geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Ljuba" <lju...@gmail.com>
Subject Re: @GeneratedValue(strategy = GenerationType.TABLE... : org.apache.openjpa.persistence.PersistenceException: The Transaction Synchronization Registry can not suspend the current transaction
Date Thu, 04 Dec 2008 09:35:17 GMT
Thank you for reply,
persistence.xml -s are same but with only one difference
transaction-type="JPA" and transaction-type="RESOURCE_LOCAL".
I tried to change this property for geronimo (JPA -> RESOURCE_LOCAL) but
same error is shown, and if I change in test persistence.xml (RESOURCE_LOCAL
-> JPA) then I got this error.

org.springframework.transaction.CannotCreateTransactionException: Could not
open JPA EntityManager for transaction; nested exception is
<openjpa-1.2.0-r422266:683325 fatal user error>
org.apache.openjpa.persistence.InvalidStateException: Could not perform
automatic lookup of EJB container's javax.transaction.TransactionManager
implementation. Please ensure that you are running the application from
within an EJB 1.1 compliant EJB container, and then set the
org.apache.openjpa.ManagedRuntime property to

Geronimo persistence.xml:
 /xxx-core-internal/src/main/resources/META-INF/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" version="1.0"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

    <persistence-unit name="xxx" transaction-type="JPA">
        <description>ContainerManagedJPA</description>

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>xxx</jta-data-source>
        <class>net.xxx.persistenceTest.probnaTabela.ProbnaTabela1</class>
        <class>net.xxx.persistence.counter.Counter</class>
        <class>net.xxx.persistence.counter.CounterId</class>

        <exclude-unlisted-classes>true</exclude-unlisted-classes>

        <properties>
            <!-- DBDictionary has a boolean property - storeCharsAsNumbers,
the default is true. -->
            <!-- link with solution:
http://www.gg3721.com/list/42/164023.html -->
            <!-- stack trace: java.sql.SQLException: The value supplied
cannot be converted to INTEGER. -->
            <!-- place made problem: at
org.apache.openjpa.jdbc.sql.DBDictionary.getInt(DBDictionary.java:653)
                                     at
org.apache.openjpa.jdbc.sql.DBDictionary.getChar(DBDictionary.java:555) -->
            <!-- openjpa code made problem: if (storeCharsAsNumbers) return
(char) getInt(rs, column); -->
            <property name="openjpa.jdbc.DBDictionary"
value="storeCharsAsNumbers=false"/>
            <property name="openjpa.jdbc.SynchronizeMappings" value="false"
/>
            <property name="openjpa.Log" value="SQL=TRACE"></property>
            <property name="openjpa.ConnectionFactoryProperties"
                value="PrettyPrint=true,
PrettyPrintLineLength=72"></property>
            <!--<property name="openjpa.InitializeEagerly"
value="true"></property>-->

        </properties>
    </persistence-unit>


Unitils test persistence.xml:
/xxx-core-internal/src/test/resources/META-INF/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="xxx" transaction-type="RESOURCE_LOCAL">
        <description>ContainerManagedJPA</description>

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

        <jta-data-source>xxx</jta-data-source>
        <class>net.xxx.persistenceTest.probnaTabela.ProbnaTabela1</class>
        <class>net.xxx.persistence.counter.Counter</class>
        <class>net.xxx.persistence.counter.CounterId</class>
               <exclude-unlisted-classes>true</exclude-unlisted-classes>

        <properties>
            <!-- DBDictionary has a boolean property - storeCharsAsNumbers,
the default is true. -->
            <!-- link with solution:
http://www.gg3721.com/list/42/164023.html -->
            <!-- stack trace: java.sql.SQLException: The value supplied
cannot be converted to INTEGER. -->
            <!-- place made problem: at
org.apache.openjpa.jdbc.sql.DBDictionary.getInt(DBDictionary.java:653)
                                     at
org.apache.openjpa.jdbc.sql.DBDictionary.getChar(DBDictionary.java:555) -->
            <!-- openjpa code made problem: if (storeCharsAsNumbers) return
(char) getInt(rs, column); -->
            <property name="openjpa.jdbc.DBDictionary"
value="storeCharsAsNumbers=false"/>
            <property name="openjpa.jdbc.SynchronizeMappings" value="false"
/>
            <property name="openjpa.Log" value="SQL=TRACE"></property>
            <property name="openjpa.ConnectionFactoryProperties"
value="PrettyPrint=true, PrettyPrintLineLength=72"></property>
            <!--<property name="openjpa.InitializeEagerly"
value="true"></property>-->

            </properties>
    </persistence-unit>
</persistence>


Here is test class:

package net.xxx.serviceTest.probnaTabela;

import net.xxx.persistenceTest.probnaTabela.ProbnaTabela1;
import net.xxx.persistenceTest.probnaTabela.ProbnaTabela1Home;
import net.xxx.persistenceTest.probnaTabela.ProbnaTabela1HomeLocal;

import org.junit.Before;
import org.junit.Test;
import org.unitils.UnitilsJUnit4;
import org.unitils.orm.jpa.JpaUnitils;
import org.unitils.orm.jpa.annotation.JpaEntityManagerFactory;

@JpaEntityManagerFactory(persistenceUnit = "xxx", configFile =
"META-INF/persistence.xml")
public class ProbnaTabela1Test extends UnitilsJUnit4 {

    private ProbnaTabela1HomeLocal probnaTabela1Home;

    @Before
    public void setUp() {
        probnaTabela1Home = new ProbnaTabela1Home();
        JpaUnitils.injectEntityManagerInto(probnaTabela1Home);

    }

    @Test
    public void testPersist() {
        ProbnaTabela1 probnaTabela1 = new ProbnaTabela1();
        probnaTabela1.setIme("D");
        probnaTabela1Home.persist(probnaTabela1);
    }

}


David


On Wed, Dec 3, 2008 at 6:52 PM, David Jencks <david_jencks@yahoo.com> wrote:

> From some of this info I have some doubts that you have configured openjpa
> to use geronimo connection pools.  I'm pretty sure the problem comes from
> using the same datasource for both jta and non-jta work.
> Can you please show your persistence.xml, tell us where it is, and show how
> the jta and non-jta datasources are configured?
>
> thanks
> david jencks
>
> On Dec 3, 2008, at 6:45 AM, David Ljuba wrote:
>
> we have this symptom:
> Generates exception:
> ...
> 18047  xxx  INFO   [RMI TCP Connection(216)-192.168.0.63] openjpa.Runtime
> - Starting OpenJPA 1.2.0
> 18344  xxx  INFO   [RMI TCP Connection(216)-192.168.0.63]
> openjpa.jdbc.JDBC - Using dictionary class
> "org.apache.openjpa.jdbc.sql.SQLServerDictionary" (Microsoft SQL Server
> 09.00.3073 ,jTDS Type 4 JDBC Driver for MS SQL Server and Sybase 1.2.2).
> ...
>
> <snip>
>

Mime
View raw message