8 Replies Latest reply on Dec 28, 2005 4:57 PM by Aditya Poosarla

    ClassNotFoundException when using resin, jboss and EJB3

    Aditya Poosarla Newbie

      Hi,

      I am having a application where I need to use resin-3.0.14 as a web server and jboss4.0.3SP1 as the application server.
      I am using stateless session bean's in EJB3. When I call a remote method on the EJB from the servlet I get the following exception in the servlet.
      I have deployed the same application on tomcat it works fine.

      java.lang.ClassNotFoundException: com.rewards.model.Category
       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:242)
       at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:574)
       at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:102)
       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1538)
       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
       at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
       at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
       at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
       at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
       at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:73)
       at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:242)
       at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:112)
       at org.jboss.remoting.Client.invoke(Client.java:226)
       at org.jboss.remoting.Client.invoke(Client.java:189)
       at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:41)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
       at $Proxy0.remoteCategory(Unknown Source)
       at com.rewards.RewardsServlet.doPost(RewardsServlet.java:66)
       at com.rewards.RewardsServlet.doGet(RewardsServlet.java:51)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99)
       at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)
       at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)
       at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:259)
       at com.caucho.server.port.TcpConnection.run(TcpConnection.java:363)
       at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490)
       at com.caucho.util.ThreadPool.run(ThreadPool.java:423)
       at java.lang.Thread.run(Thread.java:595)



      I have two methods in my Session bean. One returns a string and the other returns a object of type category which has two simple fields, name and description.
      The object is serializable and implements the serializable interface.
      The method which returns a string works fine. It gives the correct output.

      I am placing snippets of my session bean and servlet here.

      RewardsServlet

      protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
      {
       Context ctx = new InitialContext();
       rewardsEJB = (RewardsEJB)ctx.lookup(RewardsEJB.class.getName());
       String test = rewardsEJB.remoteMethod();
       System.out.println("Test is : " + test);
       Category category = rewardsEJB.remoteCategory();
       System.out.println("Name is : " + category.getName());
      }


      RewardsEJB

      public String remoteMethod() {
       return "Returned String from the remote method";
      }
      
      public Category remoteCategory() {
       Category category = new Category();
       category.setName("Remote Test");
       category.setDescription("Remote Description");
       return category;
      }
      

      Can anyone help me out with this problem. Does it have to do anything with ejb3?

      Thanks in advance,
      Aditya.P

        • 1. Re: ClassNotFoundException when using resin, jboss and EJB3
          William DeCoste Apprentice

          The client side proxy for the RewardsEJB is trying to unmarshall the Category object returned from the server side. This has to be a classpath issue. Can you please describe your classpath settings for your webserver?

          • 3. Re: ClassNotFoundException when using resin, jboss and EJB3
            Aditya Poosarla Newbie

            I have included the following in my web-app tag of resin as suggested. The classpath tag given in the example does is I believe in the older version of resin. I tried to add the same but it gave me a dtd error. So I changed and have included the following.

            <web-app id='/' document-directory='C:\projects\testresin'>
             <class-loader>
             <compiling-loader path="WEB-INF/classes"/>
             <library-loader path="WEB-INF/lib"/>
             </class-loader>
            
             <jndi-link>
             <jndi-name>java:comp/env</jndi-name>
             <factory>org.jnp.interfaces.NamingContextFactory</factory>
             <init-param java.naming.provider.url="localhost:1099"/>
             </jndi-link>
             </web-app>


            In my web-inf/lib I have all the classes mentioned in the document except user.jar which I could not find and also instead of the ejb.jar I have ejb-management.jar and ejb-persistence.jar.

            Thanks in advance.

            • 4. Re: ClassNotFoundException when using resin, jboss and EJB3
              Bill Burke Master

              Try this patch. There is a classloader bug with JBoss Remoting:

              http://jira.jboss.com/jira/browse/JBREM-260

              Let me know if that fixes it.

              • 5. Re: ClassNotFoundException when using resin, jboss and EJB3
                Aditya Poosarla Newbie

                It works fine now after I have replaced the existing jboss-remoting.jar with the one from the patch.

                Thanks

                • 6. Re: ClassNotFoundException when using resin, jboss and EJB3
                  Aditya Poosarla Newbie

                  It now runs fine if I call the remote method from a servlet. If I call the remote method from a spring controller I get the following exception:

                  java.io.InvalidClassException: javax.ejb.EJBException; local class incompatible:
                  stream classdesc serialVersionUID = 796770993296843510, local class serialVersionUID
                  = -5182684592159555248
                   at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
                   at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
                   at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
                   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
                   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
                   at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
                   at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
                   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
                   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
                   at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
                   at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:73)
                   at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:242)
                   at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:117)
                   at org.jboss.remoting.Client.invoke(Client.java:226)
                   at org.jboss.remoting.Client.invoke(Client.java:189)
                   at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
                   at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
                   at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
                   at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:41)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
                   at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
                   at $Proxy0.findAllCategories(Unknown Source)
                   at com.rewardtv.rewards.controller.CreateCategoryController.onSubmit(CreateCategoryController.java:48)
                   at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:258)
                   at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:256)
                   at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:139)
                   at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
                   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
                   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
                   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
                   at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:357)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                   at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99)
                   at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)
                   at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)
                   at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:259)
                   at com.caucho.server.port.TcpConnection.run(TcpConnection.java:363)
                   at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490)
                   at com.caucho.util.ThreadPool.run(ThreadPool.java:423)
                   at java.lang.Thread.run(Thread.java:595)



                  Thanks again

                  • 7. Re: ClassNotFoundException when using resin, jboss and EJB3
                    Bill Burke Master

                    that looks like your problem. Could be that you have different versions of your app or EJB3 or whatever deployed.

                    • 8. Re: ClassNotFoundException when using resin, jboss and EJB3
                      Aditya Poosarla Newbie

                      Thank you. It is my problem. One of the classes I has is an olderversion.

                      Thanks again,
                      Aditya.P