简体   繁体   中英

Remote invocation in EJB 3.0

I'm new to EJB 3.0 and trying out the DI with my ejb's.

I'm using WAS 7.0 as my appserver and I have two EAR's deployed on it. Both have ejb 3 session beans and I need to invoke an ejb in ear 2 from an ejb available in ear 1.

In both my applications, I have a client project which holds the local and remote interfaces, a commons project which contains interfaces which are extended by the remote and local interfaces, then the ejb project and a router project(as the webservice endpoints for the ejb's)

Now to make the remote call, I tried putting the client and commons jar files in the lib directory of EAR, updated the META-INF of the ejb project and tried to use the @EJB annotation, but its giving exceptions, that the EJB's are missing.

I tried to do a JNDI lookup, but it gave NamingException.

Which is the correct way to do a remote bean invoke in ejb 3.0?

Please provide your suggestions.

The problem is not the invocation, the problem is getting a reference to the EJB's stub in the first place. For a remote EJB, this absolutely requires a JNDI lookup (unless you want to call it via SOAP or REST). Thus, you need to add the lookup parameter to the @EJB annotation, and you need to pass it the correct JNDI lookup name - and that is the difficult part since the composition of JNDI names is complex and influenced by a lot of factors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM