users@glassfish.java.net

Library jar with JPA entity classes

From: <forums_at_java.net>
Date: Sun, 3 Apr 2011 08:35:28 -0500 (CDT)

Hi,

I have read in the FAQ's that one cannot share a PU across multiple
applications deployed in the EJB container. My practical experience has
indeed shown that this is error prone as the first application works fine,
but subsequent deployed EARs get errors due to the entity classes being in
different classloaders and throwing "com.xxx.yy cannot be cast to com.xx.yy"
etc.

In this light, there must be a way of achieving my use case. Here is what I
want to achieve:

- I want to create a library jar that can be used by many EJB modules, which
in turn are deployed in different EAR's (the library jar would be packagedin
the /lib directory of each EAR). I dont want a single ear containing all
theEJB's, as it would be huge and wouln't allow me to redeploy a single
component at a time. The separate ears are to be deployed to a single
Glassfish instance.

- The jar needs a persistence unit that allows it to connect to a mysql
database

- The jar has JPA entity classes for persistence

 

Is there a way I can achieve this? If I try to accomplish this now, the EMF
can be created easily enough, but it seems that its shared in a container
level classloader for all the EAR's and this causes issues when using the
entity classes (the casting issue mentioned).

 

Paul


--
[Message sent by forum member 'paulcb']
View Post: http://forums.java.net/node/788153