Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SEVERE: java.lang.RuntimeException: Invalid resource :

 
Stanley Akudinobi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day every body!

I recently encountered a deployment error on my Glass Fish Server while trying to deploy my application.
Intially I configured the database( mysql) in my platform (Netbeans) on the Java EE through JNDI i.e I Right Clicked Source Package/New/Entity Classes from Database/Data Source/New Data/Database Connection → jdbc:mysql………/JNDI Name → (jdbc/zoodatabase)/Ok.

When I deployed the application, I got the following info:

1) ON MY RUN(APP) I GOT THE RESULT BELOW

NetBeans: Deploying on GlassFish Server 4
profile mode: false
debug mode: false
force redeploy: true
In-place deployment at C:\Users\user\Documents\NetBeansProjects\MyApp\target\classes
GlassFish Server 4, deploy, null, false

cd C:\Users\user\Documents\NetBeansProjects\MyApp; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.7.0_40" cmd /c "\"\"C:\\Program Files\\NetBeans 8.0\\java\\maven\\bin\\mvn.bat\" -Dnetbeans.deploy=true -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.0\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 package\""
Scanning for projects...

Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1

------------------------------------------------------------------------
Building MyApp 1.0-SNAPSHOT
------------------------------------------------------------------------

--- maven-dependency-plugin:2.6:copy (default) @ MyApp ---

--- maven-resources-plugin:2.6:resources (default-resources) @ MyApp ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 2 resources

--- maven-compiler-plugin:3.1:compile (default-compile) @ MyApp ---
Nothing to compile - all classes are up to date

--- maven-resources-plugin:2.6:testResources (default-testResources) @ MyApp ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\Users\user\Documents\NetBeansProjects\MyApp\src\test\resources

--- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MyApp ---
No sources to compile

--- maven-surefire-plugin:2.12.4:test (default-test) @ MyApp ---

--- maven-ejb-plugin:2.3:ejb (default-ejb) @ MyApp ---
Building EJB MyApp-1.0-SNAPSHOT with EJB version 3.1
Building jar: C:\Users\user\Documents\NetBeansProjects\MyApp\target\MyApp-1.0-SNAPSHOT.jar
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 46.828 s
Finished at: 2014-05-09T04:05:49-08:00
Final Memory: 8M/21M
------------------------------------------------------------------------
NetBeans: Deploying on GlassFish Server 4
profile mode: false
debug mode: false
force redeploy: true
In-place deployment at C:\Users\user\Documents\NetBeansProjects\MyApp\target\classes
GlassFish Server 4, deploy, null, false

2) ON MY GLASS FISH SERVER I GOT THIS ERROR REPORT

SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: Exception during lifecycle processing


java.lang.RuntimeException: Invalid resource : jdbc/zoodatabase__pm
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)
atorg.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)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
atorg.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)

SEVERE: java.lang.RuntimeException: Invalid resource : jdbc/zoodatabase__pm

Atcom.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:593)
Atcom.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:517)
atorg.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
atorg.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)
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : jdbc/zoodatabase__pm

SEVERE: Exception while preparing the app : Invalid resource : jdbc/zoodatabase__pm

com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : jdbc/zoodatabase__pm
at org.glassfish.jdbcruntime.service.JdbcDataSource.validateResource(JdbcDataSource.java:81)
at org.glassfish.jdbcruntime.service.JdbcDataSource.setResourceInfo(JdbcDataSource.java:62)
atorg.glassfish.jdbcruntime.JdbcRuntimeExtension.lookupDataSourceInDAS(JdbcRuntimeExtension.java:136)
atcom.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:589)
at com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:517)
at org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)

INFO: visiting unvisited references
INFO: visiting unvisited references

SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
SEVERE: java.lang.RuntimeException: Invalid resource : jdbc/zoodatabase__pm


Atcom.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)
atorg.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

SEVERE: Exception while preparing the app
SEVERE: Exception during lifecycle processing


java.lang.RuntimeException: Invalid resource : jdbc/zoodatabase__pm
atcom.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)
atorg.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)

SEVERE: Exception while preparing the app : Invalid resource : jdbc/zoodatabase__pm

com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : jdbc/zoodatabase__pm
at org.glassfish.jdbcruntime.service.JdbcDataSource.validateResource(JdbcDataSource.java:81)
at org.glassfish.jdbcruntime.service.JdbcDataSource.setResourceInfo(JdbcDataSource.java:62)
atorg.glassfish.jdbcruntime.JdbcRuntimeExtension.lookupDataSourceInDAS(JdbcRuntimeExtension.java:136)
atcom.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:589)at com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:517)

I would be grateful if someone can proffer solutions to the above challenge and at the same time educate me on how to create data source on Glass Fish Server manually using admin console.

Best regards!



 
K. Tsang
Bartender
Posts: 3502
14
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Creating JDBC resource in Glassfish is pretty simple. I'm using Glassfish v3 to illustrate:

1. Create a JDBC connection pool = new -> type in the name (eg MySQLPool) and choose "javax.sql.DataSource" for resource type and chose "MySQL" for driver vendor then click Next
2. Under the properties section, enter the server, user and password and character encoding (eg UTF-8). Leave out the database name. If you want to test it, select Ping checkbox. Click Finish.

Note: If you plan to have one pool for each database then do enter the database name above in step 2 and specific user/password for that db and give a more specific name in step 1

Then create the actual jdbc resource

1. enter the name eg jdbc/<dbname>
2. choose the newly created pool name
3. add property "DatabaseName"

Voila. Now if I haven't missed anything, you should just able to lookup the "jdbc/<dbname>" through JNDI.

Hope this helps.
 
Stanley Akudinobi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot T.Ksang!

I actually implemented your strategies and it did work for me.

Once again i'm gratful!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic