Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314833 - maven jetty:run uses wrong webAppSourceDirectory by default
Summary: maven jetty:run uses wrong webAppSourceDirectory by default
Status: CLOSED WONTFIX
Alias: None
Product: Jetty
Classification: RT
Component: other (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 7.0.2.RC0   Edit
Assignee: Jan Bartel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-28 05:32 EDT by Karsten Ohme CLA
Modified: 2010-06-09 22:50 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Ohme CLA 2010-05-28 05:32:38 EDT
Hi,

the Maven jetty:run does not work out of the box for me.

I use the Scannotation library http://scannotation.sourceforge.net/

There is a method whch regtrieves the class path:

URL webInfClassesPath = WarUrlFinder.findWebInfClassesPath(webConfig.getServletContext());

Unfortunately this dos not work with jetty:run, because the webAppSourceDirectory is configured to use the src directory by default. There are no compiled classes. Also filtering files does not work with this approach.

Fix would be to use the ${basedir}/target/${artifactId}-${version}/ as default directory for all web application data.

            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <webAppSourceDirectory>${basedir}/target/${artifactId}-${version}/</webAppSourceDirectory>
                    <webAppConfig>
                        <contextPath>/${artifactId}</contextPath>
                        <descriptor>${basedir}/target/${artifactId}-${version}/WEB-INF/web.xml</descriptor>
                    </webAppConfig>
                    <classesDirectory>${basedir}/target/${artifactId}-${version}/WEB-INF/classes</classesDirectory>
                    <connectors>
                        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                            <port>8080</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                </configuration>
            </plugin>

This also affects the maven jetty plugin in version 6.
Comment 1 Jan Bartel CLA 2010-05-28 07:20:48 EDT
Hi Karsten,

The mvn jetty:run goal is designed specifically on an unassembled webapp, based on the constituent bits and pieces of the webapp. The webAppSrc directory is where you place static files and normally WEB-INF static files, however the plugin makes up the web app's classpath by amalgamating target/classes and the various dependency jars.

The default location for webAppSrc directory cannot be in target/ because that would require the webapp to be assembled into a war first.

I think the problem is that the scannotation library you are using is designed only to work on an assembled webapp when WEB-INF contains the classes and jars.

So one easy solution for you would be to use the mvn jetty:run-exploded target instead, whereby the webapp is in fact assembled, but jetty works off target/${artifactId}-${version}, so all the classes etc will be in the location that scannotation expects.

Other than that, is there perhaps some other alternative class-finding option for scannotation that is more configurable that you could use?

cheers
Jan
Comment 2 Karsten Ohme CLA 2010-05-28 07:42:13 EDT
Hi John,

I thought webAppSourceDirectory is the solution, because changing it, solved my problem.

So, when to use jetty:run at all? If I use filters in Maven to modify my web.xml it will also not work?

So the default jetty goal to use for web apps should be run-exploded?

What is the purpose of the simple jetty:run target?
Comment 3 Jan Bartel CLA 2010-05-28 10:18:34 EDT
Karsten,

There are many configuration options for the jetty plugin. One of them is <webXml> which tells jetty where to find the web.xml for your project. So, if its not in the standard location of src/main/webapp/WEB-INF, then use that to tell jetty the location of it after the filters are applied etc.

Your project just happens to be using a 3rd party library that just isn't adapted to running in an unassembled webapp. For those cases we supply mvn jetty:run-war or mvn jetty:run-exploded.  Alternatively, maybe you could look into ways to provide the classes to scannotations via the context classloader.

regards
Jan
Comment 4 Jan Bartel CLA 2010-06-09 22:50:07 EDT
Closing this issue as this is not a jetty bug.