1 2 3 Previous Next 34 Replies Latest reply on Oct 15, 2013 10:29 AM by steeltomato

    JNDI Lookup of EJBs

    mohanpotturi

      Has anybody tried EJB lookup thru JNDI using the standalone-preview configuration of 7.0.0.Final? I have played around with it for the last few days and ran into issues. For example if the remote interface name is MyEjbRemote and the bean class is MyEjbRemoteBean, then the JNDI lookup results in MyEjbRemote$$$view22. Wondering if anybody else tried it and had similar issues. Appreciate your inputs.

        • 1. Re: JNDI Lookup of EJBs
          prasad.deshpande

          Can you please attach server.log? I was able to deploy my application successfully. It clearly follows rules defined in EE6 for EJBs

          http://download.oracle.com/javaee/6/tutorial/doc/gipjf.html#girgn

           

          Also, how is your application packaged?

          • 2. Re: JNDI Lookup of EJBs
            wolfc

            That's how it is supposed to work. You get back a (proxy) class that implements your business interface with which you communicate with the EJB.

            • 3. Re: JNDI Lookup of EJBs
              mohanpotturi

              Thank you Prasad for the response. My application is packaged in a EAR file. The EAR contains one ejb jar, one war and a bunch of other supporting jars etc. We use @Remote interface eventhough it is all inside one EAR. I am using global portable name like java:global/appName/moduleName/MyEjbRemoteBean for the lookup. What I am getting back is not MyEjbRemote but istead it is MyEjbRemote$$$view22

              • 4. Re: JNDI Lookup of EJBs
                mohanpotturi

                Sure if the returned object is of the Interface that the Bean implements. I tried casting the MyEjbRemote$$$view22 to MyEjbRemote but got ClassCast Exception.

                • 5. Re: JNDI Lookup of EJBs
                  mohanpotturi

                  Here is the stack trace Prasad.

                  STACK_TRACE

                  • 6. Re: JNDI Lookup of EJBs
                    prasad.deshpande

                    Hmm... could you please post content of jar -tvf <ear>? Also, how are you retriving bean, by lookup or by injection? Could you please paste relevant code?

                     

                    EDIT: ClassCast exception typically occures when there is problem of classloader.

                    • 7. Re: JNDI Lookup of EJBs
                      scottg

                      I'm running into the same problem when attempting to inject an EJB from an external ear into a web app.  Using the following annotaion:

                       

                      @EJB(lookup="java:global/hpservices/hpservices/MessageServiceBean!com.hochheim.service.messaging.MessageServiceRemote") private MessageServiceRemote messageService;

                       

                      produces the following exception:

                       

                      java.lang.IllegalArgumentException: Can not set com.hochheim.service.messaging.MessageServiceRemote field com.hochheim.TestBean.messageService to com.hochheim.service.messaging.MessageServiceRemote$$$view2

                      sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)

                      sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)

                      sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)

                      java.lang.reflect.Field.set(Field.java:657)

                      org.jboss.weld.introspector.jlr.WeldFieldImpl.set(WeldFieldImpl.java:97)

                      org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:163)

                      org.jboss.weld.util.Beans.injectEEFields(Beans.java:776)

                      org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:181)

                      org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:54)

                      org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:176)

                      org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:142)

                      org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:170)

                      org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:339)

                      org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:67)

                      org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:693)

                      org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:152)

                      org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:112)

                      org.jboss.as.weld.webtier.jsf.ForwardingELResolver.getValue(ForwardingELResolver.java:46)

                      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)

                      com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)

                      com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)

                      org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:67)

                      org.apache.el.parser.AstValue.getTarget(AstValue.java:71)

                      org.apache.el.parser.AstValue.invoke(AstValue.java:183)

                      org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)

                      org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)

                      org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)

                      com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

                      javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)

                      com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

                      javax.faces.component.UICommand.broadcast(UICommand.java:315)

                      javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)

                      javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)

                      com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

                      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                      javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)

                      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

                      • 8. Re: JNDI Lookup of EJBs
                        wolfc

                        It looks like there is a bug in the class loader handling of remote interfaces.

                         

                        Could you print the class loader of the result and the class loader of the expected?

                         

                        For the moment you can work around the issue by making sure only 1 version of the remote interface is deployed and made available to other deployments via Class-Path entries.

                        • 9. Re: JNDI Lookup of EJBs
                          mohanpotturi

                          I reference the beans from the web tier (mostly action classes and other POJOs) and use JNDI lookup. Here is the lookup code:

                           

                          InitialContext     ctx_ = new InitialContext();

                          Object   remoteObj = ctx_.lookup(jndiName);

                          • 10. Re: JNDI Lookup of EJBs
                            prasad.deshpande

                            What are the contents of lib/infolink-mapping-ejb-client.jar? How have you packaged your remote interface classes? Are they packaged separately in WAR (alongwith EJB jar or ear/lib)?

                             

                            As Carl said above, please have just one copy of remote interfaces (may be in ear/lib directory).

                             

                            Also, could you please attach server.log?

                            • 11. Re: JNDI Lookup of EJBs
                              mohanpotturi

                              Carlo de Wolf wrote:

                               

                              Could you print the class loader of the result and the class loader of the expected?

                               

                              Carlo, I am not sure I understood you on this. How do I do that? Can you please elaborate it? Appreciate your help.

                              • 12. Re: JNDI Lookup of EJBs
                                wolfc

                                Mohan Potturi wrote:

                                 

                                com.crown.infolink.web.exception.SystemException: Invalid remote class type received (com.crown.infolink.ejb

                                .place.PlaceQueryRemote$$$view3) when com.crown.infolink.ejb.place.PlaceQueryRemote was expected.

                                Could you add the class loader of com.crown.infolink.ejb.place.PlaceQueryRemote$$$view3 and the class loader of com.crown.infolink.ejb.place.PlaceQueryRemote to this error message?

                                • 13. Re: JNDI Lookup of EJBs
                                  mohanpotturi

                                  All the implementation classes and interfaces of the EJBs are inside prod-ejb.jar. Each class exists only in one jar and only one version and there are no multiple copies spread across different jars. The prod-mapping-ejb-client.jar is a place holder for hooks to an external mapping application which is not active at the moment. That jar doesn't even come into the picture for the problem we are discussing. Sorry I forgot to attach the server log file last time. Here it is...

                                  • 14. Re: JNDI Lookup of EJBs
                                    wolfc

                                    In that case it's even more important to know the two class loaders. So you'll need to modify JNDIHelper.handleInvalidRemoteClass to output those.

                                    1 2 3 Previous Next