Prodoc wrote: > > This method of working functions until the entity manager is called from > two different threads at the same time. Sometimes it works, sometimes I > get an error like the following (note the strange fact that it Weapon is > the problem but it is one of the known entities): > > 63 MPSFPU INFO [RunnableQueue-1] openjpa.Runtime - Starting OpenJPA > 1.2.1 > 188 MPSFPU INFO [RunnableQueue-1] openjpa.jdbc.JDBC - Using dictionary > class "org.apache.openjpa.jdbc.sql.DerbyDictionary". > <openjpa-1.2.1-r752877:753278 nonfatal user error> > org.apache.openjpa.persistence.ArgumentException: An error occurred while > parsing the query filter "SELECT d FROM Weapon d WHERE d.type = 'gun'". > Error message: The name "Weapon" is not a recognized entity or identifier. > Perhaps you meant Weapon, which is a close match. Known entity names: > [Sensor, Weapon, Threat] > at > org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) > at > org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:177) > at > org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150) > at > org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225) > at > org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195) > at > org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188) > at > org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69) > at > org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756) > at > org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56) > at > org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153) > at > org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658) > at > org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639) > at > org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) > at > org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) > at > org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492) > at > org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123) > at > org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243) > at > org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) > at > com.thalesgroup.nl.mpsf.editor.AddDeviceTool.initDeviceList(AddDeviceTool.java:133) > at > com.thalesgroup.nl.mpsf.editor.AddDeviceTool.<init>(AddDeviceTool.java:56) > at > com.thalesgroup.nl.mpsf.editor.MPSFView$2$1.addDeviceEventListeners(MPSFView.java:148) > at > com.thalesgroup.nl.mpsf.editor.MPSFView$2$1.run(MPSFView.java:131) > at org.apache.batik.util.RunnableQueue.run(Unknown Source) > at java.lang.Thread.run(Thread.java:595) > >
To come back to the initial error. I just found that it is not caused by the entity manager but the entity manager factory. I tried getting just the factory from a singleton and creating a manager for each thread but the error remained. Maybe I'm looking at it the wrong way but how can it be that I'm getting a manager from the factory while OpenJPA isn't finished initializing in the first place? -- View this message in context: http://n2.nabble.com/EntityManager-used-in-multiple-threads-tp3662432p3668274.html Sent from the OpenJPA Users mailing list archive at Nabble.com.