users@glassfish.java.net

app scoped resources

From: <forums_at_java.net>
Date: Tue, 17 Jan 2012 20:25:48 -0600 (CST)

I have an app running in GF that use jdbc to a mysql db. My
jdbc-connection-pool and jdbc-resource are defined in domain.xml of the
domain I use. It works fine for quite sometimes now. In fact the pool and the
db is being used by a single app in GF. So I moved jdbc-connection-pool and
jdbc-resource to glassfish-resources.xml and checked that NB had correctly
put it in the meta-info folder. Here is my glassfish-resources.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server
9.0 Resource Definitions //EN"
"http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd [1]">
<resources>
    <jdbc-connection-pool connection-validation-method="auto-commit"
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
res-type="javax.sql.DataSource" wrap-jdbc-objects="false" name="mysqlPool">
      <property name="databaseName" value="myDB"></property>
      <property name="serverName" value="myServer"></property>
      <property name="User" value="root"></property>
      <property name="Password" value="myPasswd"></property>
      <property name="URL"
value="jdbc:mysql://myServer:3306/myDB"></property>
      <property name="portNumber" value="3306"></property>
      <property name="driverClass"
value="com.mysql.jdbc.Driver"></property>
    </jdbc-connection-pool>
    <jdbc-resource pool-name="mysqlPool"
jndi-name="testingPU"></jdbc-resource>
</resources>
But then my app failed to deploy with the following stacktrace:

[#|2012-01-17T18:26:54.319+0800|SEVERE|glassfish3.1.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=20;_ThreadName=Thread-2;|Exception
while preparing the app : Invalid resource : testingPU__pm
java.lang.RuntimeException: Invalid resource : testingPU__pm
 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
org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:290)
 at
org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:86)
 at
org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:141)
 at
org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:138)
 at
org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:215)
 at
org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:224)
 at
org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:250)
 at
org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:138)
 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:662)
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:
Invalid resource : testingPU__pm
 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)
 ... 48 more
 

Appreciate any help on how to make it works as application scoped resources.


[1] http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd

--
[Message sent by forum member 'senderj']
View Post: http://forums.java.net/node/882770