1 2 3 Previous Next 30 Replies Latest reply on Mar 17, 2014 2:41 PM by gah doh

    Jboss5 remote EJB lookup from Jboss 7.1CR1

    pushpak1981 Novice

      How can i do the EJB lookup for remote Jboss5.1 EJB's from Jboss 7.1CR1. Is this the same way as mentioned:

       

      https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

       

      as the JNDI names for Jboss5.1 EJB's will be different.

        • 1. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
          Kavan Desai Newbie

          As per my knowledge the above link is only applicable to EJB3.x deployed in JBOSS AS 7.x

           

          For the earlier version it would be some thing like

           

          Properties props = new Properties();

                              props.setProperty("java.naming.provider.url", "localhost:1099");

                              props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");

                              props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

                              InitialContext context = new InitialContext(props);

                              if (Log.doActionTrace())

           

                              try {

                                 

                                  trade = (TradeServices) context.lookup("ejb/TradeSLSBBean"); // jndi name given in jboss.xml or ejb-jar.xml              

                              } catch (Exception ex) {

                                  ex.printStackTrace();

                                  Log.error("TradeAction:createTrade - Lookup of TradeSLSBRemote failed!!!");

                                  trade = (TradeServices) context.lookup("TradeSLSBBean");

                              }

          • 2. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
            pushpak1981 Novice

            Thanks for the reply.

             

            We tried with the approach but we are getting the following exception in Jboss7.1 console:

            16:56:42,441 ERROR [stderr] (MSC service thread 1-4) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.AAA.ear.AAA.war:main" from Service Module Loader

            16:56:42,447 ERROR [stderr] (MSC service thread 1-4)    at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:60)

            16:56:42,451 ERROR [stderr] (MSC service thread 1-4)    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:664)

            16:56:42,458 ERROR [stderr] (MSC service thread 1-4)    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

            16:56:42,465 ERROR [stderr] (MSC service thread 1-4) at javax.naming.InitialContext.init(InitialContext.java:223)

            16:56:42,471 ERROR [stderr] (MSC service thread 1-4)    at javax.naming.InitialContext.<init>(InitialContext.java:197)

            • 3. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
              Kavan Desai Newbie

              Hi

               

              Are the ejbs deployed successfully in JBOSS AS 5? Can you paste the client code snippet here?

              Also ejb-jar or jboss.xml where you have specified jndi name of the ejb?

              • 4. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                Carlo de Wolf Master

                Start by creating a module which contain the client jars from AS 5. Add that as a dependency to your deployment.

                Alternatively you can package the AS 5 client jars with your deployment, but I think it'll probably run into class conflicts.

                 

                To properly resolve such class conflicts we would need an isolated context as mention in AS7-1709.

                • 5. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                  pushpak1981 Novice

                  Yes we verified that the beans are deployed properly. When we try to do a lookup for the same EJB from Jboss5.1 it works fine. We have used Annotations so there are no ejb-jar.xml file. The beans are by default binded to appname/beanname/remote.

                  • 6. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                    Kavan Desai Newbie

                    As Carlo suggested you can probably try creating a seperate module (out side AS 7 and AS 5 as a standalone application) of ejb client and adding required client jar (jbossall-client.jar probably) and try to do the lookup using above given code snippet.That would be an itermideate step.

                    • 7. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                      pushpak1981 Novice

                      Thanks for the reply. Yes we tried with the stanalone application by including Jboss5.1 client jars and bean look up works fine. We are now trying to create a Jboss7.1 module for Jboss5.1 client jars and trying to run our code in server environment as suggested by Carlo.

                      • 8. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                        Anton Ivakhnenko Newbie

                        Hi! i'm had same problem with jboss 6

                        try this:

                         

                        Properties env = new Properties();

                        env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");

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

                        env.put(Context.PROVIDER_URL, providerUrl);

                        InitialContext ctx = new InitialContext(env);

                         

                         

                        now i have another problem when i try to lookup remote ejb:  javax.naming.NameNotFoundException: MyApp/RemoteEJB/remote -- service jboss.naming.context.java.MyApp.RemoteEJB.remote

                        • 9. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                          Anton Ivakhnenko Newbie

                          i'm fix this javax.naming.NameNotFoundException. JNDI name must be in format: ejb:/MyApp//RemoteEjb!my.ejb.remote.interface.stateless.RemoteEjb

                          • 10. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                            pushpak1981 Novice

                            Do we need the class isolation mentioned by Carlo ?

                             

                            I tried with class isolaton and did a lookup and it throws an exception

                             

                            java.lang.ClassCastException: $Proxy115 cannot be cast to com.MyRemoteInterface

                             

                            I tried with lookup name starting with ejb:/ but it throws an exception. My beans are stateful beans.

                            • 11. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                              Anton Ivakhnenko Newbie

                              My aforecited approach proved to be wrong. I've tried the method described here: https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance but unsuccessfully yet.

                               

                              useful topic: https://community.jboss.org/message/647885

                              • 12. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                                Carlo de Wolf Master

                                How did you package your remote view class (MyRemoteInterface)?

                                • 13. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                                  pushpak1981 Novice

                                  We created an isolated class loader which contains jars for JBoss5.1 all clients and also added our remote interface jar to that class loader.

                                   

                                  We are facing the following error message

                                  ERROR [stderr] (pool-9-thread-1) java.lang.ClassCastException: $Proxy117 cannot be cast to com.MyRemoteInterface

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                                  ERROR [stderr] (pool-9-thread-1)   at java.lang.reflect.Method.invoke(Method.java:597)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                                  ERROR [stderr] (pool-9-thread-1)   at java.lang.reflect.Method.invoke(Method.java:597)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.seam.async.TimerServiceDispatcher.dispatch(TimerServiceDispatcher.java:50)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                                  ERROR [stderr] (pool-9-thread-1)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                                  ERROR [stderr] (pool-9-thread-1)   at java.lang.reflect.Method.invoke(Method.java:597)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:39)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.timerservice.TimedObjectInvokerImpl.callTimeout(TimedObjectInvokerImpl.java:101)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.timerservice.TimedObjectInvokerImpl.callTimeout(TimedObjectInvokerImpl.java:111)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.timerservice.task.TimerTask.callTimeout(TimerTask.java:148)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.as.ejb3.timerservice.task.TimerTask.run(TimerTask.java:126)

                                  ERROR [stderr] (pool-9-thread-1)   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

                                  ERROR [stderr] (pool-9-thread-1)   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

                                  ERROR [stderr] (pool-9-thread-1)   at java.util.concurrent.FutureTask.run(FutureTask.java:138)

                                  ERROR [stderr] (pool-9-thread-1)   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)

                                  ERROR [stderr] (pool-9-thread-1)   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)

                                  ERROR [stderr] (pool-9-thread-1)   at java.lang.Thread.run(Thread.java:619)

                                  ERROR [stderr] (pool-9-thread-1)   at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                                  • 14. Re: Jboss5 remote EJB lookup from Jboss 7.1CR1
                                    Carlo de Wolf Master

                                    That won't work out.

                                     

                                    See Re: EJB call from 4.2.3 to 5.1.0? and http://wolf-71.blogspot.com/2010/02/et-phone-home.html.

                                     

                                    In short, the remote view class needs to be directly available from your deployment, while the AS 5 client jar needs to be isolated. You can combine the two using AluniteClassLoader.

                                     

                                    Message was edited by: Carlo de Wolf

                                    1 2 3 Previous Next