简体   繁体   中英

Classes folder instead of jars in Jetty configuration

i'm migrating our web application from Tomcat 7 to Jetty 9. Ant task is used for Jetty startup. Jar files are located under WEB-INF/lib, class files are located under .build/classes.

The question is: is there any way to specify a folder containing class files instead of jars when performing annotations scan?

Below is Ant target configuration being used:

  <target name="jetty.run">
    <jetty.run tempDirectory="jetty-temp">
      <webApp war="app" contextpath="/">
        <attributes>
          <attribute name="org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern" value=".*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$"/>
          <attribute name="org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern" value=".*classes.*"/>
        </attributes>
        <classes dir=".build/classes">
          <include name="**/*.class" />
        </classes>
        <!--<lib dir=".build/classes">
          <include name="**/*.class" />
        </lib>-->
      </webApp>
      <connectors>
        <connector port="8090"/>
        <connector port="80"/>
      </connectors>
    </jetty.run>
  </target>

I've tried specifying classes element, but it seems to be ignored (.build folder resides at the same location where build.xml is). So the application code jar has to be built and copied to WEB-INF/lib in order for the application to start properly.

Jars reside in a standard location, but classes don't. Could this somehow cause this?

I'd be grateful for any help.

Thanks, Vitaliy.

I think you should open a bug on jetty for this: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Jetty

The jetty-ant integration will add the onto the classpath, but unfortunately it won't scan them for annotations.

If you upgraded to jetty-9.1.0.M0, then you could try specifying the classes dir instead as , as we implemented annotation scanning on the extraClasspath with this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=416597 . Note however,as Joakim says, that the dir name cannot start with a "." as this denotes a hidden directory.

regards Jan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM