-
1. Re: JNDI Lookup of EJBs
prasad.deshpande Jul 21, 2011 2:21 PM (in response to mohanpotturi)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 Jul 21, 2011 2:34 PM (in response to mohanpotturi)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 Jul 21, 2011 2:37 PM (in response to prasad.deshpande)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 Jul 21, 2011 2:42 PM (in response to wolfc)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 Nov 12, 2012 2:16 PM (in response to prasad.deshpande)Here is the stack trace Prasad.
STACK_TRACE
-
6. Re: JNDI Lookup of EJBs
prasad.deshpande Jul 21, 2011 3:10 PM (in response to mohanpotturi)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 Jul 21, 2011 3:10 PM (in response to mohanpotturi)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 Jul 21, 2011 3:12 PM (in response to mohanpotturi)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 Nov 12, 2012 2:18 PM (in response to prasad.deshpande)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 Jul 21, 2011 3:32 PM (in response to mohanpotturi)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 Jul 21, 2011 3:33 PM (in response to wolfc)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 Jul 21, 2011 3:40 PM (in response to mohanpotturi)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 Nov 12, 2012 4:40 PM (in response to prasad.deshpande)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 Jul 21, 2011 4:00 PM (in response to mohanpotturi)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.