Hello David,
Thanks for helping out. Following yout e-mail:
1) I've fixed the problem by using "SystemDatasource" (not
SystemDatabse) as the name.
2) I don't really care whether Geronimo uses JNDI or not internally. I
need to register the JPA persistence context in my web application's
JNDI context, as I am using Spring which expects to be able to look it
up via JNDI (using <jee:jndi-lookup .../> if you're familiar with
Spring). So I need the reference in web.xml for my own purposes. Anyway,
it works now so this has been resolved.
3) I don't really intend to use Derby; I was just taking things
step-by-step. Having said that, how do I define my own datasource in
Geronimo? For example, in JBoss you use a "somename-ds.xml" file to
register a datasource.
On 12/2/2010 8:20 μμ, David Jencks wrote:
Geronimo doesn't use jndi for the datasources in persistence.xml. You
don't need to configure resource-refs for the datasources. You do
need to make sure they are in ancestor plugins to the app and that you
use the name from the datasource configuration. In this case I think
that would be
<jta-data-source>SystemDatabase</jta-data-source>
In my experience, at least with derby, you need both jta and non-jta
datasource. I guess if you aren't using jta transactions at all you
might be able to use just a non-jta-data-source, but I haven't tried
this.
thanks
david jencks
On Feb 12, 2010, at 6:53 AM, Alexandros Karypidis wrote:
Hello,
My scenario is this:
I have a library with entities (as in @Entity objects) containing my
domain model. I want to declare a container-managed persistence unit
in a standalone WAR (not EAR), using that library (the
persistence.xml must NOT be in the library, but the WAR). So, I
proceed as follows (this is valid as far as I know, base on J2EE5
specs):
1) I have declared a data source in geronimo-web.xml and web.xml (see
below for file contents).
2) I put my library (as a jar) in my WAR's WEB-INF/lib and added a
WEB-INF/classes/META-INF/persistence.xml in the WAR (see below for
file contents).
Deployment after performing step (1) worked and I could see the data
source registered in the console.
Deployment after performing step (2) fails; from what I understand
from the error (see below), geronimo claims the data-source from step
(1) does not exist. I assume that geronimo tries to create the
persistence context prior to registering the data source? (i.e. it
processes persistence.xml prior to apply the configuration from
web.xml and geronimo-web.xml).
What do I need to configure this properly. My deployment descriptors
and the error trace follow:
persistence.xml
-------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="appPersistenceUnit" transaction-type="JTA">
<jta-data-source>jdbc/AppDataSource</jta-data-source>
<jar-file>app-entities.jar</jar-file>
</persistence-unit>
</persistence>
web.xml
-------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.4">
<display-name>App</display-name>
<!-- Unrelated Spring contextListener and Wicket filter configuration
here
have been supresed -->
<resource-ref>
<res-ref-name>jdbc/AppDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<!--
Ultimately I want to do this, but I can't get persistence.xml to
work...
<persistence-unit-ref>
<persistence-unit-ref-name>persistence/appPersistenceUnit</persistence-unit-ref-name>
<persistence-unit-name>appPersistenceUnit</persistence-unit-name>
</persistence-unit-ref>
-->
</web-app>
geronimo-web.xml
-------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
<sys:environment>
<sys:moduleId>
<sys:groupId>app</sys:groupId>
<sys:artifactId>app-frontend</sys:artifactId>
<sys:version>0.0.1</sys:version>
<sys:type>car</sys:type>
</sys:moduleId>
<sys:dependencies>
<!-- Need the embedded Derby -->
<sys:dependency>
<sys:groupId>org.apache.geronimo.configs</sys:groupId>
<sys:artifactId>
system-database
</sys:artifactId>
</sys:dependency>
</sys:dependencies>
</sys:environment>
<context-root>/app</context-root>
<!-- Ultimately, I want to register the PU in JNDI,
but persistence.xml does not work
<naming:persistence-unit-ref>
<naming:persistence-unit-ref-name>persistence/appPersistenceUnit</naming:persistence-unit-ref-name>
<naming:persistence-unit-name>persistence/appPersistenceUnit</naming:persistence-unit-name>
</naming:persistence-unit-ref>
-->
<naming:resource-ref>
<naming:ref-name>jdbc/AppDataSource</naming:ref-name>
<naming:resource-link>SystemDatasource</naming:resource-link>
</naming:resource-ref>
</web-app>
__________________________________________________
Χρησιμοποιείτε Yahoo!;
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail διαθέτει
την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων
http://mail.yahoo.gr