4 Replies Latest reply on Oct 5, 2015 5:45 AM by Peter Jaxy

    Whe I don't get remote access on my ejb?I

    Peter Jaxy Newbie

      I get this error message, if my client app try to communicate with my server app:

       

      Okt 01, 2015 3:06:02 PM org.xnio.Xnio <clinit>

      INFO: XNIO Version 3.0.13.GA-redhat-1

      Okt 01, 2015 3:06:03 PM org.xnio.nio.NioXnio <clinit>

      INFO: XNIO NIO Implementation Version 3.0.13.GA-redhat-1

      Okt 01, 2015 3:06:03 PM org.jboss.remoting3.EndpointImpl <clinit>

      INFO: JBoss Remoting version 3.3.4.Final-redhat-1

      Okt 01, 2015 3:06:04 PM org.jboss.ejb.client.EJBClient <clinit>

      INFO: JBoss EJB Client version 1.0.30.Final-redhat-1

      Exception in thread "main" java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:HelloBean, moduleName:HelloBean-ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@363ee3a2

        at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:747)

        at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)

        at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)

        at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)

        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)

        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)

        at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)

        at com.sun.proxy.$Proxy2.hello(Unknown Source)

        at examples.session.stateless.HelloClient.main(HelloClient.java:58)

      Java Result: 1

       

      I created a simple ejb "HelloBean.ear" with the following two files:

      1. Hello.java (The interface)
      2. HelloBean.java (implements my Interface)

       

      The content of Hello.java is:

       

      package examples.session.stateless;
      
      public interface Hello {
          public String hello();
      }
      

       

      The content of HelloBean.java is:

       

      package examples.session.stateless;
      
      import javax.ejb.Stateless;
      import javax.ejb.Remote;
      
      @Stateless
      @Remote(Hello.class)
      public class HelloBean implements Hello{
          @Override
          public String hello(){
              String result;
              result = "Hallo!";
              return result;
          }
      }
      

       

      I successfully deployed my ejb on the jboss server. This is the output of the server's log file:

       

      12:54:48,334 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starte Deployment von "HelloBean.ear" (runtime-name: "HelloBean.ear")

      12:54:48,376 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015973: Starte Subdeployment (runtime-name: "HelloBean-ejb.jar")

      12:54:48,384 INFO  [org.jboss.as.pojo] (MSC service thread 1-3) JBAS017000: Veralteten Bean/Pojo Namespace: urn:jboss:bean-deployer:2.0 gefunden - es k�nnen xml-Features fehlen (potenzielle Ausnahmen).

      12:54:48,403 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named HelloBean in deployment unit subdeployment "HelloBean-ejb.jar" of deployment "HelloBean.ear" are as follows:

       

       

        java:global/HelloBean/HelloBean-ejb/HelloBean!examples.session.stateless.Hello

        java:app/HelloBean-ejb/HelloBean!examples.session.stateless.Hello

        java:module/HelloBean!examples.session.stateless.Hello

        java:jboss/exported/HelloBean/HelloBean-ejb/HelloBean!examples.session.stateless.Hello

        java:global/HelloBean/HelloBean-ejb/HelloBean

        java:app/HelloBean-ejb/HelloBean

        java:module/HelloBean

       

       

      12:54:48,547 INFO  [org.jboss.as.server] (HttpManagementService-threads - 43) JBAS015859: "HelloBean.ear" deployed (runtime-name: "HelloBean.ear")

       

      Furthermore I created a client app with the following files:

      1. jboss-ejb-client.properties
      2. jndi.properties
      3. HelloClient.java

       

      The content of the "jboss-ejb-client.properties"-file is:
      
      endpoint.name=client-endpoint
      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
      
      remote.connections=default
      
      remote.connection.default.host=10.7.97.48
      remote.connection.default.port = 4447
      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      
      remote.connection.default.username=xxxxxx
      remote.connection.default.password=xxxxxx
      

       

      The content of the "jndi.properties"-file is:

       

      java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
      java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
      jboss.naming.client.ejb.context=true
      java.naming.provider.url=remote://10.7.97.48:4447
      java.naming.security.principal=xxxxxxx
      java.naming.security.credentials=xxxxxxx
      

       

      The content of the "HelloClient.java"-file is:

       

      package examples.session.stateless;
      
      
      import java.util.Hashtable;
      import java.util.Properties;
      import javax.naming.*;
      import org.jboss.ejb.client.EJBClientContext;
      import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;
      import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;
      
      public class HelloClient{     
          
          public static void main(String[] args) throws Exception{
              
              final String appName = "HelloBean";
              final String moduleName = "HelloBean-ejb";
              final String distinctName = "";
              final String beanName = HelloBean.class.getSimpleName();
      
              final String viewClassName = Hello.class.getName();
              System.out.println("Looking EJB via JNDI ");
              String ejbName = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName;
              System.out.println(ejbName);
              final Hello ejb = (Hello) InitialContext.doLookup(ejbName);
              String result = ejb.hello();
              System.out.println(result);
          }
      }
      

       

      I can ping my server with the ip 10.7.97.48.

      In my webbrowser I can see the application platform with the ip 10.7.97.48 and with the port 8081.

       

      Why my client app don't get access on my ejb?

        • 1. Re: Whe I don't get remote access on my ejb?I
          Wolf-Dieter Fink Master

          A mix of ejb-client and remote-naming approach.

           

          remote the jndi.properties and try this code

           

                  final Hashtable jndiProperties = new Hashtable();

                  jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                  final Context context = new InitialContext(jndiProperties);

          for the lookup.

          Also ensure that you added the correct user to the server environment.

          You might use this quickstart : https://github.com/jboss-developer/jboss-eap-quickstarts/tree/7.0.x-develop/ejb-remote

          • 2. Re: Whe I don't get remote access on my ejb?I
            Peter Jaxy Newbie

            I added in the HelloClient.java file:

             

            final Hashtable jndiProperties = newHashtable();
            jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
            finalContext context = newInitialContext(jndiProperties);
            

            But I get the same error message:

             

            Exception in thread "main" java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:HelloBean, moduleName:HelloBean-ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@4690b489

              at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:747)

              at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)

              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)

              at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)

              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)

              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)

              at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)

              at com.sun.proxy.$Proxy2.hello(Unknown Source)

              at examples.session.stateless.HelloClient.main(HelloClient.java:61)

            Java Result: 1

             

            Because I have a jndi.properties file with the input:

             

            java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

             

            , isn't it the same, if  define a Hashtable with the entry: Context.URL_PKG_PREFIXES, "org,jboss.ejb.client.naming"?

            • 3. Re: Whe I don't get remote access on my ejb?I
              Wolf-Dieter Fink Master

              But the jndi.properties add other configuration and you mix two different approaches. the "remote:" is not recommeneded for ejb invocation.

               

              If you run the quickstart ejb-remote you can easy start here and change it for your needs.

              • 4. Re: Whe I don't get remote access on my ejb?I
                Peter Jaxy Newbie

                I tried out the quickstart ejb-remote example.

                I created a Calculator.ear file. The structure of the file was as follows:

                 

                Calculator.ear:

                MEAT-INF --> MANIFEST.MF

                                 --> jboss-app.xml

                Calculator-ejb.jar --> META-INF --> MANIFEST.MF

                                                               --> jboss.xml

                                          --> org --> jboss --> as --> quickstarts --> ejb --> remote --> stateless --> CalculatorBean.class

                                                                                                                                                   --> RemoteCalculator.class

                 

                CalculatorBean.java:

                package org.jboss.as.quickstarts.ejb.remote.stateless;
                
                import javax.ejb.Remote;
                import javax.ejb.Stateless;
                
                @Stateless
                @Remote(RemoteCalculator.class)
                public class CalculatorBean implements RemoteCalculator {
                
                
                    @Override
                    public int add(int a, int b) {
                        return a + b;
                    }
                
                
                    @Override
                    public int subtract(int a, int b) {
                        return a - b;
                    }
                }
                

                 

                RemoteCalculator.java:

                package org.jboss.as.quickstarts.ejb.remote.stateless;
                
                public interface RemoteCalculator {
                
                    int add(int a, int b);
                    int subtract(int a, int b);
                }
                

                 

                I deployed the Calculator.ear file successfully. The output of jboss was as follows:

                10:23:39,750 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starte Deployment von "Calculator.ear" (runtime-name: "Calculator.ear")
                10:23:39,785 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015973: Starte Subdeployment (runtime-name: "Calculator-ejb.jar")
                10:23:39,791 INFO  [org.jboss.as.pojo] (MSC service thread 1-4) JBAS017000: Veralteten Bean/Pojo Namespace: urn:jboss:bean-deployer:2.0 gefunden - es k�nnen xml-Features fehlen (potenzielle Ausnahmen).
                10:23:39,809 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named CalculatorBean in deployment unit subdeployment "Calculator-ejb.jar" of deployment "Calculator.ear" are as follows:
                
                
                  java:global/Calculator/Calculator-ejb/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator
                  java:app/Calculator-ejb/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator
                  java:module/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator
                  java:jboss/exported/Calculator/Calculator-ejb/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator
                  java:global/Calculator/Calculator-ejb/CalculatorBean
                  java:app/Calculator-ejb/CalculatorBean
                  java:module/CalculatorBean
                
                
                10:23:39,879 INFO  [org.jboss.as.server] (HttpManagementService-threads - 8) JBAS015859: "Calculator.ear" deployed (runtime-name: "Calculator.ear")
                

                 

                I created the ClientCalculator.jar file:

                 

                ClientCalculator.jar:

                META-INF --> MANIFEST.MF

                org            --> jboss --> quickstarts --> ejb --> remote --> client --> RemoteEJBClient.class

                jboss-ejb-client.properties

                 

                RemoteEJBClient.java:

                package org.jboss.as.quickstarts.ejb.remote.client;
                
                import org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator;
                
                
                import javax.naming.Context;
                import javax.naming.InitialContext;
                import javax.naming.NamingException;
                
                import java.util.Hashtable;
                
                public class RemoteEJBClient {
                
                
                    public static void main(String[] args) throws Exception {
                        // Invoke a stateless bean
                        invokeStatelessBean();
                    }
                
                
                    /**
                     * Looks up a stateless bean and invokes on it
                     *
                     * @throws NamingException
                     */
                    private static void invokeStatelessBean() throws NamingException {
                        // Let's lookup the remote stateless calculator
                        final RemoteCalculator statelessRemoteCalculator = lookupRemoteStatelessCalculator();
                        System.out.println("Obtained a remote stateless calculator for invocation");
                        // invoke on the remote calculator
                        int a = 204;
                        int b = 340;
                        System.out.println("Adding " + a + " and " + b + " via the remote stateless calculator deployed on the server");
                        int sum = statelessRemoteCalculator.add(a, b);
                        System.out.println("Remote calculator returned sum = " + sum);
                        if (sum != a + b) {
                            throw new RuntimeException("Remote stateless calculator returned an incorrect sum " + sum + " ,expected sum was "
                                + (a + b));
                        }
                        // try one more invocation, this time for subtraction
                        int num1 = 3434;
                        int num2 = 2332;
                        System.out.println("Subtracting " + num2 + " from " + num1
                            + " via the remote stateless calculator deployed on the server");
                        int difference = statelessRemoteCalculator.subtract(num1, num2);
                        System.out.println("Remote calculator returned difference = " + difference);
                        if (difference != num1 - num2) {
                            throw new RuntimeException("Remote stateless calculator returned an incorrect difference " + difference
                                + " ,expected difference was " + (num1 - num2));
                        }
                    }
                
                    /**
                     * Looks up and returns the proxy to remote stateless calculator bean
                     *
                     * @return
                     * @throws NamingException
                     */
                    private static RemoteCalculator lookupRemoteStatelessCalculator() throws NamingException {
                        final Hashtable<String, String> jndiProperties = new Hashtable<>();
                        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                        final Context context = new InitialContext(jndiProperties);
                
                
                        // The JNDI lookup name for a stateless session bean has the syntax of:
                        // ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>
                        //
                        // <appName> The application name is the name of the EAR that the EJB is deployed in
                        // (without the .ear). If the EJB JAR is not deployed in an EAR then this is
                        // blank. The app name can also be specified in the EAR's application.xml
                        //
                        // <moduleName> By the default the module name is the name of the EJB JAR file (without the
                        // .jar suffix). The module name might be overridden in the ejb-jar.xml
                        //
                        // <distinctName> : EAP allows each deployment to have an (optional) distinct name.
                        // This example does not use this so leave it blank.
                        //
                        // <beanName> : The name of the session been to be invoked.
                        //
                        // <viewClassName>: The fully qualified classname of the remote interface. Must include
                        // the whole package name.
                        
                        final String appName = "Calculator";
                        final String moduleName = "Calculator-ejb";
                        final String distinctName = "";
                        final String beanName = "CalculatorBean";
                        final String viewClassName = RemoteCalculator.class.getName();
                        System.out.println("Looking EJB via JNDI ");
                        String ejbUrl = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName;
                        System.out.println(ejbUrl);
                        // let's do the lookup
                        return (RemoteCalculator) context.lookup(ejbUrl);
                    }
                
                }
                

                 

                jboss-ejb-client.properties:

                endpoint.name=client-endpoint
                remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
                
                remote.connections=default
                
                remote.connection.default.host=10.7.97.48
                remote.connection.default.port = 8080
                remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
                
                remote.connection.default.username=ejbappuser
                remote.connection.default.password=e3q5o-tbp
                

                 

                The target host has the ip 10.7.97.48.

                From my client host I can ping the target host.

                 

                From my client host a telnet session doesn't work:

                telnet 10.7.97.48 8080 --> Connection refused.

                 

                The Client app "ClientCalculator.jar" run on a host, which uses a proxy to connect to the web.

                 

                I get the following error message, if I run the Client app:

                Looking EJB via JNDI

                ejb:Calculator/Calculator-ejb//CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator

                Okt 05, 2015 11:42:01 AM org.jboss.ejb.client.EJBClient <clinit>

                INFO: JBoss EJB Client version 1.0.30.Final-redhat-1

                Obtained a remote stateless calculator for invocation

                Adding 204 and 340 via the remote stateless calculator deployed on the server

                Okt 05, 2015 11:42:02 AM org.xnio.Xnio <clinit>

                INFO: XNIO Version 3.0.13.GA-redhat-1

                Okt 05, 2015 11:42:02 AM org.xnio.nio.NioXnio <clinit>

                INFO: XNIO NIO Implementation Version 3.0.13.GA-redhat-1

                Okt 05, 2015 11:42:03 AM org.jboss.remoting3.EndpointImpl <clinit>

                INFO: JBoss Remoting version 3.3.4.Final-redhat-1

                Okt 05, 2015 11:42:05 AM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers

                WARN: Could not register a EJB receiver for connection to 10.7.97.48:8080

                java.lang.RuntimeException: java.net.ConnectException: Connection refused: no further information

                  at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:92)

                  at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:80)

                  at org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)

                  at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:146)

                  at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:115)

                  at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:47)

                  at org.jboss.ejb.client.EJBClientContext.getCurrent(EJBClientContext.java:279)

                  at org.jboss.ejb.client.EJBClientContext.requireCurrent(EJBClientContext.java:289)

                  at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:178)

                  at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)

                  at com.sun.proxy.$Proxy0.add(Unknown Source)

                  at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:57)

                  at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.main(RemoteEJBClient.java:38)

                Caused by: java.net.ConnectException: Connection refused: no further information

                  at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

                  at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)

                  at org.xnio.nio.NioXnioWorker$1.handleEvent(NioXnioWorker.java:329)

                  at org.xnio.nio.NioXnioWorker$1.handleEvent(NioXnioWorker.java:325)

                  at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)

                  at org.xnio.nio.NioHandle.run(NioHandle.java:90)

                  at org.xnio.nio.WorkerThread.run(WorkerThread.java:198)

                  at ...asynchronous invocation...(Unknown Source)

                  at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)

                  at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:386)

                  at org.jboss.ejb.client.remoting.EndpointPool$PooledEndpoint.connect(EndpointPool.java:187)

                  at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:152)

                  at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:133)

                  at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:78)

                  ... 11 more

                 

                What did I wrong?

                Did I forget something?