openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boblitz John <John.Bobl...@BERTSCHI.com>
Subject AW: OpenJPA transactions
Date Wed, 28 Mar 2012 06:33:40 GMT
 

> -----Ursprüngliche Nachricht-----
> Von: javidelgadillo [mailto:jdelgadillo@esri.com] 
> Gesendet: Mittwoch, 28. März 2012 02:57
> An: users@openjpa.apache.org
> Betreff: OpenJPA transactions
> 
> I've been banging my head against a wall for well over a week 
> trying to get this to work.  So now I'm coming to the experts 
> for help.
> 
> I've got Karaf 2.2.5, OpenJPA 2.2.0, and Aries 0.3 installed. 
>  I've got an entity configured  via the persistence.xml.  The 
> DataSources are loaded and a connection to the DB is 
> acquired.  But when I call
> em.getTransaction().begin() the whole hing blows up.  It 
> seems I'm winding up with the default JTAEntityManager that 
> doesn't support Transacations, but attempts to set the 
> TransactionManager via the properties section in the 
> persistence.xml file aren't working.
> 
> Any ideas on what I'm doing wrong?
> 
>  My 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="metadataPersistenceUnit"
> 		transaction-type="JTA">
> 		<description>Persistence unit for Metadata</description>
> 
> 	
> <provider>org.apache.openjpa.persistence.PersistenceProviderIm
> pl</provider>
> 
> 	
> <jta-data-source>osgi:service/javax.sql.XADataSource/(osgi.jnd
> i.service.name=jdbc/jta)</jta-data-source>
> 	
> <non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.j
> ndi.service.name=jdbc/nojta)</non-jta-data-source>
> 
> 		<class>MetadataEntity</class>
> 		
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
> 		<properties>
> 			<property name="openjpa.Log" 
> value="DefaultLevel=TRACE" />
> 			<property 
> name="openjpa.RuntimeUnenhancedClasses" value="unsupported" />
> 			<property 
> name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
> 			<property 
> name="openjpa.TransactionMode" value="managed"/>
> 			<property name="openjpa.ManagedRuntime"
> value="jndi(TransactionManagerName=osgi:service/javax.transact
> ion.TransactionManager)"/>
> 		</properties>
> 		
> 	</persistence-unit>
> </persistence>
> 
> Here's the stack trace I get when trying to persist an Entity 
> to the DB:
> Caused by: java.lang.IllegalStateException: Transaction 
> management is not available for container managed EntityManagers
>         at
> org.apache.aries.jpa.container.context.transaction.impl.JTAEnt
> ityManager.getTransaction(JTAEntityManager.java:244)
>         at xxx.xxx.xxx.xxx(MetadataDAOImpl.java:65)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)[:1.6.0_17]
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
> orImpl.java:39)[:1.6.0_17]
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
> odAccessorImpl.java:25)[:1.6.0_17]
>         at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_17]
>         at
> org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler
> .java:50)
>         at
> org.apache.aries.blueprint.proxy.Collaborator.invoke(Collabora
> tor.java:91)
>         at
> org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
>         at xxx.xxx.xxx(Unknown Source)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)[:1.6.0_17]
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
> orImpl.java:39)[:1.6.0_17]
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
> odAccessorImpl.java:25)[:1.6.0_17]
>         at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_17]
>         at
> org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler
> .java:50)
>         at
> org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapp
> er.java:31)
>         at
> org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
>         at $Proxy33.saveNewMetadatas(Unknown Source)
> 
> 
> 
> 
> --
> View this message in context: 
> http://openjpa.208410.n2.nabble.com/OpenJPA-transactions-tp741
> 1924p7411924.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 


Maybe you need:

	<persistence-unit name="metadataPersistenceUnit" transaction-type="RESOURCE_LOCAL">

Instead of 

      <persistence-unit name="metadataPersistenceUnit" transaction-type="JTA">

 

John

---- 

Who is General Failure, and why is he reading my hard disk?



Mime
View raw message