ResourceHandler creates an incorrect injector when a bean has a interceptor with
injection-target
-------------------------------------------------------------------------------------------------
Key: EJBTHREE-2061
URL:
https://jira.jboss.org/jira/browse/EJBTHREE-2061
Project: EJB 3.0
Issue Type: Bug
Components: core
Affects Versions: EJB3_1 1.0.5, Plugin 1.0.19, 1.1.22
Reporter: jaikiran pai
Assignee: jaikiran pai
Fix For: as-int 1.1.23, EJB3_1 1.0.6
Consider the following bean with an interceptor:
@Stateless
@Interceptors(SimpleInterceptor.class)
@Remote(InjectionTester.class)
public class SimpleStatelessBean implements InjectionTester
{
...
and the corresponding interceptor class:
public class SimpleInterceptor
{
private EJBContext ejbContextInjectedThroughEjbJarXml;
...
}
and the ejb-jar.xml which configures injection-target for the interceptor:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<interceptors>
<interceptor>
<interceptor-class>org.jboss.ejb3.test.interceptor.SimpleInterceptor</interceptor-class>
<resource-env-ref>
<resource-env-ref-name>someOtherENCName</resource-env-ref-name>
<resource-env-ref-type>javax.ejb.EJBContext</resource-env-ref-type>
<injection-target>
<injection-target-class>org.jboss.ejb3.test.interceptor.SimpleInterceptor</injection-target-class>
<injection-target-name>ejbContextInjectedThroughEjbJarXml</injection-target-name>
</injection-target>
</resource-env-ref>
</interceptor>
</interceptors>
</ejb-jar>
This results in the following exception:
16:25:56,659 ERROR [FieldBeanProperty] failed to set value
org.jboss.ejb3.stateless.StatelessSessionContextImpl@61a781 on field private
javax.ejb.EJBContext
org.jboss.ejb3.test.interceptor.SimpleInterceptor.ejbContextInjectedThroughEjbJarXml
java.lang.IllegalArgumentException: Can not set javax.ejb.EJBContext field
org.jboss.ejb3.test.interceptor.SimpleInterceptor.ejbContextInjectedThroughEjbJarXml to
org.jboss.ejb3.test.interceptor.SimpleStatelessBean
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:1138)
at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:83)
at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:56)
at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:51)
at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:52)
at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:92)
at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:58)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:201)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:438)
at
org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:897)
at
org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:768)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:721)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:548)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234)
The ResourceHandler ends up creating an injector for the bean instance (instead of the
interceptor):
private static void loadXmlResourceEnvRefs(InjectionContainer container,
Collection<ResourceEnvironmentReferenceMetaData> refs)
{
for (ResourceEnvironmentReferenceMetaData envRef : refs)
{
....
try
{
if(resTypeName != null)
{
...
if (envRef.getInjectionTargets() != null)
{
InjectionUtil.createInjectors(container.getInjectors(),
container.getClassloader(), factory, envRef.getInjectionTargets());
continue;
}
(Notice the use of InjectionUtil.createInjectors which creates an injector for the bean
instance (i.e. adds the injector to container.injectors()). The ResourceHandler should
instead use
InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
--
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