0 Replies Latest reply on Sep 3, 2010 1:11 AM by v a

    Remote classloading and EJB3

    v a Newbie

      I'm facing with remote classloading and EJB3. I have a simple EJB:

      @Remote

      public interface ITest {

          public void test();

      }

       

      @Stateless

      public class Test implements ITest {

          public void test() { }

      }

      Here is the client code:

      public static void main(String[] args) throws Exception {
          Properties props = new Properties();
          props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
          props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
          props.setProperty(Context.PROVIDER_URL, "jnp://localhost");

          InitialContext ctx = new InitialContext(props);
          Object test = ctx.lookup("jboss-test/Test/remote");

         System.out.println(test);
      }

      The all needed classes are successfully loaded (as I see in the logs), but I have the following exception on client:

      Exception in thread "main" javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + sun.misc.Launcher$AppClassLoader@1a16869]
          at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1508)
          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:824)
          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
          at javax.naming.InitialContext.lookup(InitialContext.java:392)
          at org.test.jboss.client.Client.main(Client.java:20)
      Caused by: java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + sun.misc.Launcher$AppClassLoader@1a16869
          at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:410)
          at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:134)
          at org.jboss.ejb3.proxy.impl.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
          at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:161)
          at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
          at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1483)
          at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1500)
          ... 4 more
      Caused by: java.lang.ClassNotFoundException: org.test.ejb.ITest
          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:247)
          at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:406)
          ... 10 more