0

I want to serve a directory so I could open an html webpage. My structure is as follows:

C:\ 
¦
¦-- myProj\
    ¦
    ¦index.html
    ¦
    ¦jar\
      ¦
     jetty-distribution-9.4.18.v20190429\
      ¦
      ¦(some jetty folders...)
      ¦(some jetty files...)
      ¦start.jar

and inside the folder C:\myProj\jar\jetty-distribution-9.4.18.v20190429 I have unzipped jetty-distribution-9.4.18.v20190429.zip which I downloaded from Eclipse Jetty Downloads.

I then cd C:\myProj and try to start the server with the following

java -jar ./jar/jetty-distribution-9.4.18.v20190429/start.jar

However I receive the following msg

    C:\myProj>java -jar ./jar/jetty-distribution-9.4.18.v20190429/start.jar
ERROR : Nothing to start, exiting ...

Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
       java -jar $JETTY_HOME/start.jar --help  # for more information

What am I doing wrong please? According to this example near the bottom of the page in the documentation it should work

"The following demonstrates this by allowing default discovery of ${jetty.home} via locating the start.jar, and using the user.dir System Property for ${jetty.base}."

[jetty-distribution-9.4.18.v20190429]$ pwd
/home/user/jetty-distribution-9.4.18.v20190429

[jetty-distribution-9.4.18.v20190429]$ cd /home/user/my-base
[my-base]$ java -jar /home/user/jetty-distribution-9.4.18.v20190429/start.jar

2013-10-16 09:08:47.802:INFO:oejs.Server:main: jetty-9.4.18.v20190429
2013-10-16 09:08:47.817:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/home/user/my-base/webapps/] at interval 1

Obviously I must be missing something here....

Aenaon
  • 3,169
  • 4
  • 32
  • 60
  • I had the same issue. Maybe this answer can help you : https://stackoverflow.com/a/35797802/10775356 – SmartTom Nov 05 '19 at 15:14

4 Answers4

0

I had the same problem on MacOS with Jetty 9.4.x. Upgrading to Jetty 10.0.0 solved the problem. It seems specific to Jetty 9.

0

This happened to me as well.

The documentation states that you need to create a start.d directory and specify the Jetty modules to run:


> java -jar $JETTY_HOME/start.jar --create-startd
INFO : Base directory was modified
> java -jar $JETTY_HOME/start.jar --add-to-start=http,deploy

INFO: server          initialised (transitively) in ${jetty.base}/start.d/server.ini
INFO: http            initialised in ${jetty.base}/start.d/http.ini
INFO: security        initialised (transitively) in ${jetty.base}/start.d/security.ini
INFO: servlet         initialised (transitively) in ${jetty.base}/start.d/servlet.ini
INFO: webapp          initialised (transitively) in ${jetty.base}/start.d/webapp.ini
INFO: deploy          initialised in ${jetty.base}/start.d/deploy.ini
MKDIR: ${jetty.base}/webapps
INFO: Base directory was modified

> cp $JETTY_HOME/demo-base/webapps/async-rest.war webapps/ROOT.war
> java -jar $JETTY_HOME/start.jar

2015-06-04 11:10:16.286:INFO::main: Logging initialized @274ms

Copying the start.ini from the Jetty home to the base dir and modifying it also worked for me.

Alex Gyoshev
  • 11,929
  • 4
  • 44
  • 74
0

In my case, the following steps really helped:

JETTY_HOME="<the path to the jetty home folder>"
JETTY_BASE="<the path to the jetty base folder>"
java -jar $JETTY_HOME/start.jar jetty.base=$JETTY_BASE jetty.home=$JETTY_HOME

As you can see, I've set the jetty.base and jetty.home properties during the startup of Jetty.

JETTY_HOME: This is the location for the Jetty distribution binaries, default XML IoC configurations, and default module definitions. In my case, it was /jetty-home-10.0.15.

JETTY_BASE: This is the location for your configurations and customizations to the Jetty distribution. Usually, it's the root directory where you installed Jetty. In my case, it was /jetty-home-10.0.15/base.

You can create the JETTY_BASE directory using the following commands:

cd $JETTY_HOME
mkdir base
cd base
java -jar ../start.jar --create-startd

PS.

  • Since some MacOS users may still experience problems, upgrading Jetty from 9.4.* to 10.0.* can be really helpful. It helped in my case, at least.
  • Also, removing some modules helped me, e.g., the demo module in my case.

Here is the official documentation on how to start Jetty with different paths.

This article could also be useful - link.

Volodya Lombrozo
  • 2,325
  • 2
  • 16
  • 34
-1

The start.jar in the ${jetty.home} directory (in your case that directory is /home/user/jetty-distribution-9.4.18.v20190429/) is for starting a configured instance of Jetty.

Note: you can also use the newer jetty-home-<ver>.tar.gz artifact instead of the older jetty-distribution artifact.

What does that mean?

Well, it means ...

  • You have a ${jetty.base} directory somewhere
  • The ${jetty.base} directory doesn't overlap with the ${jetty.home} directory (and vice-versa)
  • The ${jetty.base} directory has its configuration in *.ini files.
    • First it looks for ${jetty.base}/start.ini
    • Then it looks for ${jetty.base}/start.d/*.ini
  • Each line in the various *.ini files are just command line options for start.jar

You can see this configuration by using the --list-config option.

example:

[~]$ cd /home/user/my-base
[my-base]$ java -jar /home/user/jetty-distribution-9.4.18.v20190429/start.jar --list-config
Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • are there any examples on how to do set `jetty.base` please especially in windows. I tried `SET JETTY_BASE='C:\myProj\jar'` but obviously it doesnt work. All I want to achieve is to serve a dir and then open an html file. Many thanks! – Aenaon May 29 '19 at 14:59
  • jetty.base is a directory. it's always the current working directory. you cd into it, and then run the commands. as shown in the answer. Since this is stackoverflow, with a focus on programming, why not just make a simple embedded-jetty server that does exactly what you want/need, without all of the extra work that jetty-standalone brings into the picture? – Joakim Erdfelt May 29 '19 at 15:21
  • i wanted a portable solution, something that doesnt require the end user to install any programs or other dependencies and also I just do not know java – Aenaon May 29 '19 at 15:30