users@glassfish.java.net

Re: How I can obtain the JNDI name from a DataSource in my app?

From: <glassfish_at_javadesktop.org>
Date: Wed, 28 Apr 2010 19:34:51 PDT

Regardless how the two sides are packaged, as long as they are in the same EAR, you can use classloader to getResourceAsStream(META-INF/persistence.xml) to load the current persistence.xml, and then parse it. You don't need to find it by yourself.

Other options I can think of may be a bit easier, but all involves duplicate the datasource name in other config files, which should be avoided, IMO.
[Message sent by forum member 'cf126330']

http://forums.java.net/jive/thread.jspa?messageID=399517