[
https://issues.apache.org/jira/browse/OPENJPA-2193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13411520#comment-13411520
]
Daniel Persson commented on OPENJPA-2193:
-----------------------------------------
I'm using tomcat and one EntityManagerFactory. Creating multiple EntityManager
one per thread using
private static transient ThreadLocal<Hashtable<String, EntityManager>>
entityManagers = new ThreadLocal<Hashtable<String, EntityManager>>();
Cleanup is done with an ServletRequestListener destroying the entitymanager
after each request as described by
http://javanotepad.blogspot.se/2007/08/managing-jpa-entitymanager-lifecycle.html
Haven't used all parts of the information but I'm cleaning up entity manager
after each request with:
public static void destroyEntityManager() {
if(entityManagers.get() == null) return;
for(String emName : entityNameList) {
if(entityManagers.get().get(emName) != null) {
entityManagers.get().get(emName).close();
}
}
entityManagers.set(null);
}
Here is my context settings for the datasource container.
<Resource name="jdbc/testDb" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="testuser"
password="testpwd" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/obn?jdbcCompliantTruncation=false&characterEncoding=utf8"
removeAbandoned="true" logAbandoned="true"/>
> Nullpointer exception when persisting object during high load
> -------------------------------------------------------------
>
> Key: OPENJPA-2193
> URL: https://issues.apache.org/jira/browse/OPENJPA-2193
> Project: OpenJPA
> Issue Type: Bug
> Reporter: Daniel Persson
> Priority: Minor
> Attachments: patch-tomcat-pooling-fix.patch
>
>
> During high load and many persists _conn is null during commit.
> Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: null
> at
> org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:2034)
> at
> org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:94)
> at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1514)
> at
> org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:933)
> at
> org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:570)
> ... 29 more
> Caused by: java.lang.NullPointerException
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.commit(JDBCStoreManager.java:196)
> at
> org.apache.openjpa.kernel.DelegatingStoreManager.commit(DelegatingStoreManager.java:95)
> at
> org.apache.openjpa.datacache.DataCacheStoreManager.commit(DataCacheStoreManager.java:88)
> at
> org.apache.openjpa.kernel.DelegatingStoreManager.commit(DelegatingStoreManager.java:95)
> at
> org.apache.openjpa.kernel.BrokerImpl.endStoreManagerTransaction(BrokerImpl.java:1471)
> at
> org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2351)
> at
> org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:2010)
> ... 33 more
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira