You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Martin Uhlir <st...@seznam.cz> on 2009/01/24 02:02:57 UTC
Problem with DataSource
Hi all,
I added new DataSources in my openejb.xml file:
<Resource id="MyDB" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/TestDB
UserName xxx
Password yyy
JtaManaged true
</Resource>
<Resource id="MyDBun" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/TestDB
UserName xxx
Password yyy
JtaManaged false
</Resource>
Then I deployed an EJB application with this persistence.xml
<persistence-unit name="EJB_Module">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>MyDB</jta-data-source>
<non-jta-data-source>MyDBun</non-jta-data-source>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
So according to SynchronizeMappings the tables etc. shall be
automatically created.
But running the application I get following exception:
<openjpa-1.2.0-r422266:683325 fatal store error>
org.apache.openjpa.util.StoreException: The transaction has been rolled
back. See the nested exceptions for details on the errors that occurred.
at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
at
org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
at
org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
at
org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
at
org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:245)
at
org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:291)
at
org.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71)
at
org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:74)
at
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:231)
at
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
at
org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
at
org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:129)
at
org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:149)
at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:71)
at
org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:213)
at
org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:66)
at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
org.apache.openjpa.util.StoreException: ERROR: relation "country" does
not exist {prepstmnt 16963612 INSERT INTO Country (id, name) VALUES (?,
?) [params=(long) 5, (String) aaa]} [code=0, state=42P01]
FailedObject: carpool.entities.Country@17a687b
at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238)
at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:131)
at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:89)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:72)
at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:543)
at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:105)
at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
... 26 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
relation "country" does not exist {prepstmnt 16963612 INSERT INTO
Country (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]}
[code=0, state=42P01]
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:866)
at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:151)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:120)
... 36 more
What does this '.....relation "country" does not exist".....' mean? I'm
just using this simple entity bean which I try to persist in a stateless
session bean.
@Entity
public class Country {
private Long id;
private String name;
public void setId(Long id) {
this.id = id;
}
@Id
public Long getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
When I change my persistence.xml to the DataSources provided by openejb
by default
<jta-data-source>My DataSource</jta-data-source>
<non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
then everything works just fine (but I don't want to use the default
HSQL database).
Thank you for any help in advance.
Re: Problem with DataSource
Posted by Martin Uhlir <st...@seznam.cz>.
Hi David,
as I wrote in my previous email, I tried to install MySQL instead of
PostreSQL and suddenly everything works fine.
When using the MySQL I can see in the log the statements for creating
tables, but trying to connect to PostgreSQL it didn't come to the point
of creating tables at all. Most likely this seems to be problem of
OpenJPA, so I will go to try to solve this problem to their mailing list.
Anyway, thank you for your answer.
Martin
David Blevins wrote:
> Hi Martin,
>
> Your configuration is perfect. I wonder if the OpenJPA team might be
> aware of anything that might prevent the SynchronizeMappings feature
> from working on PostgreSQL. Of perhaps if there's a better way to
> debug exactly what table definitions were created in the
> synchronization process.
>
> -David
>
> On Jan 23, 2009, at 5:02 PM, Martin Uhlir wrote:
>
>> Hi all,
>>
>> I added new DataSources in my openejb.xml file:
>>
>> <Resource id="MyDB" type="DataSource">
>> JdbcDriver org.postgresql.Driver
>> JdbcUrl jdbc:postgresql://localhost/TestDB
>> UserName xxx
>> Password yyy
>> JtaManaged true
>> </Resource>
>>
>> <Resource id="MyDBun" type="DataSource">
>> JdbcDriver org.postgresql.Driver
>> JdbcUrl jdbc:postgresql://localhost/TestDB
>> UserName xxx
>> Password yyy
>> JtaManaged false
>> </Resource>
>>
>> Then I deployed an EJB application with this persistence.xml
>> <persistence-unit name="EJB_Module">
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>
>> <jta-data-source>MyDB</jta-data-source>
>> <non-jta-data-source>MyDBun</non-jta-data-source>
>> <properties>
>> <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true)"/>
>> </properties>
>> </persistence-unit>
>>
>> So according to SynchronizeMappings the tables etc. shall be
>> automatically created.
>>
>> But running the application I get following exception:
>> <openjpa-1.2.0-r422266:683325 fatal store error>
>> org.apache.openjpa.util.StoreException: The transaction has been
>> rolled back. See the nested exceptions for details on the errors
>> that occurred.
>> at
>> org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
>>
>> at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
>> at
>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
>> at
>> org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
>>
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
>>
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
>>
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
>>
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
>>
>> at
>> org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:245)
>>
>> at
>> org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:291)
>>
>> at
>> org.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71)
>>
>> at
>> org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:74)
>>
>> at
>> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:231)
>>
>> at
>> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
>>
>> at
>> org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
>>
>> at
>> org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:129)
>>
>> at
>> org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
>>
>> at
>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:149)
>> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:71)
>> at
>> org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:213)
>>
>> at
>> org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
>>
>> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:66)
>> at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
>> at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>
>> at java.lang.Thread.run(Thread.java:619)
>> Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
>> org.apache.openjpa.util.StoreException: ERROR: relation "country"
>> does not exist {prepstmnt 16963612 INSERT INTO Country (id, name)
>> VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0, state=42P01]
>> FailedObject: carpool.entities.Country@17a687b
>> at
>> org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238)
>> at
>> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203)
>>
>> at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
>>
>> at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:131)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:89)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:72)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:543)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:105)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
>>
>> at
>> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
>>
>> ... 26 more
>> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
>> relation "country" does not exist {prepstmnt 16963612 INSERT INTO
>> Country (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]}
>> [code=0, state=42P01]
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
>>
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57)
>>
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:866)
>>
>> at
>> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
>>
>> at
>> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:151)
>>
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:120)
>>
>> ... 36 more
>>
>>
>>
>> What does this '.....relation "country" does not exist".....' mean?
>> I'm just using this simple entity bean which I try to persist in a
>> stateless session bean.
>> @Entity
>> public class Country {
>> private Long id;
>> private String name;
>>
>> public void setId(Long id) {
>> this.id = id;
>> }
>>
>> @Id
>> public Long getId() {
>> return id;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> public String getName() {
>> return name;
>> }
>> }
>>
>>
>> When I change my persistence.xml to the DataSources provided by
>> openejb by default
>> <jta-data-source>My DataSource</jta-data-source>
>> <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
>> then everything works just fine (but I don't want to use the default
>> HSQL database).
>>
>> Thank you for any help in advance.
>>
>
>
Re: Problem with DataSource
Posted by Kevin Sutter <kw...@gmail.com>.
Hi Martin,
I am not aware of any problems with SynchronizeMappings not working with
PostgreSQL. If you turn on trace for OpenJPA, you should see the actual
interaction with the database for creating the tables. Here's an example
for turning on just the SQL trace, which should be sufficient for debugging
this problem. But, you can experiment with more trace settings to get more
data.
<property name="openjpa.Log" value="DefaultLevel=WARN,SQL=TRACE"/>
Since this seems to work with HSQL, then you could also run with trace with
that database to see how the tables are being created.
One thought I have is whether you already have a "country" table that exists
in PostgreSQL and it's schema doesn't match with your Entity definitions.
Good luck,
Kevin
On Wed, Jan 28, 2009 at 1:20 AM, David Blevins <da...@visi.com>wrote:
> Hi Martin,
>
> Your configuration is perfect. I wonder if the OpenJPA team might be aware
> of anything that might prevent the SynchronizeMappings feature from working
> on PostgreSQL. Of perhaps if there's a better way to debug exactly what
> table definitions were created in the synchronization process.
>
> -David
>
> On Jan 23, 2009, at 5:02 PM, Martin Uhlir wrote:
>
> Hi all,
>>
>> I added new DataSources in my openejb.xml file:
>>
>> <Resource id="MyDB" type="DataSource">
>> JdbcDriver org.postgresql.Driver
>> JdbcUrl jdbc:postgresql://localhost/TestDB
>> UserName xxx
>> Password yyy
>> JtaManaged true
>> </Resource>
>>
>> <Resource id="MyDBun" type="DataSource">
>> JdbcDriver org.postgresql.Driver
>> JdbcUrl jdbc:postgresql://localhost/TestDB
>> UserName xxx
>> Password yyy
>> JtaManaged false
>> </Resource>
>>
>> Then I deployed an EJB application with this persistence.xml
>> <persistence-unit name="EJB_Module">
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>> <jta-data-source>MyDB</jta-data-source>
>> <non-jta-data-source>MyDBun</non-jta-data-source>
>> <properties>
>> <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true)"/>
>> </properties>
>> </persistence-unit>
>>
>> So according to SynchronizeMappings the tables etc. shall be automatically
>> created.
>>
>> But running the application I get following exception:
>> <openjpa-1.2.0-r422266:683325 fatal store error>
>> org.apache.openjpa.util.StoreException: The transaction has been rolled
>> back. See the nested exceptions for details on the errors that occurred.
>> at
>> org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
>> at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
>> at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
>> at
>> org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
>> at
>> org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:245)
>> at
>> org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:291)
>> at
>> org.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71)
>> at
>> org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:74)
>> at
>> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:231)
>> at
>> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
>> at
>> org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
>> at
>> org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:129)
>> at
>> org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
>> at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:149)
>> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:71)
>> at
>> org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:213)
>> at
>> org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
>> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:66)
>> at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
>> at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>> at java.lang.Thread.run(Thread.java:619)
>> Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
>> org.apache.openjpa.util.StoreException: ERROR: relation "country" does not
>> exist {prepstmnt 16963612 INSERT INTO Country (id, name) VALUES (?, ?)
>> [params=(long) 5, (String) aaa]} [code=0, state=42P01]
>> FailedObject: carpool.entities.Country@17a687b
>> at
>> org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238)
>> at
>> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203)
>> at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
>> at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:131)
>> at
>> org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:89)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:72)
>> at
>> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:543)
>> at
>> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:105)
>> at
>> org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
>> at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
>> at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
>> at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
>> at
>> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
>> ... 26 more
>> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
>> relation "country" does not exist {prepstmnt 16963612 INSERT INTO Country
>> (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0,
>> state=42P01]
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57)
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:866)
>> at
>> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
>> at
>> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
>> at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:151)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:120)
>> ... 36 more
>>
>>
>>
>> What does this '.....relation "country" does not exist".....' mean? I'm
>> just using this simple entity bean which I try to persist in a stateless
>> session bean.
>> @Entity
>> public class Country {
>> private Long id;
>> private String name;
>>
>> public void setId(Long id) {
>> this.id = id;
>> }
>>
>> @Id
>> public Long getId() {
>> return id;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> public String getName() {
>> return name;
>> }
>> }
>>
>>
>> When I change my persistence.xml to the DataSources provided by openejb by
>> default
>> <jta-data-source>My DataSource</jta-data-source>
>> <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
>> then everything works just fine (but I don't want to use the default HSQL
>> database).
>>
>> Thank you for any help in advance.
>>
>>
>
Re: Problem with DataSource
Posted by Kevin Sutter <kw...@gmail.com>.
Hi Martin,
I am not aware of any problems with SynchronizeMappings not working with
PostgreSQL. If you turn on trace for OpenJPA, you should see the actual
interaction with the database for creating the tables. Here's an example
for turning on just the SQL trace, which should be sufficient for debugging
this problem. But, you can experiment with more trace settings to get more
data.
<property name="openjpa.Log" value="DefaultLevel=WARN,SQL=TRACE"/>
Since this seems to work with HSQL, then you could also run with trace with
that database to see how the tables are being created.
One thought I have is whether you already have a "country" table that exists
in PostgreSQL and it's schema doesn't match with your Entity definitions.
Good luck,
Kevin
On Wed, Jan 28, 2009 at 1:20 AM, David Blevins <da...@visi.com>wrote:
> Hi Martin,
>
> Your configuration is perfect. I wonder if the OpenJPA team might be aware
> of anything that might prevent the SynchronizeMappings feature from working
> on PostgreSQL. Of perhaps if there's a better way to debug exactly what
> table definitions were created in the synchronization process.
>
> -David
>
> On Jan 23, 2009, at 5:02 PM, Martin Uhlir wrote:
>
> Hi all,
>>
>> I added new DataSources in my openejb.xml file:
>>
>> <Resource id="MyDB" type="DataSource">
>> JdbcDriver org.postgresql.Driver
>> JdbcUrl jdbc:postgresql://localhost/TestDB
>> UserName xxx
>> Password yyy
>> JtaManaged true
>> </Resource>
>>
>> <Resource id="MyDBun" type="DataSource">
>> JdbcDriver org.postgresql.Driver
>> JdbcUrl jdbc:postgresql://localhost/TestDB
>> UserName xxx
>> Password yyy
>> JtaManaged false
>> </Resource>
>>
>> Then I deployed an EJB application with this persistence.xml
>> <persistence-unit name="EJB_Module">
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>> <jta-data-source>MyDB</jta-data-source>
>> <non-jta-data-source>MyDBun</non-jta-data-source>
>> <properties>
>> <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true)"/>
>> </properties>
>> </persistence-unit>
>>
>> So according to SynchronizeMappings the tables etc. shall be automatically
>> created.
>>
>> But running the application I get following exception:
>> <openjpa-1.2.0-r422266:683325 fatal store error>
>> org.apache.openjpa.util.StoreException: The transaction has been rolled
>> back. See the nested exceptions for details on the errors that occurred.
>> at
>> org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
>> at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
>> at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
>> at
>> org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
>> at
>> org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
>> at
>> org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:245)
>> at
>> org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:291)
>> at
>> org.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71)
>> at
>> org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:74)
>> at
>> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:231)
>> at
>> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
>> at
>> org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
>> at
>> org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:129)
>> at
>> org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
>> at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:149)
>> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:71)
>> at
>> org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:213)
>> at
>> org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
>> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:66)
>> at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
>> at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>> at java.lang.Thread.run(Thread.java:619)
>> Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
>> org.apache.openjpa.util.StoreException: ERROR: relation "country" does not
>> exist {prepstmnt 16963612 INSERT INTO Country (id, name) VALUES (?, ?)
>> [params=(long) 5, (String) aaa]} [code=0, state=42P01]
>> FailedObject: carpool.entities.Country@17a687b
>> at
>> org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238)
>> at
>> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203)
>> at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
>> at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:131)
>> at
>> org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:89)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:72)
>> at
>> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:543)
>> at
>> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:105)
>> at
>> org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
>> at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
>> at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
>> at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
>> at
>> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
>> ... 26 more
>> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
>> relation "country" does not exist {prepstmnt 16963612 INSERT INTO Country
>> (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0,
>> state=42P01]
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57)
>> at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:866)
>> at
>> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
>> at
>> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
>> at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:151)
>> at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:120)
>> ... 36 more
>>
>>
>>
>> What does this '.....relation "country" does not exist".....' mean? I'm
>> just using this simple entity bean which I try to persist in a stateless
>> session bean.
>> @Entity
>> public class Country {
>> private Long id;
>> private String name;
>>
>> public void setId(Long id) {
>> this.id = id;
>> }
>>
>> @Id
>> public Long getId() {
>> return id;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> public String getName() {
>> return name;
>> }
>> }
>>
>>
>> When I change my persistence.xml to the DataSources provided by openejb by
>> default
>> <jta-data-source>My DataSource</jta-data-source>
>> <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
>> then everything works just fine (but I don't want to use the default HSQL
>> database).
>>
>> Thank you for any help in advance.
>>
>>
>
Re: Problem with DataSource
Posted by David Blevins <da...@visi.com>.
Hi Martin,
Your configuration is perfect. I wonder if the OpenJPA team might be
aware of anything that might prevent the SynchronizeMappings feature
from working on PostgreSQL. Of perhaps if there's a better way to
debug exactly what table definitions were created in the
synchronization process.
-David
On Jan 23, 2009, at 5:02 PM, Martin Uhlir wrote:
> Hi all,
>
> I added new DataSources in my openejb.xml file:
>
> <Resource id="MyDB" type="DataSource">
> JdbcDriver org.postgresql.Driver
> JdbcUrl jdbc:postgresql://localhost/TestDB
> UserName xxx
> Password yyy
> JtaManaged true
> </Resource>
>
> <Resource id="MyDBun" type="DataSource">
> JdbcDriver org.postgresql.Driver
> JdbcUrl jdbc:postgresql://localhost/TestDB
> UserName xxx
> Password yyy
> JtaManaged false
> </Resource>
>
> Then I deployed an EJB application with this persistence.xml
> <persistence-unit name="EJB_Module">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</
> provider>
> <jta-data-source>MyDB</jta-data-source>
> <non-jta-data-source>MyDBun</non-jta-data-source>
> <properties>
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)"/>
> </properties>
> </persistence-unit>
>
> So according to SynchronizeMappings the tables etc. shall be
> automatically created.
>
> But running the application I get following exception:
> <openjpa-1.2.0-r422266:683325 fatal store error>
> org.apache.openjpa.util.StoreException: The transaction has been
> rolled back. See the nested exceptions for details on the errors
> that occurred.
> at
> org
> .apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:
> 2163)
> at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
> at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
> 1908)
> at
> org
> .apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:
> 1826)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
> at
> org
> .apache
> .geronimo
> .transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:
> 245)
> at
> org
> .apache
> .openejb
> .core
> .transaction
> .JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:
> 291)
> at
> org
> .apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71)
> at
> org
> .apache
> .openejb
> .core
> .transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:
> 74)
> at
> org
> .apache
> .openejb
> .core.stateless.StatelessContainer._invoke(StatelessContainer.java:
> 231)
> at
> org
> .apache
> .openejb
> .core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
> at
> org
> .apache
> .openejb
> .server
> .ejbd
> .EjbRequestHandler
> .doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
> at
> org
> .apache
> .openejb
> .server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:
> 129)
> at
> org
> .apache
> .openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
> at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:
> 149)
> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:
> 71)
> at org.apache.openejb.server.ejbd.KeepAliveServer
> $Session.service(KeepAliveServer.java:213)
> at
> org
> .apache
> .openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:
> 66)
> at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
> at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
> at java.util.concurrent.ThreadPoolExecutor
> $Worker.runTask(ThreadPoolExecutor.java:886)
> at java.util.concurrent.ThreadPoolExecutor
> $Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
> org.apache.openjpa.util.StoreException: ERROR: relation "country"
> does not exist {prepstmnt 16963612 INSERT INTO Country (id, name)
> VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0, state=42P01]
> FailedObject: carpool.entities.Country@17a687b
> at
> org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:
> 4238)
> at
> org
> .apache
> .openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:
> 4203)
> at
> org
> .apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:
> 102)
> at
> org
> .apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flushAndUpdate(PreparedStatementManagerImpl.java:131)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .BatchingPreparedStatementManagerImpl
> .flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flushInternal(PreparedStatementManagerImpl.java:89)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flush(PreparedStatementManagerImpl.java:72)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:
> 543)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:
> 105)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .BatchingConstraintUpdateManager
> .flush(BatchingConstraintUpdateManager.java:59)
> at
> org
> .apache
> .openjpa
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:
> 89)
> at
> org
> .apache
> .openjpa
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:
> 72)
> at
> org
> .apache
> .openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
> at
> org
> .apache
> .openjpa
> .kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
> ... 26 more
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
> relation "country" does not exist {prepstmnt 16963612 INSERT INTO
> Country (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]}
> [code=0, state=42P01]
> at
> org
> .apache
> .openjpa
> .lib
> .jdbc
> .LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
> at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access
> $700(LoggingConnectionDecorator.java:57)
> at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
> $LoggingConnection
> $
> LoggingPreparedStatement
> .executeUpdate(LoggingConnectionDecorator.java:866)
> at
> org
> .apache
> .openjpa
> .lib
> .jdbc
> .DelegatingPreparedStatement
> .executeUpdate(DelegatingPreparedStatement.java:269)
> at
> org
> .apache
> .openjpa
> .lib
> .jdbc
> .DelegatingPreparedStatement
> .executeUpdate(DelegatingPreparedStatement.java:269)
> at org.apache.openjpa.jdbc.kernel.JDBCStoreManager
> $CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .executeUpdate(PreparedStatementManagerImpl.java:151)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flushAndUpdate(PreparedStatementManagerImpl.java:120)
> ... 36 more
>
>
>
> What does this '.....relation "country" does not exist".....' mean?
> I'm just using this simple entity bean which I try to persist in a
> stateless session bean.
> @Entity
> public class Country {
> private Long id;
> private String name;
>
> public void setId(Long id) {
> this.id = id;
> }
>
> @Id
> public Long getId() {
> return id;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> public String getName() {
> return name;
> }
> }
>
>
> When I change my persistence.xml to the DataSources provided by
> openejb by default
> <jta-data-source>My DataSource</jta-data-source>
> <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
> then everything works just fine (but I don't want to use the default
> HSQL database).
>
> Thank you for any help in advance.
>
Re: Problem with DataSource
Posted by Martin Uhlir <st...@seznam.cz>.
Jacek Laskowski wrote:
> On Sat, Jan 24, 2009 at 2:02 AM, Martin Uhlir <st...@seznam.cz> wrote:
>
>
>> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
>> relation "country" does not exist {prepstmnt 16963612 INSERT INTO Country
>> (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0,
>> state=42P01]
>>
> ...
>
>> What does this '.....relation "country" does not exist".....' mean? I'm just
>> using this simple entity bean which I try to persist in a stateless session
>> bean.
>> @Entity
>> public class Country {
>> private Long id;
>> private String name;
>>
>> public void setId(Long id) {
>> this.id = id;
>> }
>>
>> @Id
>> public Long getId() {
>> return id;
>> }
>>
>
> How do you work with the entity? Why was the id 5 in the exception if
> it had never worked before? Did PostgreSQL assign 5 from the very
> begining? You didn't set the id yourself, did you? Show the relevant
> session ejb snippet where the entity is used.
>
>
There is nothing interesting about the ejb snippet. I was just "greedy"
to see it running (the creation of tables by OpenJPA in db when getting
EntityManager for the first time) so I made it as simple as possible :-)
Country c = new Country();
c.setId(5L);
em.persist(c);
> I also wonder if no @GeneratedValue with @Id causes the exception.
> 9.1.9 GeneratedValue Annotation in the EJB 3.0 spec reads (AUTO is the
> default value):
>
Thanks for noticing me about this fact, but there was really no
exception in the log when I didn't use the GenerationValue annotation
together with Id.
> The AUTO value indicates that the persistence provider should pick an
> appropriate strategy for the particular database. The AUTO generation
> strategy may expect a database resource to exist, or it may attempt to
> create one. A vendor may provide documentation on how to create such
> resources in the event that it does not support schema generation or
> cannot create the schema resource at runtime.
>
> That's why the exception contained reference to "relation country",
> but it still doesn't sound good.
>
Btw. in the meantime I installed MySQL instead of PostgreSQL and used
its connection and suddenly everything worked just fine..
Still I dont know where the problem with PostgreSQL was, I used the
"superuser" who has all rights (grants) to do in db..
> BTW, you don't have to use the wrapper classes, e.g. Long for entity
> fields - primitive types work fine, e.g. long.
>
> Jacek
>
>
Re: Problem with DataSource
Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Sat, Jan 24, 2009 at 2:02 AM, Martin Uhlir <st...@seznam.cz> wrote:
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
> relation "country" does not exist {prepstmnt 16963612 INSERT INTO Country
> (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0,
> state=42P01]
...
> What does this '.....relation "country" does not exist".....' mean? I'm just
> using this simple entity bean which I try to persist in a stateless session
> bean.
> @Entity
> public class Country {
> private Long id;
> private String name;
>
> public void setId(Long id) {
> this.id = id;
> }
>
> @Id
> public Long getId() {
> return id;
> }
How do you work with the entity? Why was the id 5 in the exception if
it had never worked before? Did PostgreSQL assign 5 from the very
begining? You didn't set the id yourself, did you? Show the relevant
session ejb snippet where the entity is used.
I also wonder if no @GeneratedValue with @Id causes the exception.
9.1.9 GeneratedValue Annotation in the EJB 3.0 spec reads (AUTO is the
default value):
The AUTO value indicates that the persistence provider should pick an
appropriate strategy for the particular database. The AUTO generation
strategy may expect a database resource to exist, or it may attempt to
create one. A vendor may provide documentation on how to create such
resources in the event that it does not support schema generation or
cannot create the schema resource at runtime.
That's why the exception contained reference to "relation country",
but it still doesn't sound good.
BTW, you don't have to use the wrapper classes, e.g. Long for entity
fields - primitive types work fine, e.g. long.
Jacek
--
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl
Re: Problem with DataSource
Posted by David Blevins <da...@visi.com>.
Hi Martin,
Your configuration is perfect. I wonder if the OpenJPA team might be
aware of anything that might prevent the SynchronizeMappings feature
from working on PostgreSQL. Of perhaps if there's a better way to
debug exactly what table definitions were created in the
synchronization process.
-David
On Jan 23, 2009, at 5:02 PM, Martin Uhlir wrote:
> Hi all,
>
> I added new DataSources in my openejb.xml file:
>
> <Resource id="MyDB" type="DataSource">
> JdbcDriver org.postgresql.Driver
> JdbcUrl jdbc:postgresql://localhost/TestDB
> UserName xxx
> Password yyy
> JtaManaged true
> </Resource>
>
> <Resource id="MyDBun" type="DataSource">
> JdbcDriver org.postgresql.Driver
> JdbcUrl jdbc:postgresql://localhost/TestDB
> UserName xxx
> Password yyy
> JtaManaged false
> </Resource>
>
> Then I deployed an EJB application with this persistence.xml
> <persistence-unit name="EJB_Module">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</
> provider>
> <jta-data-source>MyDB</jta-data-source>
> <non-jta-data-source>MyDBun</non-jta-data-source>
> <properties>
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)"/>
> </properties>
> </persistence-unit>
>
> So according to SynchronizeMappings the tables etc. shall be
> automatically created.
>
> But running the application I get following exception:
> <openjpa-1.2.0-r422266:683325 fatal store error>
> org.apache.openjpa.util.StoreException: The transaction has been
> rolled back. See the nested exceptions for details on the errors
> that occurred.
> at
> org
> .apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:
> 2163)
> at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
> at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
> 1908)
> at
> org
> .apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:
> 1826)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
> at
> org
> .apache
> .geronimo
> .transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
> at
> org
> .apache
> .geronimo
> .transaction
> .manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:
> 245)
> at
> org
> .apache
> .openejb
> .core
> .transaction
> .JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:
> 291)
> at
> org
> .apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71)
> at
> org
> .apache
> .openejb
> .core
> .transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:
> 74)
> at
> org
> .apache
> .openejb
> .core.stateless.StatelessContainer._invoke(StatelessContainer.java:
> 231)
> at
> org
> .apache
> .openejb
> .core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
> at
> org
> .apache
> .openejb
> .server
> .ejbd
> .EjbRequestHandler
> .doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
> at
> org
> .apache
> .openejb
> .server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:
> 129)
> at
> org
> .apache
> .openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
> at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:
> 149)
> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:
> 71)
> at org.apache.openejb.server.ejbd.KeepAliveServer
> $Session.service(KeepAliveServer.java:213)
> at
> org
> .apache
> .openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
> at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:
> 66)
> at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
> at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
> at java.util.concurrent.ThreadPoolExecutor
> $Worker.runTask(ThreadPoolExecutor.java:886)
> at java.util.concurrent.ThreadPoolExecutor
> $Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
> org.apache.openjpa.util.StoreException: ERROR: relation "country"
> does not exist {prepstmnt 16963612 INSERT INTO Country (id, name)
> VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0, state=42P01]
> FailedObject: carpool.entities.Country@17a687b
> at
> org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:
> 4238)
> at
> org
> .apache
> .openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:
> 4203)
> at
> org
> .apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:
> 102)
> at
> org
> .apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flushAndUpdate(PreparedStatementManagerImpl.java:131)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .BatchingPreparedStatementManagerImpl
> .flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flushInternal(PreparedStatementManagerImpl.java:89)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flush(PreparedStatementManagerImpl.java:72)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:
> 543)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:
> 105)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .BatchingConstraintUpdateManager
> .flush(BatchingConstraintUpdateManager.java:59)
> at
> org
> .apache
> .openjpa
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:
> 89)
> at
> org
> .apache
> .openjpa
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:
> 72)
> at
> org
> .apache
> .openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
> at
> org
> .apache
> .openjpa
> .kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
> ... 26 more
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
> relation "country" does not exist {prepstmnt 16963612 INSERT INTO
> Country (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]}
> [code=0, state=42P01]
> at
> org
> .apache
> .openjpa
> .lib
> .jdbc
> .LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
> at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access
> $700(LoggingConnectionDecorator.java:57)
> at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
> $LoggingConnection
> $
> LoggingPreparedStatement
> .executeUpdate(LoggingConnectionDecorator.java:866)
> at
> org
> .apache
> .openjpa
> .lib
> .jdbc
> .DelegatingPreparedStatement
> .executeUpdate(DelegatingPreparedStatement.java:269)
> at
> org
> .apache
> .openjpa
> .lib
> .jdbc
> .DelegatingPreparedStatement
> .executeUpdate(DelegatingPreparedStatement.java:269)
> at org.apache.openjpa.jdbc.kernel.JDBCStoreManager
> $CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .executeUpdate(PreparedStatementManagerImpl.java:151)
> at
> org
> .apache
> .openjpa
> .jdbc
> .kernel
> .PreparedStatementManagerImpl
> .flushAndUpdate(PreparedStatementManagerImpl.java:120)
> ... 36 more
>
>
>
> What does this '.....relation "country" does not exist".....' mean?
> I'm just using this simple entity bean which I try to persist in a
> stateless session bean.
> @Entity
> public class Country {
> private Long id;
> private String name;
>
> public void setId(Long id) {
> this.id = id;
> }
>
> @Id
> public Long getId() {
> return id;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> public String getName() {
> return name;
> }
> }
>
>
> When I change my persistence.xml to the DataSources provided by
> openejb by default
> <jta-data-source>My DataSource</jta-data-source>
> <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
> then everything works just fine (but I don't want to use the default
> HSQL database).
>
> Thank you for any help in advance.
>