简体   繁体   中英

Calling an EJB3 library from an EJB2 library

I have an existing application that is written in EJB2.1. This is deployed on jboss-5.1.0.GA as an EAR.

I now have a new requirement to implement a process which is supposed to be used by the EJB2.1 application. Both will be in their own ear files but will both be running on the same jboss-5.1.0 instance.

My questions are:

  • Is it possible to call the services of the EJB3 ear from the EJB2.1 ear?
  • If the answer to the above is yes, is it possible to manage the transactions? ie only have the EJB2.1 application commit any transactions.
  • Migrating the existing 2.1 application to v3 is out of the question. Is creating the new process as v3 worth the effort or am i likely to come across problems with the integration between the two?
  • I have been looking around for a simple hello world type example that demonstrate the above but have not been able to find any. Anyone know of a good example?
  • The EJB3 services will be called from session beans in the EJB2 application. Is this the wrong way to do it? (ie the session bean is not a client).

The EJB3 specification allows a smooth transition,defining methods for EJB2/EJB3 interoperability, it's sometimes bulky and you will need artifacts not necessary in a 'normal' EJB3 app ( @RemoteHome )

  • Is it possible to call the services of the EJB3 ear from the EJB2.1 ear?

Yes, it is possible, see: Referencing EJB3 beans in EJB2.1 and Introduction to using EJB2.1 client adaptors and the sample project "ejb21_client_adaptors"

  • If the answer to the above is yes, is it possible to manage the transactions? ie only have the EJB2.1 application commit any transactions.

Yes, just remember to annotate your EJB3 method with @TransactionAttribute(TransactionAttributeType.MANDATORY)

  • The EJB3 services will be called from session beans in the EJB2 application. Is this the wrong way to do it? (ie the session bean is not a client).

I see no problem here, session beans can call other beans' services.

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