6 Replies Latest reply on Feb 12, 2013 7:02 AM by Jahoorulla Shaik

    Problem with remote ejb calls and jboss client 7.1.3

    Jahoorulla Shaik Newbie

      I am currently evaluating jboss eap 6.0.1 which comes with Jboss AS 7.1.3.

      My remote ejb look up is working fine but when I am invoking any remote ejb calls its throwing null pointer exception.

       

      Error stack trace:

       

      java.lang.NullPointerException
      at org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver.<init>(RemotingConnectionEJBReceiver.java:102)
      at org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver.<init>(RemotingConnectionEJBReceiver.java:90)
      at org.jboss.ejb.client.EJBClientContext.registerConnection(EJBClientContext.java:347)
      at org.jboss.naming.remote.client.ejb.RemoteNamingEjbClientContextSelector.getContext(RemoteNamingEjbClientContextSelector.java:60)
      at org.jboss.naming.remote.client.ejb.RemoteNamingEjbClientContextSelector.getCurrent(RemoteNamingEjbClientContextSelector.java:46)
      at org.jboss.naming.remote.client.ejb.RemoteNamingEjbClientContextSelector.getCurrent(RemoteNamingEjbClientContextSelector.java:15)
      at org.jboss.ejb.client.EJBClientContext.getCurrent(EJBClientContext.java:228)
      at org.jboss.ejb.client.EJBClientContext.requireCurrent(EJBClientContext.java:238)
      at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:120)
      at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
      at $Proxy6.addCustomer(Unknown Source)
      at com.test.remote.RemoteCustomerTest.testCustomerService(RemoteCustomerTest.java:49)

       

       

      This is how my EJB3 subsytem configuration looks like

       

      <subsystem xmlns="urn:jboss:domain:ejb3:1.3">

                  <session-bean>

                      <stateless>

                          <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>

                      </stateless>

                      <stateful default-access-timeout="5000" cache-ref="simple"/>

                      <singleton default-access-timeout="5000"/>

                  </session-bean>

                  <mdb>

                      <resource-adapter-ref resource-adapter-name="hornetq-ra"/>

                      <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>

                  </mdb>

                  <pools>

                      <bean-instance-pools>

                          <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                          <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                      </bean-instance-pools>

                  </pools>

                  <caches>

                      <cache name="simple" aliases="NoPassivationCache"/>

                      <cache name="passivating" passivation-store-ref="file" aliases="SimpleStatefulCache"/>

                  </caches>

                  <passivation-stores>

                      <file-passivation-store name="file"/>

                  </passivation-stores>

                  <async thread-pool-name="default"/>

                  <timer-service thread-pool-name="default">

                      <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>

                  </timer-service>

                  <remote connector-ref="remoting-connector" thread-pool-name="default"/>

                  <thread-pools>

                      <thread-pool name="default">

                          <max-threads count="10"/>

                          <keepalive-time time="100" unit="milliseconds"/>

                      </thread-pool>

                  </thread-pools>

                  <iiop enable-by-default="false" use-qualified-name="false"/>

              </subsystem>

       

       

      I have come across a similar discussion https://community.jboss.org/thread/206049?start=0&tstart=0

      I have tried with latest nightly build and still facing the same issue.

      Is it a existing bug in the current release? Will it be fixed in the future 7.2 release?

        • 1. Re: Problem with remote ejb calls and jboss client 7.1.3
          Nicklas Karlsson Master

          show the lookup code and related properties files

          • 2. Re: Problem with remote ejb calls and jboss client 7.1.3
            Jahoorulla Shaik Newbie

            Sorry for the delay in response...

             

            This is how our lookup code is:

             

            public class RemoteHelper

            {

             

                private static final String SYSPROP_SERVER_URL = "java.naming.provider.url";

                private static final String SYSPROP_CONTEXT_FACTORY = "java.naming.factory.initial";

                private static final String SYSPROP_SERVER_PRINCIPAL = "server.principal";

                private static final String SYSPROP_SERVER_PASSWORD = "server.password";

                private static final String SYSPROP_FACTORY_URL_PKGS = "java.naming.factory.url.pkgs";

                private static final String SYSPROP_SECURITY_AUTHENTICATION = "security.authentication";

                private static final String SERVER_TYPE = "server.type";

                private static Context ctx;

             

             

                private static Context getContext() throws Exception

                {

             

                    if (ctx == null)

                    {

                        Hashtable<Object, Object> ht = new Hashtable<Object, Object>();

                        ht.put(Context.INITIAL_CONTEXT_FACTORY, getProperty(SYSPROP_CONTEXT_FACTORY));

                        ht.put(Context.PROVIDER_URL, getProperty(SYSPROP_SERVER_URL));

             

                        if ("jboss".equals(getProperty(SERVER_TYPE)))

                        {

                            ht.put(Context.URL_PKG_PREFIXES, getProperty(SYSPROP_FACTORY_URL_PKGS));

                            ht.put(Context.SECURITY_PRINCIPAL,"superadmin");

                            ht.put(Context.SECURITY_CREDENTIALS,"superadmin");

                            ht.put("jboss.naming.client.ejb.context", true);

                            ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

                            //ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");

                        }

                        ctx = new InitialContext(ht);

                    }

             

                    return ctx;

                }

             

             

                public static Object getRemoteBean(String beanName)

                {

                    Object obj;

                    try

                    {

                        if ("jboss".equals(getProperty(SERVER_TYPE)) && beanName != null)

                        {

                            if("ReportServiceEJB".equals(beanName.split("#")[0]))

                                beanName = "ejb:reportApp/platform-ejb//"+beanName.split("#")[0]+"!"+beanName.split("#")[1];

                            else

                                beanName = "ejb:mainApp/platform-ejb//"+beanName.split("#")[0]+"!"+beanName.split("#")[1];

                            System.out.println("Bean Name: "+beanName);

                        }

                        obj = getContext().lookup(beanName);

                    }

                    catch (Exception e)

                    {

                        throw new RuntimeException(e);

                    }

                    return obj;

                }

             

            }

             

             

            Please find its related properties file..

             

            ### jndi.properties for remote clients - jboss

            jboss.java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory

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

            jboss.java.naming.provider.url=remote://localhost:4447

            security.authentication=simple

             

             

            Actually When I run this on JBoss client 7.1.1 it works fine... It throws null pointer exception when running with 7.1.3 client.

            • 3. Re: Problem with remote ejb calls and jboss client 7.1.3
              Wolf-Dieter Fink Master

              Looks like that you mix different approaches to connect an EJB.

              If you set the provider.url with "remote*" you are using the remote-naming project [1].

              The 'ejb' prefix is from the (recommeded) new EJB client api [2].

               

              Please read the documentation and check whether your client is setup correct.

              Also notice that the remote-naming project does not support all features for EJB clients (i.e. clustering and loadbalancing)

               

              [1] https://docs.jboss.org/author/display/AS72/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

              [2] https://docs.jboss.org/author/display/AS72/EJB+invocations+from+a+remote+client+using+JNDI

              • 4. Re: Problem with remote ejb calls and jboss client 7.1.3
                Jahoorulla Shaik Newbie

                I have gone through the documents and made necessary changes.

                 

                private static Context getContext() throws Exception

                    {

                        if (ctx == null)

                        {

                            Hashtable<Object, Object> ht = new Hashtable<Object, Object>();

                           

                            if ("jboss".equals(getProperty(SERVER_TYPE)))

                            {

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

                               

                            }

                            ctx = new InitialContext(ht);

                        }

                 

                        return ctx;

                    }

                 

                 

                My 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=localhost

                remote.connection.default.port = 4447

                remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

                 

                remote.connection.default.username=superadmin

                remote.connection.default.password=superadmin

                 

                 

                Now it throws an error at invocation like this:

                 

                ERROR [Remoting "client-endpoint" read-1] (RemoteConnection.java:105) - JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

                 

                Error Stack Trace:

                 

                EJBCLIENT000025: No EJB receiver available for handling [appName:myApp, moduleName:platform-ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@359b46dc

                 

                java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:myApp, moduleName:platform-ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@359b46dc
                at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:588)
                at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
                at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183)
                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
                at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
                at $Proxy6.addCustomer(Unknown Source)
                at
                com.test.remote.RemoteCustomerTest.testCustomerService(RemoteCustomerTest.java:49)

                 

                 

                please let me know if you need any other information.

                • 5. Re: Problem with remote ejb calls and jboss client 7.1.3
                  Jahoorulla Shaik Newbie

                  Even the latest code works fine when I replace ejb client jar of 7.1.1 version.

                  Anyone please let me know is this is a bug in 7.1.3 version?

                   

                  Thanks in advance...

                  • 6. Re: Problem with remote ejb calls and jboss client 7.1.3
                    Jahoorulla Shaik Newbie

                    I set the following property in jboss-ejb-client.properties and its working fine.

                    remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false

                     

                    Thanks Wolf-Dieter for your help.