0 Replies Latest reply on Aug 19, 2008 6:33 AM by v a

    RMI dynamic class loading

    v a Newbie

      Does dynamic class loading really work in JBoss 4.2.2?
      On server I have a bean:

      Bean.java

      @Stateless
      public class Bean implements BeanRemote
      {
       public void callMe()
       {
       }
      }
      


      BeanRemote.java
      @Remote
      public interface BeanRemote
      {
       public void callMe();
      }
      


      Then I connect to server via RMI:

      Client.java
      public class Client
      {
       public static void main(String[] args)
       {
       if (System.getSecurityManager() == null)
       {
       System.setSecurityManager(new RMISecurityManager());
       }
      
       Properties jndiProps = new Properties();
       jndiProps.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
       jndiProps.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       jndiProps.put("java.naming.provider.url", "jnp://localhost/app");
      
       InitialContext ic = new InitialContext(jndiProps);
       Object bean = ic.lookup("Bean/remote");
      
       System.out.println("bean = " + bean);
       }
      }
      


      Exception occurs in the line with lookup:
      Exception in thread "main" javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.test.BeanRemote]
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:786)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.test.Client.main(Client.java:53)
      Caused by: java.lang.ClassNotFoundException: org.test.BeanRemote
       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 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 sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:707)
       at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:651)
       at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:588)
       at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
       at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
       at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
       at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1494)
       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1457)
       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 java.rmi.MarshalledObject.get(MarshalledObject.java:135)
       at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
       ... 4 more
      


      I also tried setting java.rmi.server.codebase property on client to 'http://localhost:8083' but it didn't help. Webserver on 8083 port seems not to see my bean. I can get class for example for org.jboss.web.WebServer using url 'http://localhost:8083/org.jboss.web.WebServer' but 'http://localhost:8083/org.test.BeanRemote' returns blank page.