Community
Participate
Working Groups
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.
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
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?
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
Closing this issue as this is not a jetty bug.