users@glassfish.java.net

Application scoped resources and persistence.xml do not work together, what I

From: <forums_at_java.net>
Date: Mon, 8 Oct 2012 11:01:55 -0500 (CDT)

I've got pretty simple application packaged as ear. This application include
one ejb module, one datamodel.jar (inside lib directory which include
persistence.xml) and glassfish-resources.xml in META-INF subdirectory of ear.
Contents of persistence.xml: ... < persistence-unit
name="inventory-datamodel" transaction-type="JTA"> <
provider>org.eclipse.persistence.jpa.PersistenceProvider <
jta-data-source>java:app/jdbc/InventoryPool2 ... Contents of
glassfish-resources.xml: < resources> < jdbc-connection-pool
datasource-classname="org.postgresql.xa.PGXADataSource"
res-type="javax.sql.XADataSource" name="java:app/AppInventoryPool"
validate-atmost-once-period-in-seconds="10" > < property name="databaseName"
value="hp-inventory"/> < property name="serverName"
value="hp-inventory-stage"/> .... < jdbc-resource
pool-name="java:app/AppInventoryPool"
jndi-name="java:app/jdbc/InventoryPool2" /> Deployment of application goes
fine. But when I restart server I got following exception stack:
java.lang.RuntimeException: javax.naming.NameNotFoundException: No object
bound to name java:app/jdbc/InventoryPool2 at
org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.(PersistenceUnitInfoImpl.java:111)
at
org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:155)
at
org.glassfish.persistence.jpa.PersistenceUnitLoader.(PersistenceUnitLoader.java:120)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
at
org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168) at
com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
at
com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
... This error leads to uninitialized EJBs and other stuff (e.g. iiop
listener do not start properly). I assume that this happens because
ApplicationLoaderService invoked before ApplicationScopedResourcesManager -
i.e. resources from glassfish-resources.xml (or may be domain.xml) not yet
have been read and lookup do not return anything. I want to mention that this
problem only related to application scoped resources, NOT to globally
defined. My question is anyone know how to workaround this? (Except for
creating global resources)

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