Score:0

How to deploy a WAR file to jetty without using sudo?

mx flag

deploying this specific war file to jetty is somewhat awkward:

nicholas@mordor:~/NetBeansProjects/x$ 
nicholas@mordor:~/NetBeansProjects/x$ sudo cp build/libs/x.war /var/lib/jetty9/webapps/ -v
'build/libs/x.war' -> '/var/lib/jetty9/webapps/x.war'
nicholas@mordor:~/NetBeansProjects/x$ 
nicholas@mordor:~/NetBeansProjects/x$ lynx localhost:8081/x --dump
   fron netbeans
nicholas@mordor:~/NetBeansProjects/x$ 
nicholas@mordor:~/NetBeansProjects/x$ cp build/libs/x.war /var/lib/jetty9/webapps/ -v
'build/libs/x.war' -> '/var/lib/jetty9/webapps/x.war'
cp: cannot create regular file '/var/lib/jetty9/webapps/x.war': Permission denied
nicholas@mordor:~/NetBeansProjects/x$ 
nicholas@mordor:~/NetBeansProjects/x$ uname -a
Linux mordor 5.11.0-25-generic #27-Ubuntu SMP Fri Jul 9 23:06:29 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
nicholas@mordor:~/NetBeansProjects/x$ 

So, tried as:

nicholas@mordor:~/NetBeansProjects/x$ 
nicholas@mordor:~/NetBeansProjects/x$ java -jar /usr/share/jetty9/start.jar build/libs/x.war 
ERROR : Unrecognized argument: "build/libs/x.war" in <command-line>

Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
       java -jar $JETTY_HOME/start.jar --help  # for more information
nicholas@mordor:~/NetBeansProjects/x$ 
nicholas@mordor:~/NetBeansProjects/x$ echo $JETTY_HOME

nicholas@mordor:~/NetBeansProjects/x$ 

I would expect apt to somewhat configure the environment a bit more when installing jetty.

1.) what should $JETTY_HOME get set to? 2.) how should it be set so that the environment variable persists?

Hmm, not seeing a jetty-runner.jar file from dpkg to run a war file as it's no longer part of jetty itself but must be compiled separately.

What's a work-around to deploy a war file without resorting to sudo?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.