Saturday, February 16, 2013
MongoDB in EJB project with EclipseLink
First you need to update persistense related jar files
in Glassfish modules folder
Update 7 persistence related jar files
in glassfish/modules
This folder in my PC is located
in c:\Program Files\glassfish-3.1.2.2\glassfish\modules
first backup current files just in case - create a new sub-folder _backup
move the files from modules to this new folder:
org.eclipse.persistence.antlr.jar
org.eclipse.persistence.jpa.jar
org.eclipse.persistence.asm.jar
org.eclipse.persistence.jpa.modelgen.jar
org.eclipse.persistence.core.jar
org.eclipse.persistence.oracle.jar
javax.persistence.jar
Then from eclipselink website download new zip file,
look for OSGI bundle:
http://www.eclipse.org/eclipselink/downloads/index.php#2.4
unzip that downloaded zip into some directory like
c:\javalibs
Then copy the updated versions on the same 7 .jar files
to
glassfish\modules directory
In case here:
c:\Program Files\glassfish-3.1.2.2\glassfish\modules
and then rename each of these .jar files to remove the versioning part of
file name, for example
org.eclipse.persistence.asm_3.3.1.v201206041142.jar
should be renamed to
org.eclipse.persistence.asm.jar
Do the same of the other updated files
Finally add these 2 .jar files to your project libs via NetBeans:
org.eclipse.persistense.nosql_xxxxxxx.jar (xxxxx is a version string like _2.4.1.v20121003-ad44345.jar
and also download the java client .jar from mongodb download site
and also add the mongo-java-driver-2.6.2.jar to your project library (the actual latest version may
be greater than 2.6.2 by now)
Restart Glassfish server, this can be done from inside NetBeans
The mongodb can be used now, so a regular @Entity annotation can be used
to persist data to mongo
So far so good.
Mongodb does not have transaction support so you will be use translation-type="RESOURCE_LOCAL"
in the persistence-unit section in persistence.xml
Then you have to provide your own transaction support in the classes
Some examples and basic documentation
is here
http://wiki.eclipse.org/EclipseLink/Examples/JPA/NoSQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment