1

I am trying to add an external folder, setup/, to my Jetty's classpath. I can successfully add the setup folder to its classpath inside of its launch configurations in eclipse. I need to instead give it the setup folder's path as an argument to Jetty because I don't have control of the launch configurations when I run my project outside of an eclipse environment. I've tried stuff like this in the XML:

<jvmarg value="-Dpath=${DbServer.location}/setup"/>

This does not do anything... Any help is appreciated, thanks!

1
  • You should post the ANT xml used to launch jetty. I'm guessing the problem is the manner is which your defining the classpath, which is explicitly passed to the "java" ANT task. Jul 12, 2013 at 6:47

2 Answers 2

0

The issue is that the setup folder is in the WAR directory, so even pointing to anything else as the classpath will not make changes to where Jetty will look for the folder. Look here for how Jetty uses its classpath:

Jetty ClassLoading

Classes contained within WEB-INF/lib or WEB-INF/classes have priority over classes on the parent class loader. This is the opposite of the normal behaviour of a java 2 class loader.

1
0

As an example, to run it with the help of Maven (jetty-maven-plugin) :

        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.4.7.v20170914</version>
            <configuration>
                <httpConnector>
                    <port>8095</port>
                </httpConnector>
                <webApp>
                    <contextPath>/</contextPath>
                    <extraClasspath>conf/</extraClasspath>
                </webApp>
            </configuration>
        </plugin>

Then run your webapp with mvn jetty:run

At the root of my project, I have a ./conf/ directory, including some properties or xml files.

Some configuration properties for can be found at Configuring Your WebApp, but you can find undocumented properties in the class org.eclipse.jetty.webapp.WebAppContext or in org.eclipse.jetty.maven.plugin.JettyWebAppContext (its subclass).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.