1 2 Previous Next 15 Replies Latest reply on May 28, 2009 10:57 AM by enriqueam

    Serializable no remote classloading

      I try to return an Interface of a serializable Object and simply access a getter but all I get is a ClassNotFoundException:

      on JBoss 4.2.2.GA

      java.lang.reflect.UndeclaredThrowableException
       at $Proxy0.findRessource(Unknown Source)
       at org.test.EJBTester.main(EJBTester.java:39)
      Caused by: java.lang.ClassNotFoundException: org.test.RessourceImpl
       at org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:82)
       at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:76)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:242)
       at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:174)
       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
       at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:122)
       at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1755)
       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1717)
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
       at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
       at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
       at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:239)
       at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:133)
       at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:120)
       at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:957)
       at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:586)
       at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
       at org.jboss.remoting.Client.invoke(Client.java:1634)
       at org.jboss.remoting.Client.invoke(Client.java:548)
      


      files:

      public interface Ressource
      {
       public void setId(Long id);
       public Long getId();
      }
      
      public class RessourceImpl implements Ressource, Serializable
      {
       private Long id;
      
       public Long getId() {
       return this.id;
       }
       public void setId(Long id) {
       this.id = id;
       }
      }
      
      @Stateless
      @Remote(value=RessourceBean.class)
      public class RessourceBeanImpl implements RessourceBean, Serializable
      {
       public Ressource findRessource(Long id) {
      // simplified
       Ressource res = new RessourceImpl();
       res.setId(1L);
       return res;
       }
      }
      @Remote
      public interface RessourceBean
      {
       Ressource findRessource(Long id);
      }
      
      


      the test:
      public class EJBTester
      {
       public static void main(String[] args)
       {
       RessourceBean res = null;
       try
       {
       Properties props = new Properties();
       props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
       props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
       //
       props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
       //props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
       //props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
       System.setProperty("java.security.policy", "client.policy");
       System.setSecurityManager(new RMISecurityManager());
       InitialContext ctx = new InitialContext( props );
       //res = (RessourceBean) ctx.lookup("org.test.ejb.RessourceBean");
       res = (RessourceBean) ctx.lookup("TestEJB/RessourceBeanImpl/remote");
       if (null != res)
       {
       Ressource r = res.findRessource(null);
       if (null != r)
       {
       System.out.println("id = " + r.getId());
       }
       }
       }
       catch (Exception e)
       {
       e.printStackTrace();
       }
       }
      
      }


      On the client I only added the interfaces and retrieve successfully the SSB .. And the funny thing is as you might have noticed on glassfish it works without any problems it fetches the (ressource)implemenation via RMIClassloader ;)

      Any hints/suggestions?

        • 1. Re: Serializable no remote classloading

          Sry forgot to mention that this worked with any 4.0.X Version before

          • 2. Re: Serializable no remote classloading
            dimitris

            Have you setup a security policy on the client side to allow the remote downloading of classes?

            • 3. Re: Serializable no remote classloading

              I set an AllPermission policy tried it as well VM Parameter and also in the code(see client.policy). Could this be due to the ClassLoader redesign?

              Tried it on JBoss 5 Beta 3 too without luck. So something must have happened between 4.0.X --> 4.2

              grant {
              permission java.security.AllPermission;
              };
              

              (Yes I know not very secure)

              • 4. Re: Serializable no remote classloading
                dimitris

                The other thing to try is using an old-style EJB2 bean, to see if this is a problem with EJB3 only...

                • 5. Re: Serializable no remote classloading

                  Well I give it a try and let you know the results.

                  • 6. Re: Serializable no remote classloading

                    Well seems you're with EJB 2 style I got it working, so will it be fixed for EJB3?

                    • 7. Re: Serializable no remote classloading
                      dimitris

                      Can you please post on the EJB3 User forum? Seems like an EJB3 bug.

                      • 8. Re: Serializable no remote classloading
                        ron_sigal

                        The default behavior in AS 4.0.X was to use a "legacy" remote invoker, and the default in AS 4.2 is to use a Remoting invoker. For a Remoting invoker, the ability to download classes over the network has to be enabled explicitly. For EJB3 the configuration file is .../server/default/deploy/ejb3.deployer/META-INF/jboss-service.xml (substitute your configuration for "default"), and the relevant entry is

                         <mbean code="org.jboss.remoting.transport.Connector"
                         name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
                         <depends>jboss.aop:service=AspectDeployer</depends>
                         <attribute name="InvokerLocator">socket://${jboss.bind.address}:3873</attribute>
                         <attribute name="Configuration">
                         <handlers>
                         <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
                         </handlers>
                         </attribute>
                         </mbean>
                        


                        If you add a "loaderport" parameter to the InvokerLocator, Remoting will create a "classloader server" which, if a class cannot be found on the client side, will be contacted by the client side classloader. E.g.,

                         <mbean code="org.jboss.remoting.transport.Connector"
                         name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
                         <depends>jboss.aop:service=AspectDeployer</depends>
                         <attribute name="InvokerLocator">socket://${jboss.bind.address}:3873/?loaderport=4873</attribute>
                         <attribute name="Configuration">
                         <handlers>
                         <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
                         </handlers>
                         </attribute>
                         </mbean>
                        


                        will create a classloader server that listens on port ${jboss.bind.address}:4873.

                        For more discussion see Section "5.5. Marshalling" of the Remoting Guide (http://labs.jboss.com/jbossremoting/docs/guide/index.html).

                        • 9. Re: Serializable no remote classloading

                          Great thanks a lot ... it works but 1 (small) issue left.

                          If I do scoped classloading with a jboss-app.xml like:

                          <jboss-app>
                           <loader-repository>
                           org.test:archive=TestEJB.ear
                           </loader-repository>
                          </jboss-app>


                          it won't work (of course?) ... any possibility to get it working?


                          • 10. Re: Serializable no remote classloading
                            dimitris

                            Ron, and yet another question is could this be made to work with the existing classloading service at port 8083?

                            More so that fixes/features to the classloading service go into one place.

                            The one in remoting is it a fork of the old one (or even a different instance of it) ?

                            • 11. Re: Serializable no remote classloading
                              avogt_sundn

                              Is there a solution for scoped class loaders? Is it really the problem?
                              The configuration is not working for me, I wonder wether that is because of the scoped class loaders i am using for each ear (EJBs calling each other across ear boundaries).

                              • 12. Re: Serializable no remote classloading
                                ron_sigal

                                I've fixed this issue for the Remoting 2.2.2.SP8 release. For more information, see Remoting users forum thread "ClassNotFoundException while calling remote ejb3 across isol" at http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4159759#4159759.

                                • 13. Re: Serializable no remote classloading
                                  avogt_sundn
                                  • 14. Re: Serializable no remote classloading
                                    ron_sigal

                                     

                                    "dimitris@jboss.org" wrote:

                                    Ron, and yet another question is could this be made to work with the existing classloading service at port 8083?

                                    More so that fixes/features to the classloading service go into one place.


                                    Dimitris, I was looking at a parallel thread on the Remoting users forum when I was working on this issue, and I forgot about your question. I don't know about the JBossAS RMI classloading facility, but Remoting uses a special Remoting Connector, so it might have an independent origin.

                                    In any case, I started a "Remoting and remote classloading" thread on the "Design of JBoss Remoting, Unified Invokers" forum (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=138067) so that we keep the question in mind in Remoting 3.

                                    -Ron

                                    1 2 Previous Next