2
votes

The glassfish docs says:

An application-scoped resource is defined in the glassfish-resources.xml deployment descriptor file. This file is placed in the META-INF directory of the module or application archive.

However, it does not seem to be the case. When I do, and deploy the .jar file to my Glassfish 3.1.2 server, he throws a couple of exceptions, and says:

Exception while preparing the app : Invalid resource : jdbc/malivechat-db-ds__pm

The JNDI name of my resource is actually "jdbc/malivechat-db-ds". So I do not understand where the underscore "__pm" comes from (?). However, if I add my resources separately, say I do this through the admin console or let Netbeans deploy the package for me, all works just fine.

Is there no way to bundle the glassfish-resources.xml file with our distributed .jar file?

The way I see it, it just have to be. Although adding resources seems to be application server specific (why? I mean why "glassfish-resources.xml" and not just "resources.xml"?), surely there should be a way to add all vendor specific *-resources.xml file to our .jar file and thus "support" a set of different application servers?

Either way, doing it the way glassfish docs says does not seem to work, or I've got something completely wrong.

2
This seem similar to your problem stackoverflow.com/questions/6660416/… - rdcrng
Similar perhaps but not helpful. Thank you for sharing. - Martin Andersson
I have the same problem - Kiran Mohan

2 Answers

0
votes

I had the same problem. I solved it by specifying JNDI application namespace in my resource name. Try to change JNDI resource name in glassfish-resources.xml to something like this: jndi-name="java:app/malivechat-db-ds"

and lookup your resource with same syntax. For example in persistence.xml:

<jta-data-source>java:app/malivechat-db-ds</jta-data-source>