Migrate from EJB 2 Entity Bean to EJB3 - jpa

I am having some entity beans created in EJB 2.0 and now I need to migrate to EJB 3.x, but I've studied that use of entity beans are changed in EJB 3.x and they are using JPA instead.
Where can I find solution to actuate my beans to be comfortable with EJB 3.x?

For example from following resources available online:
http://www.datadisk.co.uk/html_docs/ejb/ejb3_migration.htm
http://www.oracle.com/technetwork/middleware/ias/oc4j-twp-ejb3-migration-1013-133021.pdf
or following printed books:
Pro JPA 2 Mastering the Java Persistence API (p. 457-466)
EJB3 in Action (p. 513-528)

IntelliJ EJB refactoring tools might prove to be useful: http://www.jetbrains.com/idea/webhelp/migrating-to-ejb-3-0.html
I belive there are some for Eclipse too.

just for future reference, I recommend the following link:
http://what-when-how.com/enterprise-javabeans-3/migrating-cmp-2-entity-beans-to-the-ejb-3-jpa-part-1/
And there's also part 2 on the same site as well as migrating session beans and MDBs.
I used them and found them very helpful and useful.

Related

Does Jboss 7.1 AS supports ejb 2.1?

it seems jboss AS 7.1 supports ejb 2.1.Our ejb 2.1 based application is deployed on jboss 5 AS. We are migrating it to jboss7.1. but i want to know what are the additional configurations required to run ejb 2.1 without any errors?
EJB2 is still supported in AS7.x, the issue might be that AS7 is a new implementation and some of the tuning options and configuations are not available for AS7 - especially the EntityBean CMP.
There are some added for EAP6 (based on AS7) you might download the unsupported version.
Wildfly (the successor of JBossAS) will not continue to support EJB2 EntityBeans because EJB3.2 declare it as optional.
Note EJB2 session beans are still supported but I recommend to upgrade it to EJB3 this should faily simple.
You might keep the EJB2 interfaces to provide an interface for EJB2 clients, but I expect effort for the client as well as the lookup Strings changed.
If the appliation should be kept for the future I would recommend to migrate to EJB3

Enable weaving in an Eclipse RCP application

I use EclipseLink 2.4.1 in an RCP application. When starting the application I get warning messages like
Reverting the lazy setting on the OneToOne or ManyToOne attribute [...] for the entity class [class ...] since weaving was not enabled or did not occur.
The reason is explained here and here. The answers point to the eclipse link documentation and the eclipse link user guide. The solution to enable dynamic weaving is
... the EclipseLink agent must be used when starting the Java VM.
java -javaagent:eclipselink.jar
My question is
Do I have to include the bare jar eclipselink.jar in my distribution (where?) or is it sufficient to add a dependency to some special eclipse link plugin, e.g. to org.eclipse.equinox.weaving.hook?
After further research I see that Gemini/JPA may be a solution. However, I'm still puzzled how to get all pieces together.
Yes, Gemini JPA is the way forward as it provides Enterprise OSGi JPA support with EclipseLink. It also supports weaving using standard OSGi byte code weaving.
You can get Gemini JPA help on the forum: http://www.eclipse.org/forums/index.php?t=thread&frm_id=153
--Shaun

Equinox OSGi + JPA Eclipselink + PAX JDBC driver adapter

After many problems with "CLASS NOT FOUND" problems in OSGi working with JPA persistence & Eclipse link, I found some article introducing PAX JDBC driver adapter.
Does anybody has some experience with this ?
Pax JDBC should be fairly straightforward to use. Just check out the docs.
In combination with Eclipselink, you should probably stay clear of the Eclipselink OSGi adapter which has an unnecessary dependency on Eclipse Gemini DBAccess, at least last time I looked at it.
Pax JPA is an incubating project which provides OSGi Enterprise compliant adapters for Eclipselink and OpenJPA.

Java EE How do you use an EntityManager with Mongo?

I"m trying to create a Java EE project using a mongo database. I am unable to find any good working examples.How do you correctly set up JPA for the project?
Java EE 6 (or in JPA 2.0 as an part of it) does not have any defined support for MongoDB or for NoSQL databases in general.
That's why how it is done depends fully from JPA provider implementation. If you use EclipseLink, maybe you can try to follow example given in this blog post and present further questions about what exactly is not working.
Hey you should at least check out Arun Gupta's blog post on this at https://blogs.oracle.com/arungupta/entry/java_ee_6_and_nosql. Gupta is the Oracle Java EE Evangelist and this entry covers using EclipseLink for a JPA connection to MongoDB and deploying to Glassfish. If you search his blog, there is also an earlier entry on how to use the Java driver included with MongoDB in a Java EE project. I haven't tried the example with an EntityManager but am thinking about doing so.

MyBatis integration with JBoss 7.1 web application

Had anybody attempted to use MyBatis as their persistence library for a JBoss 7.1 /Java EE6 application?
I'm wondering what are the best approaches to handling connections, transations, rollbacks etc?
How about CDI support? Looking around online it seems at this time MyBatis only supports two Dependency Injection (JSR-330) frameworks, Google Guice and Spring. I did run into CDI Extensions which may be something look into.
My idea would be to have the container handle all of the above however it may be difficult getting to that point.
Any tips, hints, experiences?
There is a new mybatis-cdi module. It is not released yet, but you can try the snapshot, it is at github: https://github.com/mybatis/cdi
There is no CDI support at all but as you said, if you want DI go Spring or Guice.
With JBoss you have mainly two chances:
- EJB 3
- Spring
If using EJB 3 transactions are handled automatically by them. MyBatis just ignores transactions and lets the container commit/rollback.
When using Spring, MyBatis ties to Spring transactions using the integration module MyBatis-Spring.
I would create my own CDI bean - use #Produces for a factory, and #Inject to get the session.
Here is old iBatis Spring factory, that might be the producer, after some changes:
SqlMapClientFactoryBean