0 Replies Latest reply on Dec 22, 2005 12:01 PM by Aditya Poosarla

    Servlet throws a exception when returning from a remote meth

    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.

      Thanks in advance,
      Aditya.P