users@glassfish.java.net

Re: Possible gf weld/CDI integration bug - _at_Inject of EJB with superclass

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Thu, 19 Aug 2010 17:10:46 +0530

Hi

Yes, this appears to be a bug. I was able to reproduce the issue thanks
to your detailed instructions and narrowed it down to the EJB services
implementation in GlassFish. For a no-interface local bean we weren't
resolving the super-class as a valid business interface. Could you
please file a bug in GlassFish issue tracker and I will fix this.

Thanks again for raising this issue and providing a good test-case with
this report.

Thanks
--Siva.

On Thursday 19 August 2010 08:55 AM, glassfish_at_javadesktop.org wrote:
> Hi all
>
> I have an EJB I need to inject into a session-scoped model object, but I'm hitting what looks increasingly like a possible CDI/Weld integration bug when doing it. A self-contained example project (.zip) and deployable webapp (.war) demonstrating the problem are attached.
>
> In short, I have a @Stateless EJB that I am injecting as a no-interface local view into another managed object. The @Stateless EJB inherits much of its functionality from a superclass. Weld performs the injection fine, producing a suitable proxy object, but the proxy object can't resolve methods that are implemented in the EJB's superclass.
>
> If I call a method that's implemented, or overridden, directly in the EJB implementation its self, Weld resolves it fine. If I call a method implemented in the superclass the EJB extends, Weld throws an IllegalStateException "Unable to convert ejbRef for ejb SuperClassName". It appears to be trying to access the superclass as an EJB rather than accessing the real, declared EJB and access the superclass methods via the real EJB.
>
> If I inject the EJB with @EJB instead of @Inject then the container/JSF2 implementation does the injection via a different proxy object implementation, which correctly resolves references to superclass methods.
>
> The reason I suspect this might be a glassfish (3.0.1) integration issue with weld is that my test case functions correctly when deployed to JBoss AS 6 M4, with Weld resolving the methods on the superclass correctly. JBoss AS 6 M4 bundles Weld 1.0.1.SP4. If I upgrade Glassfish 3.0.1 to 1.0.1.Final by replacing modules/weld-osgi-bundle.jar with the weld-osgi-bundle jar from Weld 1.0.1.Final maven, then restart glassfish, I can still reproduce the problem with glassfish, so it doesn't seem to be a core weld issue. After the upgrade Glassfish prints "INFO: WELD-000900 1.0.1 (Final)" in its log, so it's clearly seeing the new version.
>
> An outline of the simplified test case that demonstrates the problem is:
>
> [code]
> @Named
> @RequestScoped
> public class InjectionSite {
> @Inject private EJBClass ejb;
> public int getValue() {
> // Throws IllegalStateException from Weld
> return ejb.getValue();
> }
> }
>
> @Stateless
> public class EJBClass extends EJBSuper {
> // Inherits getValue() from super
> }
>
> public class EJBSuper {
> public int getValue() {
> return 1;
> }
> }
> [/code]
>
> The full exception thrown is:
>
> [code]
> java.lang.IllegalStateException: Unable to convert ejbRef for ejb InheritFailsEJB to a business object of type class com.mycompany.errordemo.InheritParent
> at com.sun.ejb.containers.EjbContainerServicesImpl.getBusinessObject(EjbContainerServicesImpl.java:104)
> at org.glassfish.weld.ejb.SessionObjectReferenceImpl.getBusinessObject(SessionObjectReferenceImpl.java:60)
> at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:123)
> at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
> at com.mycompany.errordemo.InheritFailsEJB_$$_javassist_47.getValue(InheritFailsEJB_$$_javassist_47.java)
> at com.mycompany.errordemo.RequestBeanCDI.getValue(RequestBeanCDI.java:32)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:613)
> at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:304)
> at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
> at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
> at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:298)
> at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
> at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
> at com.mycompany.errordemo.RequestBeanCDI_$$_javassist_53.getValue(RequestBeanCDI_$$_javassist_53.java)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:613)
> at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
> at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
> at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
> at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
> at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)
> at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:217)
> at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:141)
> at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:78)
> at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:75)
> at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:176)
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
> at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
> at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
> at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
> at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
> at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
> at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
> at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
> at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
> at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
> at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
> at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
> at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
> at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
> at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
> at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
> at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
> at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
> at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
> at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
> at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
> at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
> at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
> at java.lang.Thread.run(Thread.java:717)
> [/code]
>
> (This test case was produced based on research done after posting http://forums.java.net/jive/thread.jspa?threadID=152567&tstart=0 )
> [Message sent by forum member 'ringerc']
>
> http://forums.java.net/jive/thread.jspa?messageID=480532
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>