1 2 Previous Next 20 Replies Latest reply on Nov 13, 2009 5:45 PM by andygibson.contact.andygibson.net

    ConversationScope not working

      I'm trying to create a simple ConversationScope example using Weld on Glassfish build 70, which I believe uses the Weld 1.0.0 CR1 SP1 OSGI bundle, and a very simple example is giving me a NoClassDefFoundException on javassist.util.proxy.ProxyObject... I have made no modifications of the server, and the code is quite simple, as you can see:




      @Stateful
      @Named
      @ConversationScoped
      public class EditUserFacade implements Serializable {
          @Inject
          private Conversation conversation;
      
          @Inject
          private transient UserRepository repository;
      
          private long userId;
          private User user;
      
          public void loadUser() {
              conversation.begin();
      
              user = repository.get(userId);
          }
      
          public String editUser() {
              repository.merge(user);
      
              conversation.end();
              
              return "viewUser?userId="+userId+"&faces-redirect=true";
          }
      
          ...





      The full stack trace is:



      java.lang.RuntimeException: by java.lang.NoClassDefFoundError: javassist/util/proxy/ProxyObject
           at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:344)
           at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:314)
           at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:273)
           at org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:84)
           at org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:41)
           at org.jboss.weld.bean.proxy.ClientProxyProvider$1.call(ClientProxyProvider.java:122)
           at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
           at java.util.concurrent.FutureTask.run(FutureTask.java:138)
           at org.jboss.weld.util.collections.ConcurrentCache.putIfAbsent(ConcurrentCache.java:125)
           at org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:112)
           at org.jboss.weld.BeanManagerImpl.getReference(BeanManagerImpl.java:890)
           at org.jboss.weld.BeanManagerImpl.getReference(BeanManagerImpl.java:910)
           at org.jboss.weld.bean.builtin.facade.InstanceImpl.get(InstanceImpl.java:68)
           at org.jboss.weld.bean.builtin.facade.InstanceImpl.get(InstanceImpl.java:74)
           at org.jboss.weld.conversation.ServletConversationManager.getBeanStore(ServletConversationManager.java:60)
           at org.jboss.weld.conversation.AbstractConversationManager.cleanupConversation(AbstractConversationManager.java:150)
           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.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:111)
           at org.jboss.weld.conversation.ServletConversationManager_$$_javassist_13.cleanupConversation(ServletConversationManager_$$_javassist_13.java)
           at org.jboss.weld.jsf.WeldPhaseListener.afterRenderResponse(WeldPhaseListener.java:128)
           at org.jboss.weld.jsf.WeldPhaseListener.afterPhase(WeldPhaseListener.java:99)
           at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           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:332)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
           at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:161)
           at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:789)
           at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:697)
           at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:952)
           at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:166)
           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:619)
      Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: javassist/util/proxy/ProxyObject
           at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:169)
           at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:339)
           ... 51 more
      Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/ProxyObject
           at java.lang.ClassLoader.defineClass1(Native Method)
           at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
           at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:181)
           at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:163)
           ... 52 more
      Caused by: java.lang.ClassNotFoundException: javassist.util.proxy.ProxyObject
           at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:738)
           at org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:60)
           at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1650)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
           ... 59 more
      





      ConversationScopes are a big win over plain JSF, and something I'd like to see in action -- any hints!?


      M

        • 1. Re: ConversationScope not working
          nickarls

          Sounds like the javassist classloader problem mentioned before in this forum.

          • 2. Re: ConversationScope not working
            pmuir

            Yeah, this is an issue the GlassFish guys are currently investigating (Jason Greene and myself outlined a fix to them in an email). I suggest filing an issue in the GlassFish issue tracker, you could post it back here for tracking, and I can paste in the relevant bits of the email.

            • 3. Re: ConversationScope not working

              Thanks for the quick feedback -- defect has been registered, and can be found here


              M

              • 4. Re: ConversationScope not working

                BTW -- the issue has been corrected with build 71, released on Friday or Saturday.  Thanks!


                M

                • 5. Re: ConversationScope not working
                  andygibson.contact.andygibson.net

                  Ok, I know it isn't related to your problem, but I have the same code and it isn't working.


                  My bean works when session scoped, but not when I change it to conversation scoped, it just re-creates the bean each time I call my JSF page. I am injecting an instance of a conversation (I assume @Current got renamed to @Inject?) and calling the begin conversation method :


                  @Named(value="calculator")
                  @ConversationScoped
                  public class CalculatorBean implements Serializable {
                  
                  
                  ...
                  ...
                  
                      private void calculateSum() {
                          startConversation();
                          total = 0;
                          for (Integer number : values) {
                             total = total + number;
                          }
                      }
                  
                      private void startConversation() {
                          if (conversation == null) {
                              return;
                          }
                  
                          if (!conversation.isLongRunning()) {
                              conversation.begin();
                          }
                      }
                  
                  


                  In my page I just have


                  <h:commandButton value="add" action="#{calculator.addValue}"/>
                  



                  Which I assume will always go to the conversation scoped calculator which, by the time you call it a second time will be in a long running conversation? I just don't know whether I am missing something obvious.


                  I'm also deploying on Glassfish build b71 and Weld is running ok, my app works when I use session scope. Like you, I'm eager to see how the CDI conversation stuff works in JSF.


                  Any other bits of code that I missed?


                  Cheers,


                  Andy Gibson

                  • 6. Re: ConversationScope not working
                    gavin.king

                    Well this bit looks wrong:


                            if (conversation == null) {
                                return;
                            }



                    Why would conversation be null?


                    Where do you inject it?

                    • 7. Re: ConversationScope not working
                      nickarls

                      Tried it on JBoss? Not saying that it shouldn't work everywhere, just trying to isolate the problem...

                      • 8. Re: ConversationScope not working
                        nickarls

                        Could you repeat this experiment, works for me:


                        Take the numberguess example, change Game to @ConversationScoped
                        in Game, add


                           @Inject Conversation conversation;
                           
                           public boolean isTransient() {
                                return conversation.isTransient();
                           }
                           
                           public void makeLong() {
                                conversation.begin();
                           }
                        
                        



                        and in home.xhtml


                                         <h:outputText value="Transient: #{game.transient}"/>
                                         <h:commandButton value="long" action="#{game.makeLong}"/>
                        
                        



                        inside the form tag.


                        Click the button, see the transient change to false and play the game (keeping the state)


                        If it doesn't work, file a GF JIRA


                        PS. Try the latest from trunk (or wait for the really-soon-now-1.0), I see you still have isLongRunning(), which indicates you aren't using the latest one(?)

                        • 9. Re: ConversationScope not working
                          andygibson.contact.andygibson.net

                          Sorry Nicklas, I should have included more code. My null conversation check was a 'just in case' check to see if injection was working (it is), it also logged a message if it was null. The conversation is never null, so that bit never executes and to inject the Conversation I use :




                          @Inject
                          private Conversation conversation;





                          To inject the bean. I check isLongRunning() after calling begin, and it is true, it's almost like the conversation instance gets lost, or the conversation id is never propagated.


                          Yes, I am using an old version (The one in Glassfish b71), I'll try with a newer version first since it looks like my code is correct, otherwise, I'll try the weld example on Glassfish,


                          Cheers,


                          Andy Gibson

                          • 10. Re: ConversationScope not working
                            nickarls

                            It's not impossible that it's something in the conversation propagation that behaves differently between appservers even if they both should rely on the same JSF mechanism...

                            • 11. Re: ConversationScope not working
                              andygibson.contact.andygibson.net

                              Ok, I just got the latest Weld release, built it and the osgi bundle, installed it in Glassfish. I know it is there and working because the non-serializable DefaultLiteral problem has gone (redeploying is very smooth now) and isLongRunning() is no longer valid (I'm assuming it was replaced by isTransient())


                              However, I am still without conversation scope and isTransient() is always true. Even if I remove the conversation.begin() call from my code so I never start a conversation, isTransient() always returns true.


                              Another oddity is that while the conversion is injected into my bean successfully, if I put Conversation : #{conversation} in my page, no value appears.


                              Tomorrow, I'll try it with one of the weld examples to see if that works or not, or I'll try my code on JBoss.


                              Cheers,


                              Andy

                              • 12. Re: ConversationScope not working
                                gavin.king

                                Its name is javax.enterprise.context.conversation.

                                • 13. Re: ConversationScope not working
                                  nickarls

                                  isLongRunning is !transient so temporary conversations should show transient is true and long-running, transient is false.
                                  Conversation is not @Named so it's not directly visible to EL

                                  • 14. Re: ConversationScope not working
                                    nickarls

                                    Correction, it is @Named, see Gaving post

                                    1 2 Previous Next