Injection SessionContext in interceptor by ejb-jar.xml
------------------------------------------------------
Key: EJBTHREE-1878
URL:
https://jira.jboss.org/jira/browse/EJBTHREE-1878
Project: EJB 3.0
Issue Type: Bug
Components: injection
Affects Versions: AS 5.0.0.CR1
Environment: JBOSS 5.0.0 GA JAVA 1.6_014
Reporter: Mirek Sz
When I try inject SessionContext by @Resource annotation everything works fine but when I
inject it by ejb-jar.xml file I get following error
full stacttrace:
10:15:00,445 ERROR [FieldBeanProperty] failed to set value
org.jboss.ejb3.stateful.StatefulSessionContextImpl@1687e27{containerGuid=jboss.j2ee:jar=TestEJB.jar,name=SimpleEjbImpl,service=EJB3,VMID=0c98273ef3885574:7112b98e:122cab903ab:-7f8f,id=5c4o201w-7cbr6j-fxr7llo3-1-fxr7n3od-9r}
on field javax.ejb.SessionContext test.InterceptorTest.sessionContext
java.lang.IllegalArgumentException: Can not set javax.ejb.SessionContext field
test.InterceptorTest.sessionContext to test.SimpleEjbImpl
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:57)
at java.lang.reflect.Field.set(Field.java:657)
at org.jboss.injection.lang.reflect.FieldBeanProperty.set(FieldBeanProperty.java:74)
at
org.jboss.injection.EJBContextPropertyInjector.inject(EJBContextPropertyInjector.java:50)
at
org.jboss.injection.EJBContextPropertyInjector.inject(EJBContextPropertyInjector.java:45)
at
org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:89)
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:83)
at
org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:74)
at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1076)
at org.jboss.ejb3.stateful.StatefulContainer.create(StatefulContainer.java:136)
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:402)
at org.jboss.ejb3.stateful.StatefulContainer.createSession(StatefulContainer.java:489)
at org.jboss.ejb3.session.SessionContainer.createSession(SessionContainer.java:637)
at
org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactoryBase.getNewSessionId(StatefulSessionProxyFactoryBase.java:296)
at
org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactoryBase.createProxyBusiness(StatefulSessionProxyFactoryBase.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:908)
at
org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:742)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:695)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:522)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:230)
10:15:00,445 ERROR [STDERR] java.lang.IllegalArgumentException: failed to set value
org.jboss.ejb3.stateful.StatefulSessionContextImpl@1687e27{containerGuid=jboss.j2ee:jar=TestEJB.jar,name=SimpleEjbImpl,service=EJB3,VMID=0c98273ef3885574:7112b98e:122cab903ab:-7f8f,id=5c4o201w-7cbr6j-fxr7llo3-1-fxr7n3od-9r}
on field javax.ejb.SessionContext test.InterceptorTest.sessionContext
10:15:00,446 ERROR [STDERR] at
org.jboss.injection.lang.reflect.FieldBeanProperty.set(FieldBeanProperty.java:99)
10:15:00,446 ERROR [STDERR] at
org.jboss.injection.EJBContextPropertyInjector.inject(EJBContextPropertyInjector.java:50)
10:15:00,462 ERROR [STDERR] at
org.jboss.injection.EJBContextPropertyInjector.inject(EJBContextPropertyInjector.java:45)
10:15:00,462 ERROR [STDERR] at
org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:89)
10:15:00,462 ERROR [STDERR] at
org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:83)
10:15:00,462 ERROR [STDERR] at
org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
10:15:00,462 ERROR [STDERR] at
org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:74)
10:15:00,462 ERROR [STDERR] at
org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1076)
10:15:00,462 ERROR [STDERR] at
org.jboss.ejb3.stateful.StatefulContainer.create(StatefulContainer.java:136)
10:15:00,462 ERROR [STDERR] at
org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:402)
10:15:00,463 ERROR [STDERR] at
org.jboss.ejb3.stateful.StatefulContainer.createSession(StatefulContainer.java:489)
10:15:00,463 ERROR [STDERR] at
org.jboss.ejb3.session.SessionContainer.createSession(SessionContainer.java:637)
10:15:00,463 ERROR [STDERR] at
org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactoryBase.getNewSessionId(StatefulSessionProxyFactoryBase.java:296)
10:15:00,463 ERROR [STDERR] at
org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactoryBase.createProxyBusiness(StatefulSessionProxyFactoryBase.java:160)
10:15:00,463 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
10:15:00,463 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
10:15:00,463 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
10:15:00,463 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
10:15:00,463 ERROR [STDERR] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
10:15:00,463 ERROR [STDERR] at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
10:15:00,463 ERROR [STDERR] at
org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:908)
10:15:00,463 ERROR [STDERR] at
org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:742)
10:15:00,463 ERROR [STDERR] at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:695)
10:15:00,463 ERROR [STDERR] at
org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:522)
10:15:00,463 ERROR [STDERR] at
org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:230)
10:15:00,463 ERROR [StatefulSessionProxyFactoryBase] Could not obtain new Session ID from
SFSB Container
javax.ejb.EJBException: java.lang.IllegalArgumentException: failed to set value
org.jboss.ejb3.stateful.StatefulSessionContextImpl@1687e27{containerGuid=jboss.j2ee:jar=TestEJB.jar,name=SimpleEjbImpl,service=EJB3,VMID=0c98273ef3885574:7112b98e:122cab903ab:-7f8f,id=5c4o201w-7cbr6j-fxr7llo3-1-fxr7n3od-9r}
on field javax.ejb.SessionContext test.InterceptorTest.sessionContext
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:423)
at org.jboss.ejb3.stateful.StatefulContainer.createSession(StatefulContainer.java:489)
at org.jboss.ejb3.session.SessionContainer.createSession(SessionContainer.java:637)
at
org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactoryBase.getNewSessionId(StatefulSessionProxyFactoryBase.java:296)
at
org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactoryBase.createProxyBusiness(StatefulSessionProxyFactoryBase.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:908)
at
org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:742)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:695)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:522)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:230)
Caused by: java.lang.IllegalArgumentException: failed to set value
org.jboss.ejb3.stateful.StatefulSessionContextImpl@1687e27{containerGuid=jboss.j2ee:jar=TestEJB.jar,name=SimpleEjbImpl,service=EJB3,VMID=0c98273ef3885574:7112b98e:122cab903ab:-7f8f,id=5c4o201w-7cbr6j-fxr7llo3-1-fxr7n3od-9r}
on field javax.ejb.SessionContext test.InterceptorTest.sessionContext
at org.jboss.injection.lang.reflect.FieldBeanProperty.set(FieldBeanProperty.java:99)
at
org.jboss.injection.EJBContextPropertyInjector.inject(EJBContextPropertyInjector.java:50)
at
org.jboss.injection.EJBContextPropertyInjector.inject(EJBContextPropertyInjector.java:45)
at
org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:89)
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:83)
at
org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:74)
at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1076)
at org.jboss.ejb3.stateful.StatefulContainer.create(StatefulContainer.java:136)
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:402)
... 15 more
interceptor class
public class InterceptorTest {
SessionContext sessionContext;
public Object execute(InvocationContext invocation) throws Exception {
System.out.println(invocation.getTarget());
Context context = new InitialContext();
return invocation.proceed();
}
}
ejb-jar.xml fragment
<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>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira