OK, moved glassfish-resources.xml to ear-root/META-INF. I now receive an
Invalid Resource error when the .ear file deploys, specifically (I think)
when the persistence archive tries to connect to the
<jta-data-source>that--hopefully--references the app-scoped resource I
was supposed to have
created.
My resources file:
<?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-connection-pool name="JXConnectionPool"
res-type="javax.sql.ConnectionPoolDataSource"
datasource-classname="org.h2.jdbcx.JdbcDataSource" pool-resize-quantity="2"
max-pool-size="6" steady-pool-size="2" statement-timeout-in-seconds="60" >
<property name="serverName" value="localhost" />
<property name="User" value="sa" />
<property name="Password" value="" />
<property name="URL" value="jdbc:h2:\${user.home}/jxdb" />
</jdbc-connection-pool>
<jdbc-resource jndi-name="java:app:/jdbc/jx" pool-name="JXConnectionPool"
/>
</resources>
(Looking at it, I probably don't need the serverName property...)
Then my persistence.xml references this like so:
<jta-data-source>java:app:/jdbc/jx</jta-data-source>
What have I done wrong?
The invalid resource error looks like this:
[#|2011-08-22T14:35:01.751-0400|SEVERE|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=18;_ThreadName=Thread-3;|Invalid
resource : { ResourceInfo : (jndiName=java:app:/jdbc/jx__pm),
(applicationName=my-ear-1.0-SNAPSHOT) }
java.lang.RuntimeException: Invalid resource : { ResourceInfo :
(jndiName=java:app:/jdbc/jx__pm), (applicationName=my-ear-1.0-SNAPSHOT) }
at
com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:540)
at
com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:469)
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:154)
at
org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:119)
at
org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:214)
at
org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:483)
at
org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:221)
at
org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:167)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:872)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:680)
Caused by:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid
resource : { ResourceInfo : (jndiName=java:app:/jdbc/jx__pm),
(applicationName=my-ear-1.0-SNAPSHOT) }
at
com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.validateResource(ConnectorResourceAdminServiceImpl.java:274)
at
com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.setResourceInfo(ConnectorResourceAdminServiceImpl.java:255)
at
com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.lookupDataSourceInDAS(ConnectorResourceAdminServiceImpl.java:245)
at
com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:538)
... 39 more
--
http://about.me/lairdnelson