Wednesday, May 11, 2011

Moving away from OpenJPA

So last night I had hoped to have all the code ready to talk about creating a character and i would have if it had not been for one problem. OpenJPA 2.0.1 and possibly 2.1.0 have a problem creating an entity with an auto-increment index in a MySQL table. Because of this, I have moved my code to Hibernate3 that comes with Netbeans 7.0.

To do this you will need to go into [SmartFoxInstallDir]/SFS2X/lib and remove:

  • derby-10.5.3.1_1.jar
  • geronimo-*.jar
  • openjpa-all-2.0.1.jar
  • serp-1.13.1.jar
Then you need to go into your Netbeans project, right click and go to properties, go to Libraries and click the SmartFoxServer library and remove everything except sfs2x.jar and sfs2x-core.jar and hit OK.

Then Add Library... and look for Hibernate JPA and add that.

You will need to go into Entities/META-INF/persistence.xml and change the dropdown from EclipseLink to Hibernate.

Rebuild your projects, copy over META-INF to [SmartFoxInstallDir]/SFS2X/META-INF, copy the new Entities.jar to [SmartFoxInstallDir]/SFS2X/lib and copy over the Extension.jar to [SmartFoxInstallDir]/SFS2X/extension/[GameName]Extension and reboot your sfs2x-service service. Lastly copy all the jars in [GameName]Extension/dist/lib to [SmartFoxInstallDir]/SFS2X/lib.

This will get you out of OpenJPA and into Hibernate and will save you a few hours of headaches.

Remember, you can find the latest code over at my github open repository: https://github.com/dragagon/AegisBorn

No comments: