openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: Connection usage
Date Thu, 23 Aug 2007 16:56:28 GMT
Hi,

Are you listing your persistent types in your persistence.xml file?

The connection is being obtained while building up the mapping
information for the class, which indicates that the class meta data
was not fully populated by the time that the code started executing.

-Patrick

On 8/23/07, Christian Defoy <christian.defoy@gmail.com> wrote:
> Hi Patrick,
>
> Here is the stack trace of the second call to getConnection():
>
> java.lang.Exception: Stack trace
>         at java.lang.Thread.dumpStack(Thread.java:1158)
>         at ex5.ConnectionPool.getConnection(ConnectionPool.java:325)
>         at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:106)
>         at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:87)
>         at org.apache.openjpa.jdbc.schema.LazySchemaFactory.generateSchemaObject(LazySchemaFactory.java:140)
>         at org.apache.openjpa.jdbc.schema.LazySchemaFactory.findTable(LazySchemaFactory.java:91)
>         at org.apache.openjpa.jdbc.meta.MappingInfo.createTable(MappingInfo.java:466)
>         at org.apache.openjpa.jdbc.meta.ClassMappingInfo.getTable(ClassMappingInfo.java:229)
>         at org.apache.openjpa.jdbc.meta.strats.FullClassStrategy.map(FullClassStrategy.java:71)
>         at org.apache.openjpa.jdbc.meta.ClassMapping.setStrategy(ClassMapping.java:345)
>         at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:55)
>         at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:313)
>         at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:605)
>         at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:492)
>         at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:288)
>         at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:524)
>         at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:484)
>         at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:288)
>         at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:343)
>         at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:154)
>         at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:134)
>         at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:214)
>         at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:184)
>         at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:177)
>         at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$500(JPQLExpressionBuilder.java:64)
>         at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1671)
>         at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:55)
>         at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:148)
>         at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:649)
>         at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:630)
>         at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:596)
>         at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:658)
>         at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1483)
>         at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
>         at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:219)
>         at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:269)
>         at ex5.DatabaseCommandProcessor.processPendingCommands(DatabaseCommandProcessor.java:342)
>         at ex5.DatabaseCommandProcessor.access$1(DatabaseCommandProcessor.java:326)
>         at ex5.CommandScanner.run(DatabaseCommandProcessor.java:460)
>         at java.util.TimerThread.mainLoop(Timer.java:512)
>         at java.util.TimerThread.run(Timer.java:462)
>
> The code looks like this:
>
> EntityManager manager = factory.createEntityManager();
> Query query = manager.createQuery( "some query on objects with named
> parameters" );
> query.getResultList();
>
> If it helps, the objects queried are of type AddShapeCommand, which is
> part of a three-level object hierarchy: Command -> ShapeCommand ->
> AddShapeCommand.  I also include the annotations related to
> inheritance:
>
> @Entity
> @Table( name="command" )
> @Inheritance( strategy=InheritanceType.SINGLE_TABLE )
> @DiscriminatorColumn( name="command_type",
> discriminatorType=DiscriminatorType.INTEGER )
> @DiscriminatorValue( "0" )
> public class Command
> {
> ...
> }
>
> @MappedSuperclass
> public abstract class ShapeCommand extends Command
> {
> ...
> }
>
> @Entity
> @DiscriminatorValue( "2" )
> public class AddShapeCommand extends ShapeCommand
> {
> ..
> }
>
> Christian
>
> On 8/23/07, Patrick Linskey <plinskey@gmail.com> wrote:
> > Hi,
> >
> > Can you post a thread dump from the deadlock?
> >
> > My guess would be that we're using the second connection to fetch an
> > ID value from a sequence table. Otherwise, we should not be obtaining
> > multiple.
> >
> > -Patrick
> >
> > On 8/23/07, Christian Defoy <christian.defoy@gmail.com> wrote:
> > > Hello,
> > >
> > > Quick question about connection usage:
> > >
> > > I was performing some tests and I noticed that my connection pool was
> > > configured for 10 connections but theoretically, I should need only
> > > one so I set the connection pool size to 1.  Now, my application
> > > deadlocks because it appears that getEntityManager() requests a
> > > connection and query.getResultList() requests one too.
> > >
> > > When I read section 4.8 "Configuring the Use of JDBC Connections", I
> > > thought that setting openjpa.ConnectionRetainMode to "always" would
> > > have the entity manager retain its connection (that part works fine)
> > > but that it would have the entity manager share that connection with
> > > queries...
> > >
> > > Is there a way to make that happen?  My server is kind of counting on
> > > the fact that a single connection is used to process a single
> > > request...
> > >
> > > Christian
> > >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
> >
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message