1 Reply Latest reply on Oct 18, 2009 1:38 PM by Pete Muir

    ConversationScope

    Fabio Wang Newbie

      Hi there,


      I've just downloaded weld 1.0 CR1 and, after running the numberguess example on Tomcat (6.0.20), I tried to use a conversation scope (nothing serious, just anxious to see it working...) on it.


      @ConversationScoped
      public class Bean implements Serializable {
        private Long id;
        // setters and getters
      }



      Game.java:


        @Inject
        private Bean currentBean;
        
        @Inject
        private Conversation conversation;



      However, when I tried to mark the conversation as long running in the reset method of the Game, I got this error and my page couldn't be rendered -- I'm sorry for this long stacktrace:


      java.lang.NoClassDefFoundError: javassist/util/proxy/ProxyObject
           at java.lang.ClassLoader.defineClass1(Native Method)
           at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
           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:585)
           at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:181)
           at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:163)
           at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:339)
           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:269)
           at java.util.concurrent.FutureTask.run(FutureTask.java:123)
           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:585)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:111)
           at org.jboss.weld.conversation.ServletConversationManager_$$_javassist_1.cleanupConversation(ServletConversationManager_$$_javassist_1.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:179)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:103)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
           at java.lang.Thread.run(Thread.java:595)



      Debugging with Eclipse, I noticed that when the ServletConversationManager tries to get the beanStore for a conversation, it makes a call to httpSession.get(), trying to create a proxy for the session. Digging further, the ProxyFactory ends up resolving the classLoader to an instance of org.apache.catalina.loader.StandardClassLoader (which, clearly, doesn't know the javassist lib).


      Now I wonder if I misread something or I'm doing something really stupid. While debugging I changed the loader to the Thread.currentThread().getContextClassLoader() and things worked quite nicely.


      Is this a bug or am I doing something wrong in my app configuration?


      Thanks for your attention (for quite a long running topic :D)