users@glassfish.java.net

RE: JNDI datasource names and persistence.xml

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Fri, 7 Aug 2009 08:10:18 -0400

with jboss-seam-2.0.2.SP1 add META-INF to basefolder e.g.
basefolder/META-INF/persistence.xml

thanks for the insightful info
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Fri, 7 Aug 2009 15:52:47 +0530
> From: Sahoo_at_Sun.COM
> To: users_at_glassfish.dev.java.net
> Subject: Re: JNDI datasource names and persistence.xml
>
> Thanks for the detailed description of how you have managed to work
> around the issue in your build environment. Sounds good to me.
>
> Sahoo
>
> glassfish_at_javadesktop.org wrote:
> > Hi Sahoo,
> >
> > Thanks for the reply. I like your blog. I was looking at the EE6 stuff earlier today and can't wait for JNDI improvements.
> >
> > I eventually set up some maven profiles to deal with my issue since it's not for production and a quick hack seems to do what I need. Mainly I don't want to be editing persistence.xml every time I want to try a different application server. I'll post the relevant portions of my maven configuration below in case it's helpful to anyone else.
> >
> > I use a standard maven layout for my jpa module:
> >
> > [code]
> > module-name
> > src
> > main
> > java
> > resources
> > [/code]
> >
> > I added two non-standard directories; one for glassfish and one for jboss. Each contains a vendor specific persistence.xml file:
> >
> > [code]
> > module-name
> > src
> > main
> > java
> > resources
> > glassfish-resources
> > META-INF
> > persistence.xml
> > jboss-resources
> > META-INF
> > persistence.xml
> > [/code]
> >
> > Then I added two profiles to the pom.xml for my jpa module:
> >
> > [code]
> > <profiles>
> > <profile>
> > <id>glassfish</id>
> >
> > <!-- Setting activeByDefault makes this the default profile if no profile is selected -->
> > <activation>
> > <activeByDefault>true</activeByDefault>
> > </activation>
> >
> > <build>
> > <resources>
> >
> > <!-- Normal Resources -->
> > <resource>
> > <directory>src/main/resources</directory>
> > </resource>
> >
> > <!-- Glassfish specific persistence resources -->
> > <resource>
> > <directory>src/main/glassfish-resources</directory>
> > </resource>
> > </resources>
> > </build>
> > </profile>
> >
> > <profile>
> > <id>jboss</id>
> > <activation>
> > <!--
> > If the system property 'env_jboss' is set then this profile will be activated
> > rather than the default. In IntelliJ IDEA 9 I had to ensure the variable was
> > given an arbitrary value to ensure it was set for the build. IDEA allows you
> > to set system properties in:
> >
> > Project > Settings > Maven > Runner
> > -->
> > <property>
> > <name>env_jboss</name>
> > </property>
> > </activation>
> >
> > <build>
> > <resources>
> >
> > <!-- Normal Resources -->
> > <resource>
> > <directory>src/main/resources</directory>
> > </resource>
> >
> > <!-- JBoss specific persistence resources -->
> > <resource>
> > <directory>src/main/jboss-resources</directory>
> > </resource>
> > </resources>
> > </build>
> > </profile>
> > </profiles>
> > [/code]
> >
> > If you run maven normally you'll get the default build profile which uses the Glassfish specific persistence.xml:
> >
> > [code]
> > mvn clean package
> > [/code]
> >
> > If you set the 'env_jboss' property you'll get the jboss profile which uses the JBoss specific persistence.xml:
> >
> > [code]
> > mvn -Denv_jboss=true clean package
> > [/code]
> >
> > The value for 'env_jboss' doesn't matter. It just needs to get set. Even if you build from a parent module (which I do), the profiles will work. It's more than likely someone can come up with a fancier setup that names files differently etc, but this is a quick fix that worked for me. I simply cloned the config on my build server and added the -Denv_jboss property to the cloned configuration.
> > [Message sent by forum member 'jptech' (jptech)]
> >
> > http://forums.java.net/jive/thread.jspa?messageID=359373
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

_________________________________________________________________
Express your personality in color! Preview and select themes for Hotmail®.
http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_express:082009