我正在尝试将Hibernate JPA与Google AppEngine一起用于与我的Google Cloud SQL实例进行通信。 在创建用于保存数据的实体管理器工厂时,我在appengine日志中看到以下异常:
javax.persistence.PersistenceException: Unable to build entity manager factory
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:81)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
...
com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:724)
**Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")**
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
at java.security.AccessController.checkPermission(AccessController.java:565)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:56)
at com.google.apphosting.runtime.security.CustomSecurityManager.checkAccess(CustomSecurityManager.java:131)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
at java.lang.Thread.init(Thread.java:378)
at java.lang.Thread.<init>(Thread.java:654)
at java.util.concurrent.Executors$DefaultThreadFactory.newThread(Executors.java:572)
at java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:591)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:922)
...
我在https://developers.google.com/appengine/articles/using_hibernate中创建了我的persistence.xml和代码,但仍然得到了modifyThreadGroup的RunTimeException。我正在使用Hibernate 4.3.1.Final。有谁知道如何解决这一问题 ?我查看了现有的modifyThreadGroup异常解决方案,但那些不适用于我,因为我没有在本地运行,我正在运行GAE实例,所以我不能在eclipse项目中取消选中“使用GAE”。
答案 0 :(得分:1)
我今天遇到了同样的问题,我找到了另一个问题,答案对我有用。根据这个answer,您必须使用4.2.0.Final版本的Hibernate,因为在较新版本中,DriverManagerConnectionProvider会尝试创建新线程。