1 Reply Latest reply: Feb 21, 2012 5:57 AM by Dejan Kitic RSS

    Cannot connect to Remote EJB deployed to 7.1 instance, from another 7.1 instance

    Jason Shepherd Newbie

      Got the following error [1] trying connect from client JBoss AS7.1 instance:

       

      I followed this tutorial: https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance

       

      I know the EJB is deployed on my server side, because I can see this in the server side logs:

       

      16:35:38,290 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named GreeterBean in deployment unit subdeployment "myejb.jar" of deployment "myapp.ear" are as follows: 
      
              java:global/myapp/myejb/GreeterBean!org.myapp.ejb.Greeter 
              java:app/myejb/GreeterBean!org.myapp.ejb.Greeter 
              java:module/GreeterBean!org.myapp.ejb.Greeter 
              java:jboss/exported/myapp/myejb/GreeterBean!org.myapp.ejb.Greeter 
              java:global/myapp/myejb/GreeterBean 
              java:app/myejb/GreeterBean 
              java:module/GreeterBean 
      

       

      Also the server in it's default configuration had security enabled for the EJB connector, which I disabled by editing standalone-full.xml like this:

       

      From:

       

      <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/> 
      

       

      To:

       

      <connector name="remoting-connector" socket-binding="remoting"/> 
      

       

      Here is my client side code, [2].

       

      I have also attached all my project files, and the standalone-full.xml from the client, showing the remote binding configuration.

       

      Environment

      JBoss AS 7.1, Client and Server

      Mac OS VM 1.6

      EJB 3.1

       

      Thanks,

      Jason

       

      [1]

      16:51:14,889 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/EJBCaller].[EJBClient]] (http--127.0.0.1-8180-1) Servlet.service() for servlet EJBClient threw exception: java.lang.RuntimeException: java.lang.IllegalArgumentException: Could not find module app: myapp module: myejb distinct name: 
          at net.jasonshepherd.example.EJBClient.doGet(EJBClient.java:66) [classes:] 
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final] 
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final] 
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:] 
          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final] 
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:] 
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:] 
          at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_29] 
      Caused by: java.lang.IllegalArgumentException: Could not find module app: myapp module: myejb distinct name: 
          at org.jboss.as.ejb3.remote.LocalEjbReceiver.findBean(LocalEjbReceiver.java:274) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] 
          at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:109) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] 
          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:173) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:92) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final] 
          at $Proxy13.greet(Unknown Source)    at net.jasonshepherd.example.EJBClient.doGet(EJBClient.java:61) [classes:] 
          ... 15 more 
      

      [2]

      package net.jasonshepherd.example; 
      
      import java.io.IOException; 
      import java.util.Hashtable; 
      
      import javax.naming.Context; 
      import javax.naming.InitialContext; 
      import javax.naming.NamingException; 
      import javax.servlet.ServletException; 
      import javax.servlet.http.HttpServlet; 
      import javax.servlet.http.HttpServletRequest; 
      import javax.servlet.http.HttpServletResponse; 
      
      import org.myapp.ejb.Greeter; 
      
      /** 
       * Servlet implementation class EJBClient 
       */ 
      public class EJBClient extends HttpServlet { 
          private static final long serialVersionUID = 1L; 
      
          /** 
           * @see HttpServlet#HttpServlet() 
           */ 
          public EJBClient() { 
              super(); 
              // TODO Auto-generated constructor stub 
          } 
      
          /** 
           * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 
           */ 
          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
              /*JBoss AS 5 
              final String jndiName = "myapp/Greeter/remote"; 
              Object obj = null; 
              try { 
                  Context ic = new InitialContext(); 
                  obj = ic.lookup(jndiName); 
              } catch (NamingException e) { 
                  throw new IllegalStateException("Could not lookup EJB", e); 
              } 
              GreeterRemote greeter = (GreeterRemote) obj; 
              String result = greeter.toString() + "returned: " + greeter.greet("Jason"); 
              response.getWriter().append(result);*/ 
              try { 
                  final Hashtable props = new Hashtable(); 
                  // setup the ejb: namespace URL factory 
                  props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); 
                  // create the InitialContext 
                  final Context context = new javax.naming.InitialContext(props); 
      
                  // Lookup the Greeter bean using the ejb: namespace syntax which is explained here https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI 
                  String jndiName = "ejb:" + "myapp" + "/" + "myejb" + "/" + "" + "/" + "GreeterBean" + "!" + org.myapp.ejb.Greeter.class.getName(); 
      
                  System.out.println("Looking for ejb with jndiName: " + jndiName); 
      
                  final Greeter bean = (Greeter) context.lookup(jndiName); 
      
                  // invoke on the bean 
                  final String greeting = bean.greet("Tom"); 
      
                  response.getWriter().append("Received greeting: " + greeting); 
      
              } catch (Exception e) { 
                  throw new RuntimeException(e); 
              } 
          } 
      
      }