-
Enhancement
-
Resolution: Won't Do
-
Minor
-
2.2.0.Final
Attached sample web application with embedded Jetty. To launch it please use com.xyz.AppRunner.main method.
During startup we got famous Unsatisfied dependencies:
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Unsatisfied dependencies for type AdminService with qualifiers @Default at injection point [BackedAnnotatedField] @Inject private com.xyz.rest.resources.AdminEndpoint.adminService at com.xyz.rest.resources.AdminEndpoint.adminService(AdminEndpoint.java:0) at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:78) ~[weld-se-2.2.0.Final.jar:2014-04-11 20:12] at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:66) ~[weld-se-2.2.0.Final.jar:2014-04-11 20:12] at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:50) ~[weld-se-2.2.0.Final.jar:2014-04-11 20:12] at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory$2.<init>(CdiComponentProvider.java:236) ~[jersey-gf-cdi-2.14.jar:na] at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory.<init>(CdiComponentProvider.java:214) ~[jersey-gf-cdi-2.14.jar:na] at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.bind(CdiComponentProvider.java:393) ~[jersey-gf-cdi-2.14.jar:na] at org.glassfish.jersey.server.ApplicationHandler.bindWithComponentProvider(ApplicationHandler.java:905) ~[jersey-server-2.14.jar:na] at org.glassfish.jersey.server.ApplicationHandler.bindProvidersAndResources(ApplicationHandler.java:834) ~[jersey-server-2.14.jar:na] at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:435) ~[jersey-server-2.14.jar:na] at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:163) ~[jersey-server-2.14.jar:na] at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:323) ~[jersey-server-2.14.jar:na] at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289) ~[jersey-common-2.14.jar:na] at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286) ~[jersey-common-2.14.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[jersey-common-2.14.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[jersey-common-2.14.jar:na] at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286) ~[jersey-common-2.14.jar:na] at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:320) ~[jersey-server-2.14.jar:na] at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:315) ~[jersey-container-servlet-core-2.14.jar:na] at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170) ~[jersey-container-servlet-core-2.14.jar:na] at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358) ~[jersey-container-servlet-core-2.14.jar:na] at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[javax.servlet-api-3.1.0.jar:3.1.0] at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:621) [jetty-servlet-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:403) [jetty-servlet-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:873) [jetty-servlet-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:345) [jetty-servlet-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1357) [jetty-webapp-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1350) [jetty-webapp-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:734) [jetty-server-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:258) [jetty-servlet-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:512) [jetty-webapp-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) [jetty-util-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.server.Server.start(Server.java:405) [jetty-server-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) [jetty-util-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) [jetty-server-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.server.Server.doStart(Server.java:372) [jetty-server-9.3.0.v20150612.jar:9.3.0.v20150612] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.3.0.v20150612.jar:9.3.0.v20150612] at com.xyz.AppRunner.startJettyJersey_AndWeld(AppRunner.java:47) [classes/:na] at com.xyz.AppRunner.main(AppRunner.java:19) [classes/:na]
So I'm starting application with Jetty from the main class, within project source code directory (not with war archive).
What makes me think that this is expected to work? Because Weld correctly figures out that it has been launched inside servlet container (why? it uses ServletDeployment and org.jboss.weld.environment.servlet.deployment.WebAppBeanDeploymentArchive during startup).
But unfortunately inside WebAppBeanDeploymentArchive constructor URLScanner is skipping classes inside current project.
The only known workaround which I'm aware, is to create empty file beans.xml inside src/main/resources/META-INF/ (exactly as in standalone archive). Then Weld correctly discovers all classes within project. But this is a hack.