Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

DataSourceDefinition doesn't work within a Junit test,

 
Rudy Estrada
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I have an application that's working fine,

MAC OSX 10.11.6
Netbeans 8.1
GlassFish Server 4.1.1
MySQL

However:

When I create a Unit test with the following datasourcedefinition:



I get the following error while running the test:

=======

Aug 16, 2016 10:40:33 AM com.sun.enterprise.v3.server.ApplicationLifecycle deploy
SEVERE: Exception during lifecycle processing
java.lang.RuntimeException: Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/ms__pm), (applicationName=classes) }
at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:593)
at com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:517)
at org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
at org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)
at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:108)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:142)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107)

==========

Here is my persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="MeetingServicesPU" transaction-type="JTA">
    <jta-data-source>java:app/jdbc/ms</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>
    </properties>
  </persistence-unit>
</persistence>

=======

If I create a Resource with the name jndiName=java:app/jdbc/ms__pm

I still have the same problem,

Thank you,
 
Rudy Estrada
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed that in the build, at build/web/WEB-INF/classes/META-INF/persistence.xml
It had  <jta-data-source>jdbc/ms__pm</jta-data-source>

I removed the __pm and it worked.

I am not sure why the deploy inserts " __pm " to the jta-data-source.

- RE
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!