2 Replies Latest reply on Sep 8, 2009 5:07 AM by Jacek Gorwa

    Classloader problem in Wicket RequestCycle class in Seam 2.1.2

    Jacek Gorwa Newbie

      Using Seam 2.1 and Wicket on Glassfish 2.1 we were able to create our own request cycle class.
      After switching to Seam 2.1.2 the same code packaged in the same ear file encountered
      a ClassNotFound exception which indicates issues with classloaders. The exception does not
      tell us the class it cannot find. The problem also occurs in the latest Seam 2.2.0 GA release.


      Question: did Seam 2.1.2 introduce any changes to classloaders that could explain this problem?


      Here is the relevant code we use:


      import org.apache.wicket.Request;
      import org.apache.wicket.RequestCycle;
      import org.apache.wicket.Response;
      import org.apache.wicket.protocol.http.WebRequest;
      
       
      public class MyApplication extends SeamWebApplication {
      
      ...
      
       //--------------------------- Support for new request cycle ----------------
          /**
          * Factory method for creating a new request cycle
          */
          @Override
          public RequestCycle newRequestCycle(Request request, Response response)
          {
      
                 return new MyRequestCycle(this, (WebRequest)request, response);
          }
      }






      Our ear file for deployment to Glassfish 2.1 is packaged as follows:


      my-app.ear
           jboss-seam.jar
           my-app.jar
                \META-INF
                     ejb-jar.xml
                     orm.xml
                     persistence.xml
                \com\myapp\action (server side classes)
           
           my-app.war
                \css
                \img
                \WEB-INF
                     components.xml
                     web.xml
                     \classes\ ... (application specific classes for web-tier)
                          MyRequestCycle.class  (--> suspect class resides here)
                     \lib     (jboss-seam-wicket jar files)
           \lib
                
           \META-INF
                application.xml
      
      



        • 2. Re: Classloader problem in Wicket RequestCycle class in Seam 2.1.2
          Jacek Gorwa Newbie

          Using the try/catch block shown above I trapped the exception and printed the stack trace as shown below.


           /**
              * Factory method for creating a new request cycle
              */
              @Override
              public RequestCycle newRequestCycle(Request request, Response response)
              {
          
                  try {
                      return new MyRequestCycle(this, (WebRequest)request, response);
                  }
                  catch(Throwable e)
                  {
                      e.printStackTrace();
                      return super.newRequestCycle(request, response);
                  }
              }
          



          StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default threw exception
          java.lang.NullPointerException
                  at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:356)
                  at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:201)
                  at org.jboss.seam.web.WicketFilter.doFilter(WicketFilter.java:132)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
                  at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
                  at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
                  at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
                  at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
                  at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
                  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
                  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
                  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
                  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
                  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
                  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
                  at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
                  at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
                  at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
          java.lang.NoClassDefFoundError: Could not initialize class com.carbonicity.graphite.web.MyRequestCycle
                  at com.carbonicity.graphite.web.MyApplication.newRequestCycle100(MyApplication.java:83)
                  at com.carbonicity.graphite.web.MyApplication.newRequestCycle(MyApplication.java)
                  at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:351)
                  at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:201)
                  at org.jboss.seam.web.WicketFilter.doFilter(WicketFilter.java:132)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
                  at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
                  at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
                  at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
                  at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
                  at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
                  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
                  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
                  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
                  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
                  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
                  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
                  at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
                  at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
                  at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
          



          MyRequestCycle and MyApplication classes reside in the same package. Additionally, I discovered that can load successfully the class MyRequestCycle using explicit call to the class loader, but the invocation of the constructor new MyRequestCycle(this, (WebRequest)request, response) is causing an error


          getClass().getClassLoader().loadClass("com.carbonicity.graphite.web.MyRequestCycle")