I am trying to follow this approach to create a data source for embedded glass fish. The only significant difference between the tutorial and my code is that I start the server using the official maven plugin and the embedded-glassfish:run target.
There is a dependency in the pom file for the JDBC driver:
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.3.155</version> </dependency>
And my glassfish-resources.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd"> <resources> <jdbc-resource enabled="true" jndi-name="jdbc/myDatasource" object-type="user" pool-name="connectionPool"> <description/> </jdbc-resource> <jdbc-connection-pool datasource-classname="org.h2.jdbcx.JdbcDataSource" name="connectionPool" res-type="javax.sql.DataSource"> <property name="URL" value="jdbc:h2:~/Documents/Projetos/DBs/h2/glassfish/glassfish;AUTO_SERVER=TRUE;MVCC=TRUE"/> <property name="User" value="sa"/> <property name="Password" value=""/> <property name="driverClass" value="org.h2.Driver"/> </jdbc-connection-pool> </resources>
It works fine using a local lake fish server. But no luck with the built-in instance:
06/03/2011 19:26:31 com.sun.enterprise.v3.server.ApplicationLifecycle deploy GRAVE: Invalid resource: JDBC / myDatasource_pm java.lang.RuntimeException: Invalid resource: jdbc / myDatasource_pm at com.sun.enterprise.connectors .ConnectorRuntime.lookupDataSourceInDAS (ConnectorRuntime.javaβ39) in com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource (ConnectorRuntime.java:468) in org.glassfish.persistence.common.PersistenceHelper.lookupPMResel. Persistj org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource (ProviderContainerContractInfoBase.java:71) in
I donβt know ... Can anyone shed light on him?
source share