[jboss-user] [EJB 3.0] - Injecting SessionContext
MirekSz
do-not-reply at jboss.com
Tue Jul 21 08:11:21 EDT 2009
Hi,
I have a problem with injecting sessionContext value
My interceptor class:
| public class InterceptorTest {
|
| javax.ejb.SessionContext sessionContext;
|
| public Object execute(InvocationContext invocation) throws Exception {
| System.out.println("session contect "+sessionContext);
| return invocation.proceed();
| }
| }
|
this interceptor is describe like that
| <interceptors>
| <interceptor>
| <interceptor-class>test.InterceptorTest</interceptor-class>
| <around-invoke>
| <method-name>execute</method-name>
| </around-invoke>
| <resource-env-ref>
| <resource-env-ref-name>SessionContext</resource-env-ref-name>
| <resource-env-ref-type>javax.ejb.SessionContext</resource-env-ref-type>
| <injection-target>
| <injection-target-class>test.InterceptorTest</injection-target-class>
| <injection-target-name>sessionContext</injection-target-name>
| </injection-target>
| </resource-env-ref>
| </interceptor>
| </interceptors>
|
When I invoke some method which use this interceptor I get exception
| Exception in thread "main" javax.ejb.EJBException: java.lang.IllegalArgumentException: failed to set value org.jboss.ejb3.stateless.StatelessSessionContextImpl at 1ad3046 on field javax.ejb.SessionContext test.InterceptorTest.sessionContext
|
But when I add @Resource annotation on SessionContext sessionContext;
it works fine, but I want do this by ejb-jar.xml. What could be a problem? I use JBOSS 5.0
Best regards
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244953#4244953
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244953
More information about the jboss-user
mailing list