glassfish
  1. glassfish
  2. GLASSFISH-15888

CDI not working well on Glassfish v3.1 RC1 and RC2

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Duplicate
    • Affects Version/s: 3.1_b41
    • Fix Version/s: None
    • Component/s: cdi
    • Labels:
      None

      Description

      Up until a couple of weeks ago I worked with Glassfish 3.0. Recently, I decided to upgrade to v3.1. The first version I tried was v3.1 b35. This version seemed to work more or less OK, but there were a couple of problems in it:

      1. @Resource doesn't work (I later found this: http://java.net/jira/browse/GLASSFISH-15443?page=com.atlassian.streams.streams-jira-plugin%3Aactivity-stream-issue-tab)

      2. My log messages disappeared (I use SLF4J and GF was redirecting my log messages to its logger)

      So then I decided to install the release candidate. I installed v3.1 b41 (RC2) and in this version it seems that CDI stopped working completely! The same code worked perfectly well on v3.1 b35. I then tried it also on v3.1 b40 and had the same results.

      I experience the following problems:

      1. I have a two producer methods with qualifiers which return the EntityManager (according to the qualifier). In some of the DAOs (that use @Inject) CDI manages to find the producer method and in some it doesn't. I have no idea why it finds it in one and not in the other

      2. I have jars that contains EJBs that don't use CDI at all, so they don't contain beans.xml. Now, CDI throws a NullPointerException during the attempt to deploy the war that contains them. If I put beans.xml in these jars the exception is not thrown

      3. If I have two jars in the same war, and one is trying to inject an EJB from the other jar (using @Inject) it doesn't work. I have to add a producer method (I didn't have to in the previous versions)

      All of this is code that has been working for a long time. Now I can't even deploy the first war.

      Is this a known problem/unknown bug or has CDI gone through a major "behavior" change? Is there a way to change it back?

        Issue Links

          Activity

          Hide
          Sivakumar Thyagarajan added a comment -

          Duplicate of GLASSFISH-15721

          Show
          Sivakumar Thyagarajan added a comment - Duplicate of GLASSFISH-15721
          Hide
          ifatgv added a comment -

          I'm sorry, but I don't think this issue is resolved.

          The jar that was attached does not solve the prolem.

          I installed a new GF v3.1 b40 (RC1) and replaced this jar. My test war still does not deploy (same exceptions). Deploying my real war makes GF get into an infinite loop! (this is new, so I know the jar made a change, but not a good one).

          In order to check I did the following:

          1. Stop the domain
          2. Replace the jar in glassfish\glassfish\modules
          3. Delete the folder glassfish\glassfish\domains\BTOA\osgi-cache
          4. Start the domain
          5. Deploy the war

          Did I miss something?

          If not, please reopen this issue.

          Show
          ifatgv added a comment - I'm sorry, but I don't think this issue is resolved. The jar that was attached does not solve the prolem. I installed a new GF v3.1 b40 (RC1) and replaced this jar. My test war still does not deploy (same exceptions). Deploying my real war makes GF get into an infinite loop! (this is new, so I know the jar made a change, but not a good one). In order to check I did the following: 1. Stop the domain 2. Replace the jar in glassfish\glassfish\modules 3. Delete the folder glassfish\glassfish\domains\BTOA\osgi-cache 4. Start the domain 5. Deploy the war Did I miss something? If not, please reopen this issue.
          Hide
          vostok added a comment -

          I'm experiencing the same problems too, using the latest promoted build found at http://dlc.sun.com.edgesuite.net/glassfish/3.1/promoted/latest-glassfish.zip

          I'm using a multi-module layout in my project, just for the record, but it was being deployed w/o problems in GF 3.0.1

          Show
          vostok added a comment - I'm experiencing the same problems too, using the latest promoted build found at http://dlc.sun.com.edgesuite.net/glassfish/3.1/promoted/latest-glassfish.zip I'm using a multi-module layout in my project, just for the record, but it was being deployed w/o problems in GF 3.0.1
          Hide
          vrcollins added a comment -

          I am having the same issue with version 3.1 build 43. I replaced the weld-osgi-bundle.jar included in this ticket. It did not correct the problem.

          Show
          vrcollins added a comment - I am having the same issue with version 3.1 build 43. I replaced the weld-osgi-bundle.jar included in this ticket. It did not correct the problem.
          Hide
          vrcollins added a comment -

          This still does not seem to be working in version 3.1.1. Here is an example of my code

          @Named("userSession")
          @SessionScoped
          public class UserSession implements Serializable {

          private static final long serialVersionUID = -5357959580555377L;

          @EJB(name = "VendorAccess")
          private IVendorAccessLocal m_vendorAccess;

          private OngVendor m_vendor = null;
          private OngUser m_user = null;

          /**

          • This will get the vendor name information that is associated with the
          • user.
          • @return String
            */
            public String getVendorName() { this.initialize(); return this.m_vendor.getVendorName(); }

          protected void initialize()

          { HttpServletRequest request = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()); String host = request.getHeader("host"); host = host.substring(0, host.indexOf(":")); Map<String, OngVendor> v = this.m_vendorAccess.retrieveActiveVendors(); this.m_vendor = v.get(host); if (this.m_vendor == null) this.m_vendor = v.get("www"); }

          m_vendor is a Singleton EJB. It shows that there is an object when stepping through the code. When the retrieveActiveVendors() method is called the following error occurs.

          javax.ejb.NoSuchEJBException: Singleton VendorAccess is unavailable because its original initialization failed.
          at com.sun.ejb.containers.AbstractSingletonContainer.checkInit(AbstractSingletonContainer.java:414)
          at com.sun.ejb.containers.CMCSingletonContainer._getContext(CMCSingletonContainer.java:117)
          at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2528)
          at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1895)
          at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
          at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
          at $Proxy290.retrieveActiveVendors(Unknown Source)
          at com.clss.base.session.UserSession.initialize(UserSession.java:122)
          at com.clss.base.session.UserSession.getVendorName(UserSession.java:56)
          at com.clss.base.session.org$jboss$weld$bean-ong-web-ManagedBean-class_com$clss$base$session$UserSession_$$WeldClientProxy.getVendorName(org$jboss$weld$bean-ong-web-ManagedBean-class_com$clss$base$session$UserSession$$_WeldClientProxy.java)
          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 javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
          at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
          at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
          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:55)
          at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:224)
          at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85)
          at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
          at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:184)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
          at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
          at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
          at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:290)
          at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:290)
          at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
          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:594)
          at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:596)
          at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
          at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
          at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:726)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1020)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:91)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:56)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:662)

          This code works perfectly in Glassfish 3.0.1. Please fix this!

          Show
          vrcollins added a comment - This still does not seem to be working in version 3.1.1. Here is an example of my code @Named("userSession") @SessionScoped public class UserSession implements Serializable { private static final long serialVersionUID = -5357959580555377L; @EJB(name = "VendorAccess") private IVendorAccessLocal m_vendorAccess; private OngVendor m_vendor = null; private OngUser m_user = null; /** This will get the vendor name information that is associated with the user. @return String */ public String getVendorName() { this.initialize(); return this.m_vendor.getVendorName(); } protected void initialize() { HttpServletRequest request = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()); String host = request.getHeader("host"); host = host.substring(0, host.indexOf(":")); Map<String, OngVendor> v = this.m_vendorAccess.retrieveActiveVendors(); this.m_vendor = v.get(host); if (this.m_vendor == null) this.m_vendor = v.get("www"); } m_vendor is a Singleton EJB. It shows that there is an object when stepping through the code. When the retrieveActiveVendors() method is called the following error occurs. javax.ejb.NoSuchEJBException: Singleton VendorAccess is unavailable because its original initialization failed. at com.sun.ejb.containers.AbstractSingletonContainer.checkInit(AbstractSingletonContainer.java:414) at com.sun.ejb.containers.CMCSingletonContainer._getContext(CMCSingletonContainer.java:117) at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2528) at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1895) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88) at $Proxy290.retrieveActiveVendors(Unknown Source) at com.clss.base.session.UserSession.initialize(UserSession.java:122) at com.clss.base.session.UserSession.getVendorName(UserSession.java:56) at com.clss.base.session.org$jboss$weld$bean-ong-web-ManagedBean-class_com$clss$base$session$UserSession_$$ WeldClientProxy.getVendorName(org$jboss$weld$bean-ong-web-ManagedBean-class_com$clss$base$session$UserSession $$_WeldClientProxy.java) 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 javax.el.BeanELResolver.getValue(BeanELResolver.java:302) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) 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:55) at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:224) at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85) at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82) at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:184) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:290) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:290) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) 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:594) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:596) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:726) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1020) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:91) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:56) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:662) This code works perfectly in Glassfish 3.0.1. Please fix this!

            People

            • Assignee:
              Sivakumar Thyagarajan
              Reporter:
              ifatgv
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: