users@glassfish.java.net

Re: Same app twice using JPA

From: Edson Carlos Ericksson Richter <edson.richter_at_mgrinformatica.com.br>
Date: Wed, 20 Jun 2007 17:12:11 -0300

I getting things clear.
Scenario is:

I have one server, and need to deploy same application twice, but one
should not access database information from another.
So, when I "build" application on NetBeans, I have a custom ANT build
step that changes all .XML files to point to correct database - but I
would not change .java files (where PU is defined).

About point 1 you highlited, I think is exactly problem I'm facing
(since I have two applications using a static PersistenceManager it's
being tied up to one classloader !?).
About point 2, my expectation is two applications having same PU name
access different databases (and have own cache - so they don't trows
ClassCastException when loading a Customer from Database).

So, the point is: is possible to load PersistenceContext from JNDI in
either Tomcat and Glassfish, so I don't need two different pieces of
code for each server?

Thanks for help!

Edson Richter



glassfish_at_javadesktop.org escreveu:
> Whether TopLink will work in your scenario or not, will depend on 2 things - your expectations and the class loader.
>
> 1. The class loader. In the same class loader, there can be only one PU with a particular name. I think there is an open issue to allow the same name but different overrides as specified in the map that you pass to Persistence.createEMF() call.
>
> 2. Expectations. Do you expect those two apps to share a PU or have their own copies? Depending on how Tomcat handles class loaders (GF uses a separate class loader for each application), you'll get a different answer to your original question.
>
> Regards,
> -marina
> [Message sent by forum member 'mvatkina' (mvatkina)]
>
> http://forums.java.net/jive/thread.jspa?messageID=223161
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
>