10
votes

I am trying to run a very simple ear applicaiton . i seem to run into exactly this issue but the discussions here dont work for me JDBC resource name being modified by container (__pm being appended to it)

In my case also the datasource name is being appened by __pm. I have no clue where it comes from but the server logs point to the fact that instead of searching for databasename it searches for databasename__pm and fails the deployment.

Persistence.xml :-

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="FCK-ejbPU" transaction-type="JTA">
    <jta-data-source>FCKDatabase</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties/>
  </persistence-unit>
</persistence>

Glassfish logs :

  Error occurred during deployment: Exception while preparing the app : Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/FCKDatabase__pm), (applicationName=FCK) }. Please see server.log for more details.
        Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method : java.lang.RuntimeException: Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/FCKDatabase__pm), (applicationName=FCK) }
        Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/FCKDatabase__pm), (applicationName=FCK) }

As you can see my the JNDI name of my resources is appened with __pm.

Also on the Glassfish server console the resource is correctly shown as FCKDatabase and not FCKDatabase_pm

Any idea where this __pm comes from ?

System:

  • Netbeans 7.3
  • Glassfish Server 3.1.2
4

4 Answers

6
votes

The problem was that the mysql connector jar file was not placed into the glassfish server. This kicks in a series of problems. The one that I posted above is just one of the error messages that the server logs contains. I suggest going through the entire list of error message and try to debug from there. The following link helped me place the jar files at the correct location:

2
votes

Since Netbeans 7.1 when the IDE generates the persistence.xml the jta field and glassfish-resouces JDNI name is generated with a prefix java:module/, it has to be deleted in both files, it has to look like jdbc/[anyName]. This was tested on Netbeans 8.1 and Glassfish 4.0.

In the image, the second option shows the generated name, which is invalid en Glassfish because the ':'

0
votes

Here is another solution which I have found, it will be helpful to anyone.

Copy the resource name which you are facing the problem and follow the below steps.

  1. Login into Glassfish console
  2. Goto Resources
  3. JDBC --> JDBC Resources
  4. Click on New button to add resource
  5. Enter the copied resource into JNDI name field and select the pool name and enter the description.
  6. Click on Ok button

Redeploy the application and check.

0
votes

In my case I just moved my glassfish-resources.xml file,

from:

my_web_app / src / main / webapp / WEB-INF

to:

my_web_app / src / main / setup

And GlassFish started to recognize the file the created the resources.