1 2 3 Previous Next 31 Replies Latest reply on Jul 11, 2013 1:24 AM by Hans-Dieter Mader

    SLSB EJB3.1 invocation server to server - localhost and remote host

    Hans-Dieter Mader Newbie

      Hi,

       

      I have two servers and one SFSB ejbX inside a WAR:

       

      hostA

           |---------webApp1 (war)

       

           |---------webApp2 (war)

                          |---------ejbX

       

      hostB

           |---------webApp2 (war)

                          |---------ejbX

       

      The approach is: Sequential method call on both ejbs

       

      1) webApp1 method call to webApp2/ejbX on hostA -> same host

      2) webApp1 method call to webApp2/ejbX on hostB -> remote host

       

      Step 1 is working fine!

       

      Step 2 throws an Exception when I try to instanciate a new InitialContext.

       

      Here is my Code (inside from a WAR context):

       

       

                String serverUrl="remote://localhost:port";

       

                final Properties jndiProps = new Properties();

       

                  if ( serverUrl.trim().toLowerCase().indexOf("localhost")==-1 ){
                      jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                  }
                 
                  jndiProps.put("jboss.naming.client.ejb.context", true);
                  jndiProps.put(Context.PROVIDER_URL, serverUrl);
                  jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                  jndiProps.put(Context.SECURITY_PRINCIPAL, "xxxxx");
                  jndiProps.put(Context.SECURITY_CREDENTIALS, "xxxxxx");           

       

                  InitialContext context = new InitialContext(jndiProps);

       

                  EjbXRemote ejbX = c.lookup("ejb:/myApp/ejbX!EjbXRemote");

       

                  ejbX.methodCall();     // OK

       

       

                   serverUrl="remote://hostB:port"; 

       

                final Properties jndiPropsB = new Properties();

       

                  if ( serverUrl.trim().toLowerCase().indexOf("localhost")==-1 ){
                      jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                  }
                 
                  jndiPropsB.put("jboss.naming.client.ejb.context", true);
                  jndiPropsB.put(Context.PROVIDER_URL, serverUrl);
                  jndiPropsB.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                  jndiPropsB.put(Context.SECURITY_PRINCIPAL, "xxxxx");
                  jndiPropsB.put(Context.SECURITY_CREDENTIALS, "xxxxxx");           

       

                  InitialContext context = new InitialContext(jndiPropsB); // Exception

       

                  EjbXRemote ejbX = c.lookup("ejb:/myApp/ejbX!EjbXRemote");

       

                  ejbX.methodCall();

       

      Exception:

       

      javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.piweb.war:main" from Service Module Loader

      at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)

      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)

      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)

      at javax.naming.InitialContext.init(InitialContext.java:242)

      at javax.naming.InitialContext.<init>(InitialContext.java:216)

      at com.magnasteyr.josf3.pibase.arm.ARMSyncEjb.processUserData(ARMSyncEjb.java:192)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.lang.reflect.Method.invoke(Method.java:601)

      at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)

      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)

      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)

      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:101)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

      at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInNoTx(CMTTxInterceptor.java:211)

      at org.jboss.as.ejb3.tx.CMTTxInterceptor.notSupported(CMTTxInterceptor.java:288)

      at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:188)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

      at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)

      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      at org.jboss.as.ejb3.component.interceptors.AsyncVoidInterceptorFactory$Task.run(AsyncVoidInterceptorFactory.java:75)

      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

      at java.lang.Thread.run(Thread.java:722)

      at org.jboss.threads.JBossThread.run(JBossThread.java:122)

       

       

      Thank you very much for any help!!!!!!!!!!!!!!!!!!!!!!

      Hans

        1 2 3 Previous Next