openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miłosz <mtyle...@o2.pl>
Subject Re: Re: Confused about why Im getting this error
Date Wed, 20 Jan 2010 20:03:42 GMT
Thomas,

When you run your application in JSE, that is, outside an application server, you usually
should configure the persistence.xml to use entity manager transactions instead of JTA. Please
change "transaction-type" attribute like below and see whether anything changed:

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

Cheers,
Milosz


> persistence.xml
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0" 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">
> 	<persistence-unit name="ExampleJPA" transaction-type="JTA">
> 		<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> 		<class>com.trukoda.examples.jpa.Account</class>
> 		<class>com.trukoda.examples.jpa.Host</class>
> 		<properties>
> 		<!-- 
> 			<property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver"/>
> 			<property name="openjpa.ConnectionURL" value="jdbc:hsqldb:file:/tmp/JPA-Test" />
> 			<property name="openjpa.ConnectionUserName" value="sa" />
> 			<property name="openjpa.ConnectionPassword" value="" />
> 			<property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO,
SQL=TRACE
> Runtime=INFO, Tool=INFO, SQL=TRACE"/>
> 		-->
> 			<property name="openjpa.ConnectionURL" value="jdbc:derby:build/openjpa-database;create=true"/>
>             <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
>             <property name="openjpa.ConnectionUserName" value="user"/>
>             <property name="openjpa.ConnectionPassword" value="secret"/>
> 
> 		</properties>
> 	</persistence-unit>
> 	
> </persistence>
> 
> 
> Thanks for looking at this.
> 
> Thomas
> On Jan 19, 2010, at 4:54 PM, Miłosz Tylenda wrote:
> 
> > Thomas,
> > 
> > Can you check or post your persistence.xml? Maybe you configured your ExampleJPA
persistence unit to use JTA transactions instead of entity manager (RESOURCE_LOCAL) transactions.
> > 
> > Greetings,
> > Milosz
> > 
> >> I am not running this from an IDE.  Command line using ant for  
> >> compiles and enhancement but not to run the main doing that by hand
> >> 
> >> Thanks for looking at my issue
> >> Thomas
> >> 
> >> Sent from my iPhone
> >> 
> >> On Jan 19, 2010, at 5:20, Jean-Baptiste BRIAUD -- Novlog <j-b.briaud@novlog.com

> >>> wrote:
> >> 
> >>> Maybe a classpath issue in the IDE project's config ?
> >>> 
> >>> On Jan 18, 2010, at 02:15 , Thomas Polliard wrote:
> >>> 
> >>>> Doing an example trying to learn OpenJPA and JPA I ran into a  
> >>>> strange problem.
> >>>> 
> >>>> java.lang.ClassNotFoundException:  
> >>>> com.arjuna.jta.JTA_TransactionManager
> >>>> java.lang.ClassNotFoundException:  
> >>>> com.bluestone.jta.SaTransactionManagerFactory
> >>>> java.lang.ClassNotFoundException: org.openejb.OpenEJB
> >>>> java.lang.ClassNotFoundException:  
> >>>> com.sun.jts.jta.TransactionManagerImpl
> >>>> java.lang.ClassNotFoundException:  
> >>>> com.inprise.visitransact.jta.TransactionManagerImpl
> >>>> 
> >>>> 
> >>>> I am not using "Any of these yet for some reason, I am getting this
 
> >>>> error"
> >>>> 
> >>>> The problem is Only when I run the main program:
> >>>> 
> >>>> Main.java
> >>>> package com.trukoda.examples.jpa;
> >>>> 
> >>>> import javax.persistence.EntityManager;
> >>>> import javax.persistence.EntityManagerFactory;
> >>>> import javax.persistence.Persistence;
> >>>> 
> >>>> public class Main {
> >>>>   public static void main(String[] args) {
> >>>>       EntityManagerFactory factory =  
> >>>> Persistence.createEntityManagerFactory("ExampleJPA");
> >>>>       Account user1 = new Account("polliard");
> >>>>       Account user2 = new Account("mcclung");
> >>>> 
> >>>>       Host host1 = new Host("uranium");
> >>>>       Host host2 = new Host("thorium");
> >>>> 
> >>>>       EntityManager em = factory.createEntityManager();
> >>>> 
> >>>>       em.getTransaction().begin();
> >>>>       em.persist(host1);
> >>>>       em.persist(host2);
> >>>>       em.getTransaction().commit();
> >>>>   }
> >>>> }
> >>>> 
> >>>> Any idea why this this would causes classes I am not referencing  
> >>>> from being loaded.
> >>>> 
> >>>> I am including the following in my classpath:
> >>>> 
> >>>> .:/Users/polliard/Library/Java/Derby/10.5.3.0/derby.jar:/Users/ 
> >>>> polliard/Library/Java/Openjpa/2.0-M3/openjpa-all-2.0.0-M3.jar
> >>>> 
> >>>> The two accounts (Account and Host) are basic Entities and the  
> >>>> database gets created without issue using the mappingtool.
> >>>> 
> >>>> Thanks for any assistance,
> >>>> 
> >>>> Thomas
> >>> 
> >> 
> 


Mime
View raw message