users@jersey.java.net

How to use PersistenceContext inside of Jersey Resource inside of GlassFish v2?

From: Markus Karg <karg_at_quipsy.de>
Date: Wed, 2 Jul 2008 10:34:42 +0200

Sorry for cross-posting, but I do not know what is the better mailing
list for this issue.

I have written a Jersey Resource that is using JPA to access a database.
It works pretty well when running it as a standalone
micro-HTTP-container.

Now I have migrated my solution to be a .war file running inside of
GlassFish v2. For that, I added jersey 0.8 JARs in the /lib subfolder of
my .war file. Jersey itself and my resource are both working well inside
of GlassFish v2 now -- but not the JPA access.

When I run verifier.bat, it tells me that there is no persistence unit
found! But in the .war in META-INF there is a persistence.xml file, and
it is a correct one as you can see in the attachment (we use the same
file in another EAR and it works well there).

Test Name : tests.web.PUMatchingEMandEMFRefTest
Test Assertion : For every entity manager referenced in the application,
there must be a matching persistence unit defined using META-INF/per
sistence.xml file. Please refer to EJB 3.0 Persistence API Specification
section #6.2 for further information.
         Test Description : For [ QUIPSY ]
There is no unique persistence unit found by name [ QUIPSY ] in the
scope of this component.
Persistence units that are visible to this component are [ ].

What is my fault and how to fix that?

Thanks
Markus