[jboss-jira] [JBoss JIRA] (WFLY-7914) injection of sub-sub-EJB fails with proxy

Tom Eicher (JIRA) issues at jboss.org
Thu Jan 19 08:20:00 EST 2017


Tom Eicher created WFLY-7914:
--------------------------------

             Summary: injection of sub-sub-EJB fails with proxy
                 Key: WFLY-7914
                 URL: https://issues.jboss.org/browse/WFLY-7914
             Project: WildFly
          Issue Type: Bug
    Affects Versions: 10.1.0.Final
         Environment: WildFly 10.1.0.Final
wildfly-arquillian-2.0.2.Final
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
            Reporter: Tom Eicher
            Assignee: Jason Greene


When a hierarchy of EJBs is looked up via {{Inject Instance}} for an interface that the toplevel ejb implements, lower-hierarchy EJBs are not found unless they (redundantly) reimplement the interface, when Weld is using view proxies.

In more Detail:
{code}
public interface A extends Serializable {}
...
@Stateless
public class A1 implements A {
	public A1() {
	}
}
...
public interface B extends A {}
...
@Stateless
public class B1 implements B {
	public B1() {
	}
}
...
public abstract class C implements A { }
...
@Stateless
public class C1 extends C {
	public C1() {
	}
}
...
@Stateless
public class C2 extends C implements A {
	public C2() {
	}
}

...
@Singleton
public class WeldProcessorInjectionProblemBean {
}
...
public class WeldProcessortInjectionProblemTest {
	
	@Inject WeldProcessorInjectionProblemBean client;
	@Inject @Any Instance<A> testinstances;

	@Test
	public void testSubclassInjection() {
		boolean foundE1=false, foundE2=false;
		for (A a : testinstances) {
			if (a instanceof E1) {
				foundE1=true;
			}
			if (a instanceof E2) {
				foundE2=true;
			}
		}
		Assert.assertFalse("subsub EJB without re-implementaion of parent-parent-if was found. Weld was fixed. please remove workaround.", foundE1);
		Assert.assertTrue("subsub EJB with re-implementaion of parent-parent-if was found. Weld even more broken?", foundE2);
	}
}
...
Proxy for view class: com.ehtwo.core.util.A of EJB: C2
Proxy for view class: com.ehtwo.core.util.A of EJB: A1
Proxy for view class: com.ehtwo.core.util.B of EJB: B1
{code}

so, C1 is _not found/injected_ but C2 _is found/injected_, just because C2 re-implements A, which is redundant because it's at the top of the class hierarchy anyway.

this only happens when "proxy for view" are being applied. (in my case because the EJBs are in a JAR and the Test in a WAR inside an EAR). When running inside one module, and no weld proxies are used, all classes including C1 are injected correctly.

please move/copy issue to Wildfly-Core or Weld or as you see fit.




--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list