<< Back to previous view

[GLASSFISH-20441] JMSContext cannot be injected in a @SessionScoped bean Created: 30/Apr/13  Updated: 15/May/13  Resolved: 03/May/13

Status: Resolved
Project: glassfish
Component/s: jms
Affects Version/s: 4.0_b87_RC3
Fix Version/s: 4.0_b88_RC4, 4.0.1

Type: Bug Priority: Major
Reporter: arungupta Assignee: David Zhao
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: fishcat 4_0-approved
Participants: arungupta, Bruno Borges and David Zhao

 Description   
@Named
@SessionScoped
public class SendPointsBean implements Serializable {

   @Inject
    JMSContext context;

   ...
}

throws

Error occurred during deployment: Exception while loading the app : CDI
deployment failure:WELD-001413 The bean Managed Bean [class
org.glassfish.movieplex7.points.ReceivePointsBean] with qualifiers
[@Default @Any @Named] declares passivating scope but has non-
serializable dependency
org.glassfish.jms.injection.JMSCDIExtension$LocalBean@f6c4da4. Please
see server.log for more details.

I can inject ConnectionFactory and use it to create a local JMSContext but using the code fragment above shows the following deployment failure.



 Comments   
Comment by David Zhao [ 02/May/13 02:47 AM ]

Arun,

Could you share a small application for reproduction?

I tried injecting JMSContext into a SessionScoped managed bean and then inject the managed bean into jsf. Both deployment and run are OK with only warning printed in server.log.

[2013-05-02T10:43:04.912+0800] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=37 _ThreadName=ad
min-listener(3)] [timeMillis: 1367462584912] [levelValue: 900] [[
WELD-001473 javax.enterprise.inject.spi.Bean implementation org.glassfish.jms.injection.JMSCDIExtension$LocalBean@984cb6 declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]]

Comment by arungupta [ 02/May/13 04:40 PM ]

Tried with b87 and got the same error. Attaching the sample app as well.

Complete stack trace below:

In-place deployment at /Users/arungup/code/workspaces/javaee7-samples~source/samples/jms/jmscontext-cdi/target/jmscontext-cdi-1.0-SNAPSHOT
Initializing...
deploy?DEFAULT=/Users/arungup/code/workspaces/javaee7-samples~source/samples/jms/jmscontext-cdi/target/jmscontext-cdi-1.0-SNAPSHOT&name=jmscontext-cdi&contextroot=/jmscontext-cdi&force=true failed on GlassFish Server 4.0 (87)
Error occurred during deployment: Exception while loading the app : CDI deployment failure:Exception List with 2 exceptions:
Exception 0 :
org.jboss.weld.exceptions.UnserializableDependencyException: WELD-001413 The bean Managed Bean [class org.glassfish.sample.jmscontext.cdi.MessageReceiver] with qualifiers [@Any @Default] declares passivating scope but has non-serializable dependency org.glassfish.jms.injection.JMSCDIExtension$LocalBean@6eac366b
at org.jboss.weld.bootstrap.Validator.validateInjectionPointPassivationCapable(Validator.java:473)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:418)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:325)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:177)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:208)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:519)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:505)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:480)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:536)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:216)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)
Exception 0 :
org.jboss.weld.exceptions.UnserializableDependencyException: WELD-001413 The bean Managed Bean [class org.glassfish.sample.jmscontext.cdi.MessageSender] with qualifiers [@Any @Default] declares passivating scope but has non-serializable dependency org.glassfish.jms.injection.JMSCDIExtension$LocalBean@6eac366b
at org.jboss.weld.bootstrap.Validator.validateInjectionPointPassivationCapable(Validator.java:473)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:418)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:325)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:177)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:208)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:519)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:505)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:480)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:536)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:216)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)
. Please see server.log for more details.
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)

Comment by arungupta [ 02/May/13 04:52 PM ]

Sample is now available at:

https://blogs.oracle.com/arungupta/resource/jmscontext-cdi.zip

Comment by David Zhao [ 03/May/13 12:48 AM ]

What is the impact on the customer of the bug?
This is related to https://java.net/jira/browse/GLASSFISH-20441.
It is for the sample showing JMSContext injection (new JMS 2.0 feature) in @SessionScoped managed bean.

What is the cost/risk of fixing the bug?
It's small change, low risk

Is there an impact on documentation or message strings?
No.

Which tests should QA (re)run to verify the fix did not destabilize GlassFish?
JMSContext injection related test cases

Which is the targeted build of 4.0 for this fix?
4.0_b88

If this an integration of a new version of a component from another project,
what are the changes that are being brought in? This might be list of
Jira issues from that project or a list of revision messages.
N/A

Comment by David Zhao [ 03/May/13 09:55 AM ]

Fixed in 4.0 by revision 61813.
Ported to trunk by revision 61816.

Comment by Bruno Borges [ 14/May/13 09:24 PM ]

Tried this on GlassFish 4.0 b88 promoted on 08-May-2013 18:59 and it is not fixed.

Comment by David Zhao [ 14/May/13 10:26 PM ]

Bruno,

What do you mean for it is not fixed? What have you observed? JMSContext injection failure or just the warning logged?

Comment by arungupta [ 15/May/13 05:58 AM ]

I tried my simple use case that sends a message as:

@SessionScoped
@JMSDestinationDefinitions({@JMSDestinationDefinition(name = "java:global/jms/myQueue",
        interfaceName = "javax.jms.Queue")
})
public class MessageSender implements Serializable {

    @Inject
    JMSContext context;
   
    @Resource(mappedName="java:global/jms/myQueue")
    Queue myQueue;

    public void sendMessage(String message) {
        context.createProducer().send(myQueue, message);
    }
}

and receives a message as:

@SessionScoped
public class MessageReceiver implements Serializable {

    @Inject
    private JMSContext context;
   
    @Resource(mappedName="java:global/jms/myQueue")
    Queue myQueue;

    public String receiveMessage() {
        String message = context.createConsumer(myQueue).receiveBody(String.class, 1000);
        return message;
    }
}

And that worked.

I filed the bug because this scenario was not working and now works with 88.

What exactly is not working ?

Generated at Thu Apr 17 22:58:01 UTC 2014 using JIRA 4.0.2#472.