1 Reply Latest reply on Aug 4, 2011 5:06 PM by pumuggel

    Calling an EJB method in jboss server from another server(Servlet)

    vairam_sm

      Hi,

       

      I'm having war in one jboss server and ejb jar in another jboss server. I want to call my ejb from my servlet which is present in another server. How to call it. can any one help me with a working sample and required configurations.

       

      kindly help me for the below issue..

       

      Thanks in advance

       

      I tried with below sample, it throws exception

       

      Hashtable environment = new Hashtable();

                  environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

                  environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

                  environment.put(Context.PROVIDER_URL, "jnp://192.168.10.67:1099"); // remote machine IP

                  InitialContext context = new InitialContext(environment);

                  Object lookup = context.lookup("ejbMyTest"); //ejb-name

                  System.out.println("-->> lookup object successfully");

                  System.out.println("=====>>" + lookup);

       

      12:46:11,281 ERROR [STDERR] javax.naming.CommunicationException [Root exception

      is java.lang.ClassNotFoundException: mytest.ejbMyTestRemoteHome (no security man

      ager: RMI class loader disabled)]

      12:46:11,282 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.lookup(Namin

      gContext.java:786)

      12:46:11,283 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.lookup(Namin

      gContext.java:627)

      12:46:11,283 ERROR [STDERR]     at javax.naming.InitialContext.lookup(InitialCon

      text.java:392)

      12:46:11,283 ERROR [STDERR]     at vq.event.EventSLT.processRequest(EventSLT.jav

      a:66)

      12:46:11,283 ERROR [STDERR]     at vq.event.EventSLT.doGet(EventSLT.java:94)

      12:46:11,284 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpSe

      rvlet.java:690)

      12:46:11,284 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpSe

      rvlet.java:803)

      12:46:11,284 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterCha

      in.internalDoFilter(ApplicationFilterChain.java:290)

      12:46:11,284 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterCha

      in.doFilter(ApplicationFilterChain.java:206)

      12:46:11,285 ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilte

      r.doFilter(ReplyHeaderFilter.java:96)

      12:46:11,285 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterCha

      in.internalDoFilter(ApplicationFilterChain.java:235)

      12:46:11,285 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterCha

      in.doFilter(ApplicationFilterChain.java:206)

      12:46:11,285 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve

      .invoke(StandardWrapperValve.java:230)

      12:46:11,286 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve

      .invoke(StandardContextValve.java:175)

      12:46:11,286 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssocia

      tionValve.invoke(SecurityAssociationValve.java:179)

      12:46:11,286 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValv

      e.invoke(JaccContextValve.java:84)

      12:46:11,286 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.in

      voke(StandardHostValve.java:127)

      12:46:11,287 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.i

      nvoke(ErrorReportValve.java:102)

      12:46:11,287 ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnec

      tionValve.invoke(CachedConnectionValve.java:157)

      12:46:11,287 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.

      invoke(StandardEngineValve.java:109)

      12:46:11,288 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.s

      ervice(CoyoteAdapter.java:262)

      12:46:11,288 ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.proc

      ess(Http11Processor.java:844)

      12:46:11,288 ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http1

      1ConnectionHandler.process(Http11Protocol.java:583)

      12:46:11,288 ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker

      .run(JIoEndpoint.java:446)

      12:46:11,289 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:619)

      12:46:11,289 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: mytest.

      ejbMyTestRemoteHome (no security manager: RMI class loader disabled)

      12:46:11,289 ERROR [STDERR]     at sun.rmi.server.LoaderHandler.loadProxyClass(L

      oaderHandler.java:535)

      12:46:11,289 ERROR [STDERR]     at java.rmi.server.RMIClassLoader$2.loadProxyCla

      ss(RMIClassLoader.java:628)

      12:46:11,290 ERROR [STDERR]     at org.jboss.system.JBossRMIClassLoader.loadProx

      yClass(JBossRMIClassLoader.java:82)

      12:46:11,290 ERROR [STDERR]     at java.rmi.server.RMIClassLoader.loadProxyClass

      (RMIClassLoader.java:294)

      12:46:11,290 ERROR [STDERR]     at sun.rmi.server.MarshalInputStream.resolveProx

      yClass(MarshalInputStream.java:238)

      12:46:11,291 ERROR [STDERR]     at java.io.ObjectInputStream.readProxyDesc(Objec

      tInputStream.java:1531)

      12:46:11,291 ERROR [STDERR]     at java.io.ObjectInputStream.readClassDesc(Objec

      tInputStream.java:1493)

      12:46:11,291 ERROR [STDERR]     at java.io.ObjectInputStream.readOrdinaryObject(

      ObjectInputStream.java:1732)

      12:46:11,291 ERROR [STDERR]     at java.io.ObjectInputStream.readObject0(ObjectI

      nputStream.java:1329)

      12:46:11,292 ERROR [STDERR]     at java.io.ObjectInputStream.readObject(ObjectIn

      putStream.java:351)

      12:46:11,292 ERROR [STDERR]     at java.rmi.MarshalledObject.get(MarshalledObjec

      t.java:142)

      12:46:11,292 ERROR [STDERR]     at org.jnp.interfaces.MarshalledValuePair.get(Ma

      rshalledValuePair.java:72)

      12:46:11,292 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.lookup(Namin

      gContext.java:710)

      12:46:11,293 ERROR [STDERR]     ... 24 more

        • 1. Re: Calling an EJB method in jboss server from another server(Servlet)
          pumuggel

          Hi there,

           

          this happens due to a missing SecurityManager. RMI will not load the class from your server with your ear installed until you have set a SecurityManager on your JVM on the second server.

           

          But I have no idea how to configure that. In standalone appliction you will typically set the SecurityManager on your own by:

           

          <code>

          System.setSecurityManager(new SecurityManager());

          </code>

           

          As far as I know there is also a configuration file somewhere in your JVM directory named "java.policy". There you can configure a default behaviour as well.

           

          Hope this will help you.

           

          Regards

          Christoph