2

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.

Martin Andersson
  • 14,356
  • 8
  • 77
  • 106
  • This seem similar to your problem http://stackoverflow.com/questions/6660416/glassfish-unable-to-map-datasource-jndi-name-to-portable-name-using-glassfish-w – rdcrng Mar 17 '13 at 13:01
  • Similar perhaps but not helpful. Thank you for sharing. – Martin Andersson Mar 22 '13 at 10:46
  • I have the same [problem](http://stackoverflow.com/questions/16738828/unable-create-jms-resources-in-glassfish-v3-1-2-using-glassfish-resources-xml) – Kiran Mohan May 28 '13 at 13:50

2 Answers2

0

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>

Artem
  • 161
  • 1
  • 10