After much messing around, I finally have my sample EJB 3 app working, but on Glassfish!! I started off with JBoss, and may still go back to it once they decide on better handling of persistence units, and not reload/load it regardless! Too complicated for me to explain, check out these links which summarise it in depth (they speak about Seam, but refer to the same issue I’m babbling about):
http://relation.to/Bloggers/JBossAS5AndGlassFishSupportAddedToSeamgen
http://code.google.com/p/seaminaction/wiki/DeployingToJBossAS5
Basically I have a common domain-model jar which I wish to treat as a persistence unit used by both my EJB and WAR in the same EAR.
And after hours of tweaking and messing, this is my successful test output:
1
2 3 4 5 6 7 8 9 10 |
Creating...
Data Value=JustCreated!! Retrieving... Data Value=JustCreated!! Updating... Updated Data Value=JustUpdated!! Deleting... |
Ah, the joys of development. Actually that’s a pretty decent test case, it’s a servlet that’s got an EJB3 instance injected, which in turn has an EntityManager instance obtained via the JNDI name of a configured JTA XA MySQL datasource injected. What a mouthful!