1 Reply Latest reply on Nov 10, 2008 7:50 AM by sandello

    lookup EJB3-beans on JBoss from Eclipse RAP

    sandello

      I have a project consists two parts: RAP-based web UI part and
      EJB3-server part. Second path consists 23 EJB3-application. All works
      fine. The UI-part successfully interact with server-part.

      Now I need to add some functionality which interact with other ejb3
      application on the same server. I create a simple action:

      new Action(){
       @Override
       public void run() {
       Logger debugger = Logger.getLogger(this.getClass()); //Log4j logger
       String DEBUG_STR = "run: ";
       debugger.debug(DEBUG_STR + "start");
       debugger.debug(DEBUG_STR + "security manager " +
      System.getSecurityManager());
       Class<?> forName;
       try {
       forName =
      Class.forName("com.company.docprint.as.mngrs.DocTypeManager");
       debugger.debug(DEBUG_STR + forName);
       forName =
      Class.forName("com.company.docprint.as.mngrs.DocTypeManagerBean");
       debugger.debug(DEBUG_STR + forName);
       forName = Class.forName("org.jboss.ejb3.JBossProxy");
       debugger.debug(DEBUG_STR + forName);
       forName = Class.forName("javax.ejb.EJBObject");
       debugger.debug(DEBUG_STR + forName);
       forName = Class.forName("javax.ejb.EJBAccessException");
       debugger.debug(DEBUG_STR + forName);
      
       Properties props = new Properties();
       props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
       props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
       props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      
       Context ctx = new InitialContext(props);
       Context c0 = (Context) ctx.lookup("DocManagerBean/remote"); //throws exception
       // Context c0 = (Context) ctx.lookup("AbonentServer/remote"); // works fine
       }
       catch (Exception e) {
       debugger.debug(DEBUG_STR + e, e);
      
       }
       debugger.debug(DEBUG_STR + "stop");
       }
      
      }
      
      

      A exception occurs when I try to run this code fragment from
      RAP-application.
      If I change

      Context c0 = (Context) ctx.lookup("DocManagerBean/remote");
      

      to
      Context c0 = (Context) ctx.lookup("AbonentServer/remote");
      

      all works fine. The "AbonentServer" is the EJB3 from old server-part.
      If I run the code fragment from JUnit test case - all works fine.

      Exception:
      javax.naming.CommunicationException [Root exception is
      java.lang.ClassNotFoundException:
      com.company.docprint.as.mngrs.DocManager (no security manager: RMI class
      loader disabled)]
      javax.naming.CommunicationException [Root exception is
      java.lang.ClassNotFoundException:
      com.company.docprint.as.mngrs.DocManager (no security manager: RMI class
      loader disabled)]
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:730)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
       at
      com.company.project.ui.abonent.AbonentListView$4.run(AbonentListView.java:118)
       at org.eclipse.jface.action.Action.runWithEvent(Action.java:500)
       at
      org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580)
       at
      org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:497)
       at
      org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:449)
       at
      org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatchEvent(UntypedEventAdapter.java:313)
       at
      org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetSelected(UntypedEventAdapter.java:80)
       at
      org.eclipse.swt.events.SelectionEvent.dispatchToObserver(SelectionEvent.java:174)
       at org.eclipse.rwt.internal.events.Event.processEvent(Event.java:44)
       at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.java:115)
       at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.java:155)
       at
      org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.readAndDispatch(RWTLifeCycle.java:241)
       at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:682)
       at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2388)
       at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2347)
       at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2200)
       at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:425)
       at
      org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
       at
      org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:408)
       at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
       at com.company.project.ui.rap.Application.createUI(Application.java:15)
       at
      org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:92)
       at
      org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:228)
       at
      org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:116)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ClassNotFoundException:
      com.company.docprint.as.mngrs.DocManager (no security manager: RMI class
      loader disabled)
       at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:531)
       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:1500)
       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1463)
       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 java.rmi.MarshalledObject.get(MarshalledObject.java:135)
       at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:654)
       ... 26 more
      


      Environment:
      Eclipse 3.4.1
      RAP 1.2M2
      Jboss 4.2.1
      OS Fedora Linux 8 x86_64
      Java 1.5.0_14 x86_64

      Where is the problem? Why I can connect to one EJB but can't to other?