3 Replies Latest reply on Jan 15, 2006 9:36 AM by bill.burke

    !! Cannot lookup ejb local interface !!

      Hi guys,
      I'm not experienced ejb3 programmer, sorry in case i ask for sth really obvious ;-)

      I did very simple example which is following:

      -- server-side --
      @Stateless
      @Local(TestLocal.class)
      @Remote(TestRemote.class)
      public class TestBean implements TestLocal, TestRemote {

      public String getName() {
      return "TestBean";
      }
      }

      public interface TestLocal {
      public String getName();
      }

      [the same]
      public interface TestRemote {
      public String getName();
      }


      -- client-side --
      ...
      InitialContext ctx;
      try {
      ctx = new InitialContext();
      TestLocal test = (TestLocal) ctx.lookup(TestLocal.class.getName());
      System.out.println("Result="+test.getName());
      } catch (Exception e) {
      e.printStackTrace();
      }
      ...


      My jndi.properties are ok. I connect to my local jboss 4.0.3 with ejb3.
      The 'lookup' operation for LOCAL INTERFACE (i need local, not remote) fails with following exception:


      java.lang.RuntimeException: javax.naming.NameNotFoundException: containers not bound
      at org.jboss.ejb3.LocalProxy.readObject(LocalProxy.java:54)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      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 java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at pl.avantis.test.EJBTester.testEJB(EJBTester.java:27)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:294)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:341)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:460)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:61)
      at org.testng.TestRunner.privateRun(TestRunner.java:565)
      at org.testng.TestRunner.run(TestRunner.java:463)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:191)
      at org.testng.SuiteRunner.run(SuiteRunner.java:117)
      at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:99)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:138)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      ....
      ....
      ....


      Otherwise, when i lookup for REMOTE interface everything goes fine.


      Please help me, what did i miss?

      regards,
      janmat1@wp.pl