Hi,
I have a very strange problem with Cayenne 3.0 and Derby Embedded database.
When i execute my application, first runs a query, then when runs the second
one (different from first), it raise this exception:
Exception in thread "Thread-5" org.apache.cayenne.CayenneRuntimeException:
[v.3.0 Apr 26 2010 09:59:17] Global exception.
at
org.apache.cayenne.access.DataDomainQueryAction.nextGlobalException(DataDomainQueryAction.java:553)
at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:258)
at
org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:422)
at
org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:69)
at
org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:395)
at
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:840)
at
org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:392)
at
org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:743)
at
org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:333)
at
org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:96)
at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1278)
at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1267)
at minica.server.actions.CANewCertAction.doAction(CANewCertAction.java:46)
at
minica.server.parsers.CANewCertParser.parseMessage(CANewCertParser.java:37)
at minica.server.CASocketReceiver.run(CASocketReceiver.java:73)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalStateException: Transaction must have
'STATUS_ACTIVE' to add a connection. Current status: STATUS_COMMITTED
at
org.apache.cayenne.access.ExternalTransaction.addConnection(ExternalTransaction.java:64)
at
org.apache.cayenne.access.DataNode$TransactionDataSource.getConnection(DataNode.java:365)
at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:248)
... 15 more
The second query is executed in a different thread.
This is a code I use to get the DataContext object:
public ObjectContext getContext() {
try {
return BaseContext.getThreadObjectContext();
} catch(IllegalStateException e) {
BaseContext.bindThreadObjectContext(DataContext.createDataContext(false));
return BaseContext.getThreadObjectContext();
}
}
Both queries are simply SelectQuery:
1.
ObjectContext context =
CertificationAuthority.getInstance().getContext();
SelectQuery select1 = new SelectQuery(DBCertificate.class);
List<DBCertificate> l = context.performQuery(select1);
2.
ObjectContext context =
CertificationAuthority.getInstance().getContext();
Expression clause = ExpressionFactory.matchExp(DBUser.NAME_PROPERTY,
subject);
SelectQuery query = new SelectQuery(DBUser.class, clause);
List<DBUser> result = context.performQuery(query);
The very strange thing is that the app raises exception only at first time,
when DB is empty and, more strange, if I execute in debug mode, all works
well !
I try anything but I don't find any solution.
Any suggestions?
*Andrea*
This archive was generated by hypermail 2.0.0 : Tue Jun 08 2010 - 19:54:42 UTC