现在观察到createEntityManagerFactory失败了。堆栈跟踪对我来说有点困惑。任何人都能对它有所了解吗?
java.lang.StackOverflowError
at java.io.File.list(File.java:1133)
at java.io.File.listFiles(File.java:1297)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:90)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:74)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:54)
at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:89)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:302)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:276)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:150)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:135)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:129)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:129)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:129)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:129)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
....
...
..
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:129)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
在进一步跟踪时,我发现在现有的EntityManagerFactory失败后创建新的EntityManagerFactory时会发生这种情况,但有以下例外:
代码:
synchronized (factoryLock) {
if (null != emFactory) {
if (true == emFactory.isOpen()) {
try {
emFactory.close();
} catch (IllegalStateException e) {
System.out.println(e.getMessage());
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
emFactory = null;
}
Map<String, String> properties = new HashMap<String, String>();
properties.put(PersistenceUnitProperties.JDBC_DRIVER, jdbcDriver);
properties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER,
"com.ca.waae.dbaccess.custom.JPASessionCustomizer");
properties.put(PersistenceUnitProperties.JDBC_URL, jdbcUrl);
properties.put(PersistenceUnitProperties.JDBC_PROPERTY+"REQUEST_KERBEROS_SESSION", "true");
properties.put(PersistenceUnitProperties.JDBC_PROPERTY+"SERVICE_PRINCIPAL_NAME", dbPrincipalName);
emFactory = Persistence.createEntityManagerFactory(
"JPA", properties);
}
例外:
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1440)
at java.util.HashMap$ValueIterator.next(HashMap.java:1469)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.clearStatementCache(DatabaseAccessor.java:342)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.disconnect(DatabaseAccessor.java:505)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.disconnect(DatabaseSessionImpl.java:415)
at org.eclipse.persistence.sessions.server.ServerSession.disconnect(ServerSession.java:504)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.logout(DatabaseSessionImpl.java:931)
at org.eclipse.persistence.sessions.server.ServerSession.logout(ServerSession.java:776)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.removeSessionFromGlobalSessionManager(EntityManagerSetupImpl.java:511)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.undeploy(EntityManagerSetupImpl.java:2850)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.close(EntityManagerFactoryDelegate.java:267)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.close(EntityManagerFactoryImpl.java:287)
at com.ca.waae.dbaccess.dao.AEConnection.createJpaEntityFactory(AEConnection.java:144)
persistent.xml内容类似于
?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.
com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="JPA">
<class>com.xx.yy.dbaccess.model.table1</class>
<class>com.xx.yy.dbaccess.model.table2</class>
<class>com.xx.yy.dbaccess.model.table3</class>
<class>com.xx.yy.dbaccess.model.table4</class>
<class>com.xx.yy.dbaccess.model.table5</class>
<properties>
<property name="eclipselink.logging.level" value="ALL"/>
<property name="eclipselink.jdbc.cache-statements" value="true"/>
<property name="eclipselink.jpa.uppercase-column-names " value="false"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.weaving" value="static"/>
</properties>
</persistence-unit>
</persistence>