I'm not sure if this reflects a bug in geronimo or not.
What is happening is that, since geronimo is a managed environment,
it finds the persistence.xml and constructs the necessary objects to
set up managed EMF and EM instances that can be made available to
your app through dependency injection (using @PersistenceUnit or
@PersistenceContext annotations) or through jndi.
However, your app is using techniques appropriate to unmanaged
environments to ask openjpa to directly construct an EMF. The jta-
datasource and non-jta-datasource elements have no standard meaning
and in particular the geronimo meaning and openjpa meaning are
different.
To fix this you should use dependency injection such as
@PersistenceContext
private EntityManager entityManager;
I don't remember and don't have time to check right now what is
supposed to happen when you try to do what you are trying, that is to
get an EMF directly from Persistence in an managed environment.
thanks
david jencks
ps. I might have the annotation names wrong, they might be @*Ref.
On Mar 30, 2008, at 3:32 AM, LDevil wrote:
Hi,
I do not know what should i put in jta-data-source and non-jta-data-
source
elements in persistence.xml file.
I have created database pool with name: jdbc/postgresDS
My geronimo-web.xml file contains:
<nam:resource-ref>
<nam:ref-name>postgres</nam:ref-name>
<nam:resource-link>jdbc/postgresDS</nam:resource-link>
</nam:resource-ref>
My web.xml contains:
<resource-ref>
<description>PostgreSQL Datasource</description>
<res-ref-name>postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
When I put <non-jta-data-source>postgres</non-jta-data-source> in
persistence.xml file, following error appears during deployment:
Unable to resolve reference "NonJtaDataSourceWrapper"
...
due to: No matches for referencePatterns:
[?name=postgres#org.apache.geronimo.naming.ResourceSource]
When I changed value of <non-jta-data-source> to jdbc/postgresDS
there were
no erros during deployment, but when I run following code:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("default");
EntityManager entityManager = emf.createEntityManager();
This error apperars:
12:24:46,203 ERROR [TestDB]:281 - Servlet.service() for servlet
TestDB
threw exception
<openjpa-1.0.1-r420667:592145 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: There was an
error
duing JNDI lookup of the name "jdbc/postgresDS".
at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker
(AbstractBrokerFactory.java:205)
at
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker
(DelegatingBrokerFactory.java:142)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityMa
nager(EntityManagerFactoryImpl.java:192)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityMa
nager(EntityManagerFactoryImpl.java:145)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityMa
nager(EntityManagerFactoryImpl.java:56)
at
net.oledzki.novex.sklep2000.receiver.servlets.TestDB.doGet
(TestDB.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:175)
at
org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke
(DefaultSubjectValve.java:56)
at
org.apache.geronimo.tomcat.GeronimoStandardContext
$SystemMethodValve.invoke(GeronimoStandardContext.java:396)
at
org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke
(GeronimoBeforeAfterValve.java:47)
at
org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:109)
at
org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:563)
at
org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:263)
at
org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:844)
at
org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by:
org.apache.commons.lang.exception.NestableRuntimeException: There
was an error duing JNDI lookup of the name "jdbc/postgresDS".
at
org.apache.openjpa.lib.conf.Configurations.lookup
(Configurations.java:592)
at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.lookupConnectionFacto
ry(OpenJPAConfigurationImpl.java:966)
at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.getConnectionFactory(
OpenJPAConfigurationImpl.java:954)
at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFac
tory(JDBCConfigurationImpl.java:801)
at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInst
ance(JDBCConfigurationImpl.java:568)
at
org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration
(MappingRepository.java:1221)
at
org.apache.openjpa.lib.conf.Configurations.configureInstance
(Configurations.java:476)
at
org.apache.openjpa.lib.conf.Configurations.configureInstance
(Configurations.java:401)
at
org.apache.openjpa.lib.conf.PluginValue.instantiate
(PluginValue.java:102)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate
(ObjectValue.java:82)
at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepository
Instance(OpenJPAConfigurationImpl.java:861)
at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepository
Instance(OpenJPAConfigurationImpl.java:852)
at
org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly
(AbstractBrokerFactory.java:630)
at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker
(AbstractBrokerFactory.java:169)
... 23 more
Caused by: javax.naming.NotContextException: jdbc/postgresDS
at
org.apache.xbean.naming.context.AbstractContext.lookup
(AbstractContext.java:167)
at
org.apache.xbean.naming.context.AbstractContext.lookup
(AbstractContext.java:603)
at javax.naming.InitialContext.lookup(Unknown Source)
at
org.apache.openjpa.lib.conf.Configurations.lookup
(Configurations.java:590)
... 36 more".
...
What should I do to fix this problem?
--
Best regards,
Maciej Olędzki
--
View this message in context: http://www.nabble.com/Problem-with-
persistence.xml-%28how-to-use-data-source-%29-
tp16380414s134p16380414.html
Sent from the Apache Geronimo - Users mailing list archive at
Nabble.com.