Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Scanning for annotations using embedded Jetty

Ok sorted this out, I needed to add:

        context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern"".*/target/classes/");

At deploy time within a JAR I am assuming I am going to have to change this to ".*" or ".*/"

I also had an error about asm and had to carefully remove all non 4.2 versions of asm from the classpath, see https://dev.eclipse.org/mhonarc/lists/jetty-users/msg04281.html if you have that problem.

Thanks Joakim for getting me on the right path.


-David




On Tue, Apr 1, 2014 at 10:53 AM, David Erickson <halcyon1981@xxxxxxxxx> wrote:
Thanks for the fast response, unfortunately the same problem exists:


0:50:08.527 [main] DEBUG o.e.j.a.AnnotationConfiguration - Ordering ServletContainerInitializers as container path, webapp path

10:50:08.543 [main] DEBUG o.e.j.a.AnnotationConfiguration - Annotation scanning commencing: webxml=3, metadatacomplete=false, configurationDiscovered=true, multiThreaded=true, maxScanWait=60

10:50:08.544 [main] INFO  o.e.j.a.AnnotationConfiguration - Scanned 0 container path jars, 0 WEB-INF/lib jars, 0 WEB-INF/classes dirs in 0ms for context o.e.j.w.WebAppContext@75935089{/,file:/path/to/src/main/resources/web/,STARTING}

10:50:08.567 [main] DEBUG o.e.j.a.ServletContainerInitializersStarter - Calling ServletContainerInitializer org.springframework.web.SpringServletContainerInitializer

10:50:12.591 [main] INFO  / - No Spring WebApplicationInitializer types detected on classpath


        Server server = new Server(5050);

        MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());

        server.addBean(mbContainer);

        String resourceDir = "src/main/resources/web";

        WebAppContext context = new WebAppContext();

        context.setResourceBase(resourceDir);

        context.setDescriptor(resourceDir+"/WEB-INF/web.xml");

        context.setContextPath("/");

        context.setParentLoaderPriority(true);

        context.setConfigurations(new Configuration[]

        { 

            new AnnotationConfiguration(), 

            new WebInfConfiguration(), 

            new WebXmlConfiguration(), 

            new MetaInfConfiguration(), 

            new FragmentConfiguration(),

            new EnvConfiguration(), 

            new PlusConfiguration(), 

            new JettyWebXmlConfiguration() 

        });

        server.setHandler(context);

        server.start();

        server.join();


ps, is there a default set of configurations I can use or do I need to spell out the above set?


Thanks,

David



On Tue, Apr 1, 2014 at 10:43 AM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Tue, Apr 1, 2014 at 10:34 AM, David Erickson <halcyon1981@xxxxxxxxx> wrote:
Hi I've got a simple embedded Jetty server that I'd like to have load Spring via Java config.  Jetty is correctly picking up the Spring Servlet initializer, but not finding my files on the classpath:

10:22:49.456 [main] INFO  / - No Spring WebApplicationInitializer types detected on classpath

My config is very simple:

        Server server = new Server(5050);

        MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());

        server.addBean(mbContainer);

        WebAppContext context = new WebAppContext();

        context.setContextPath("/");

        context.setWar("src/main/resources/web");

        context.setConfigurations(new Configuration[] {

                new WebXmlConfiguration(),

                new AnnotationConfiguration()

        });

        server.setHandler(context);

        server.start();

        server.join();


I found mention of this on stackoverflow here: http://stackoverflow.com/questions/13222071/spring-3-1-webapplicationinitializer-embedded-jetty-8-annotationconfiguration

Which pointed to a fix by Jan here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404176#c5

But I haven't had luck implementing this, and my Jetty API knowledge is pretty limited, so translating the text in Comment 5 to working code isn't happening.  Effectively I just want Jetty's annotation scanner to scan the entire (or some user defined subset) of the classpath/classloader that started Jetty in the first place.  Can anyone provide a minimal example of how to achieve this?


Thanks,

David




_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users




Back to the top