Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
07. Jul 2008, 14:05 CET | Link

Hi!

Im trying to test my stateful session bean with SeamTest (testng). I got an Exception when running the following line in my Testclass:

setValue("#{c_musterprodukt.newMprName}", "MyName"); 
//c_musterprodukt is the name of my session bean

The Exception is:

java.lang.RuntimeException: Unable to inject jndi dependency: env/org.mydomain.musterprodukt.impl.MusterproduktConversationBean/ctx into property org.mydomain.musterprodukt.impl.MusterproduktConversationBean.ctx: EJBContext not bound at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:77) at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:89)

What can be the cause of this?

Thanks in advance,

Andreas

5 Replies:
08. Jul 2008, 01:52 CET | Link
Arbi Sookazian

when you deploy the app, view the console/log to see if the SFSB in question is being deployed properly and its JNDI reference is available. Then check the JNDI address to see if matches the above or not (you can also use jboss jmx-console I think to check).

08. Jul 2008, 13:12 CET | Link
Arbi Sookazian wrote on Jul 08, 2008 01:52:
when you deploy the app, view the console/log to see if the SFSB in question is being deployed properly and its JNDI reference is available. Then check the JNDI address to see if matches the above or not (you can also use jboss jmx-console I think to check).

Thanks for your answer.

The deployment works without errors, the deployed application works too (well, not perfect, but runs).

Thats the corresponding output during deployment:

13:02:34,787 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=JBoss_rwb-ear.ear,jar=JBoss_rwb-ejb.jar,name=MusterproduktConversationBean,service=EJB3 with dependencies:
13:02:34,787 INFO  [JmxKernelAbstraction] 	jboss.j2ee:ear=JBoss_rwb-ear.ear,jar=JBoss_rwb-ejb.jar,name=RWBMusterproduktServiceFacade,service=EJB3

13:02:34,803 INFO  [EJBContainer] STARTED EJB: org.mydomain.MusterproduktConversationBean ejbName: MusterproduktConversationBean

13:02:39,568 INFO  [Component] Component: c_musterprodukt, scope: CONVERSATION, type: STATEFUL_SESSION_BEAN, class: org.mydomain.MusterproduktConversationBean, JNDI: JBoss_rwb-ear/MusterproduktConversationBean/local 

Thats the corresponding output of jndiview of the jmx-console:

 +- JBoss_rwb-ear (class: org.jnp.interfaces.NamingContext)
  |   +- MusterproduktConversationBean (class: org.jnp.interfaces.NamingContext)
  |   |   +- localStatefulProxyFactory (class: org.jboss.ejb3.stateful.StatefulLocalProxyFactory)
  |   |   +- local (class: java.lang.Object)

Can anyone help?

10. Jul 2008, 11:06 CET | Link

I found the cause of the Exception. It is the following code in my SessionBean:

@Resource 
SessionContext ctx;

I commented this and all occurences of ctx out, and the test runs now. But I need the SessionContext for Rollbacktransactions by calling:

ctx.getRollbackOnly ();
// or
ctx.setRollbackOnly ();

How can I inject SessionContext without @Resource, or how can I use rollBack Transactions without SessionCentext? How can I solve this problem?

Thanks in advance!

Andreas

12. Jul 2008, 01:28 CET | Link
Arbi Sookazian

Have you tried this?

@In private Context sessionContext;

14. Jul 2008, 16:26 CET | Link

This would be the wrong Context.

The context Andreas ist looking for is javax.ejb.SessionContext

and not

org.jboss.seam.contexts.Context