Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any EJB migration tools available for migrating EJB 2.1 toEJB 3.x

May be the best way is doing it manually. But in a large project you need some tool to assist you. It was the idea that led me to search a tool.

Are there any EJB migration tools available for migrating EJB 2.0 to 3.x.

like image 773
Kayser Avatar asked Apr 12 '12 09:04

Kayser


People also ask

What is the difference between EJB 2.0 and ejb3 0?

EJB 2.0 deploys entity beans for accessing database. EJB 3.0 has Java Persistence API to access data which is generalized to address issues of portability. EJB 3.0 performs better because it uses POJOs along with metadata annotation, a new introduction.

Is EJB jar XML required for ejb3?

EJB 3.0. If you are using EJB 3.0 with the default TopLink Essentials JPA persistence provider, this file is not used. If you are using EJB 3.0, the toplink-ejb-jar. xml file is only used to customize TopLink JPA preview persistence provider configuration (see "Customizing the JPA Persistence Provider").


1 Answers

It was only under development for a short time, but for a period we did have an eclipse plugin that would read in ejb-jar.xml files and then update the source and insert the annotations.

It's been used a handful of times by the person who wrote it (Jonathan Gallimore) and maybe one or two more after. It did at least work then and if you're not afraid of possibly having to roll your sleeves up, it could save you weeks of time.

  • http://svn.apache.org/repos/asf/openejb/trunk/openejb-eclipse-plugin/README.txt
  • http://www.apache.org/dist/openejb/eclipse-plugin/

While I haven't personally used it, I did oversee its development. Long story short is there are xml versions of all the annotations (100% lineup). An EJB container has to effectively read in xml and then fill in the gaps with the annotation data. The xml data wins over annotation data, so this processing is basically an act of turning annotations into xml. We took OpenEJB's annotation/xml processing code and flipped it around so that instead of turning annotations into xml in turned xml into annotations -- annotations which can then be easily inserted back into the source code via the eclipse APIs.

If it runs, it should run great and shouldn't change the logic of your app. Simply an xml->annotation transformation for your descriptor data.

You'll still have EJB 2.x views, but they'll be configured in annotation form in your code.

Before doing anything like that though, I'd get unit tests setup against the EJB 2.x code using the EJBContainer API as mentioned in the other question. Then use the conversion tool. Then refactor out the EJB 2.x views now that you don't have to always be messing with xml.

So basically:

  • Add tests for the existing code
  • Convert using the xml->annotation Eclipse plugin (run tests)
  • Refactor EJB 2.x views to EJB 3.x @Local or @LocalBean views (run tests)

Follow that path and you should have a blissful transition from EJB 2.x to 3.x. Well, as blissful as that job can be at least :)

like image 105
David Blevins Avatar answered Oct 20 '22 12:10

David Blevins