users@glassfish.java.net

Re: JAX-RS on Glassfish 3.1: _at_EJB injection?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 16 Jun 2010 10:49:53 +0200

Hi Laird,

Your example works fine for me on GlassFish 3.0. BTW you need to
update the top level pom to include the war module.

However, it fails on GlassFish 3.0.1 b20 as shipped with NetBeans 6.9
RC 2.

SEVERE: Exception while loading the app
org.glassfish.deployment.common.DeploymentException: WELD-001409
Injection point has ambiguous dependencies. Injection point: field
ljnelson.frobnicator.jaxrs.FrobnicatorResource.junk; Qualifiers:
[@javax.enterprise.inject.Default()]; Possible dependencies:
[org.jboss.weld.bean-/Users/paulsandoz/Downloads/glassfish-bugs/
frobnicator/ear/target/gfdeploy/ljnelson_frobnicator-ear_ear_1.0-
SNAPSHOT/lib/frobnicator-jaxrs-1.0-SNAPSHOT.jar-ManagedBean-class
ljnelson.frobnicator.jaxrs.Junk, org.jboss.weld.bean-/Users/paulsandoz/
Downloads/glassfish-bugs/frobnicator/ear/target/gfdeploy/
ljnelson_frobnicator-ear_ear_1.0-SNAPSHOT/frobnicator-war-1.0-
SNAPSHOT_war/-ManagedBean-class ljnelson.frobnicator.jaxrs.Junk]

It looks like Weld is getting confused thinking there are two possible
dependencies for Junk, because it is in a jar included in the war. I
dunno if this is specially a Weld issue or the integration of Weld
into GF.

See end of email for more of the log.

I get the same exception if i deploy to GlassFish 3.1 b04.

Can you log an issue?

There seems to be another bug with 3.0.1 and 3.1 related to the web
container thinking the Jersey ServletContainer is a CDI managed bean
when in fact it was instantiated by Jersey's
ServletContainerInitializer.

Paul.

GlassFish 3.0.1 log
--------------------------
INFO: WELD-000900 1.0.1 (SP3)
INFO: Instantiated an instance of
org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: Portable JNDI names for EJB FrobnicatorBean : [java:global/
ljnelson_frobnicator-ear_ear_1.0-SNAPSHOT/frobnicator-ejb-1.0-SNAPSHOT/
FrobnicatorBean, java:global/ljnelson_frobnicator-ear_ear_1.0-SNAPSHOT/
frobnicator-ejb-1.0-SNAPSHOT/FrobnicatorBean!
ljnelson.frobnicator.api.Frobnicator]
INFO: Registering the Jersey servlet application, named
ljnelson.frobnicator.war.Application, at the servlet mapping, /
frobnication/*, with the Application class of the same name
INFO: Updating configuration from org.apache.felix.fileinstall-
autodeploy-bundles.cfg
INFO: Installed /Applications/NetBeans/glassfish-3.0.1-b20/glassfish/
modules/autostart/org.apache.felix.fileinstall-autodeploy-bundles.cfg
INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = /
Applications/NetBeans/glassfish-3.0.1-b20/glassfish/domains/domain1/
autodeploy/bundles, felix.fileinstall.debug = 1,
felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir
= /var/folders/vd/vdTgcMYGEb0tkynCTcnFH++++TI/-Tmp-/
fileinstall--7810245262067255821, felix.fileinstall.filter = null}
INFO: Loading application ljnelson_frobnicator-ear_ear_1.0-
SNAPSHOT#frobnicator-war-1.0-SNAPSHOT.war at /frobnicator-war
SEVERE: Exception while loading the app
org.glassfish.deployment.common.DeploymentException: WELD-001409
Injection point has ambiguous dependencies. Injection point: field
ljnelson.frobnicator.jaxrs.FrobnicatorResource.junk; Qualifiers:
[@javax.enterprise.inject.Default()]; Possible dependencies:
[org.jboss.weld.bean-/Users/paulsandoz/Downloads/glassfish-bugs/
frobnicator/ear/target/gfdeploy/ljnelson_frobnicator-ear_ear_1.0-
SNAPSHOT/lib/frobnicator-jaxrs-1.0-SNAPSHOT.jar-ManagedBean-class
ljnelson.frobnicator.jaxrs.Junk, org.jboss.weld.bean-/Users/paulsandoz/
Downloads/glassfish-bugs/frobnicator/ear/target/gfdeploy/
ljnelson_frobnicator-ear_ear_1.0-SNAPSHOT/frobnicator-war-1.0-
SNAPSHOT_war/-ManagedBean-class ljnelson.frobnicator.jaxrs.Junk]
         at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:181)
         at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:
125)
         at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
239)
         at
com
.sun
.enterprise
.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
         at
com
.sun
.enterprise
.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
         at
org
.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
272)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:305)
         at
com
.sun
.enterprise
.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
         at
com
.sun
.enterprise
.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
         at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
365)
         at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
         at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
166)
         at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
100)
         at
com
.sun
.enterprise
.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
         at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
         at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
         at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
         at
com
.sun
.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
         at
com
.sun
.grizzly
.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
         at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
         at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
         at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
         at
com
.sun
.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
         at
com
.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
         at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
         at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
         at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
         at java.lang.Thread.run(Thread.java:637)
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409
Injection point has ambiguous dependencies. Injection point: field
ljnelson.frobnicator.jaxrs.FrobnicatorResource.junk; Qualifiers:
[@javax.enterprise.inject.Default()]; Possible dependencies:
[org.jboss.weld.bean-/Users/paulsandoz/Downloads/glassfish-bugs/
frobnicator/ear/target/gfdeploy/ljnelson_frobnicator-ear_ear_1.0-
SNAPSHOT/lib/frobnicator-jaxrs-1.0-SNAPSHOT.jar-ManagedBean-class
ljnelson.frobnicator.jaxrs.Junk, org.jboss.weld.bean-/Users/paulsandoz/
Downloads/glassfish-bugs/frobnicator/ear/target/gfdeploy/
ljnelson_frobnicator-ear_ear_1.0-SNAPSHOT/frobnicator-war-1.0-
SNAPSHOT_war/-ManagedBean-class ljnelson.frobnicator.jaxrs.Junk]
         at
org
.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:
280)
         at
org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:122)
         at
org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:141)
         at
org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:331)
         at
org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:
317)
         at
org
.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:
399)
         at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:178)
         ... 30 more



SEVERE: Exception while deploying the app
java.lang.IllegalStateException: Unknown JCDI-enabled managed bean
com.sun.jersey.spi.container.servlet.ServletContainer_at_13f6edc5 of
class class com.sun.jersey.spi.container.servlet.ServletContainer
         at
com
.sun
.enterprise
.container
.common
.impl
.managedbean
.ManagedBeanManagerImpl.destroyManagedBean(ManagedBeanManagerImpl.java:
534)
         at
com
.sun
.enterprise
.container
.common
.impl
.util
.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:
340)
         at
com
.sun
.web
.server
.J2EEInstanceListener.handleAfterEvent(J2EEInstanceListener.java:324)
         at
com
.sun
.web
.server.J2EEInstanceListener.instanceEvent(J2EEInstanceListener.java:
108)
         at
org
.apache
.catalina.util.InstanceSupport.fireInstanceEvent(InstanceSupport.java:
381)
         at
org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:
1740)
         at
org.apache.catalina.core.StandardWrapper.stop(StandardWrapper.java:2036)
         at
org.apache.catalina.core.StandardContext.stop(StandardContext.java:5482)
         at com.sun.enterprise.web.WebModule.stop(WebModule.java:513)
         at
org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:
1042)
         at
com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:
2130)
         at
com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:
2085)
         at
com.sun.enterprise.web.WebApplication.stop(WebApplication.java:134)
         at org.glassfish.internal.data.EngineRef.stop(EngineRef.java:
166)
         at com.sun.enterprise.v3.server.ApplicationLifecycle
$1.actOn(ApplicationLifecycle.java:229)
         at
com
.sun
.enterprise
.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:359)
         at
com
.sun
.enterprise
.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:199)
         at
org
.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
286)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:322)
         at
com
.sun
.enterprise
.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:337)
         at
com
.sun
.enterprise
.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:965)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$1200(CommandRunnerImpl.java:92)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1088)
         at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1077)
         at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
366)
         at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:203)
         at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
166)
         at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
113)
         at
com
.sun
.enterprise
.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
         at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:802)
         at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:705)
         at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:986)
         at
com
.sun
.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
178)
         at
com
.sun
.grizzly
.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
         at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
         at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
         at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
         at
com
.sun
.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
         at
com
.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
         at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
         at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:526)
         at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:507)
         at java.lang.Thread.run(Thread.java:637)


On Jun 15, 2010, at 11:47 PM, glassfish_at_javadesktop.org wrote:

> To be very clear: CDI does not work with the project as it is
> attached.
>
> If instead of @RequestScoped I annotate my resource with
> @ManagedBean, then not only is the EJB injected properly (!) but so
> is the "control group" CDI resource. It appears that without
> @ManagedBean, no resource injection of any kind--CDI, EJB or
> otherwise--occurs; with it, it appears that all resource injection
> occurs.
>
> Thoughts? This is getting crazy.
>
> Best,
> Laird
> [Message sent by forum member 'ljnelson']
>
> http://forums.java.net/jive/thread.jspa?messageID=474391
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>