2

将ehcache与jpa和hibernate一起使用时出现问题。在这个项目中,我有两个实体:Country 和 Provider,具有 ManyToMany 关系和一个附加列(我想知道是否为特定国家启用了提供程序)。
我最初的方法是使用带有组合主键的第三个实体 CountryProvider,但由于设置涉及的复杂性并听取这些人的意见(http://en.wikibooks.org/wiki/Java_Persistence/ManyToMany)“为了让你的生活更简单,我建议将生成的 Id 属性添加到关联类”。我添加了一个人工主键并将这两个实体映射为onetomany。
只有当我想在 glassfish 上部署时,我才会遇到这个僵局:

    Java stack information for the threads listed above:
===================================================
"net.sf.ehcache.CacheManager@72d47b5a":
    at org.glassfish.web.loader.WebappClassLoader.extractResources(WebappClassLoader.java:2267)
    - waiting to lock <0x00000000e2e6c8b0> (a org.glassfish.web.loader.WebappClassLoader)
    at org.glassfish.web.loader.WebappClassLoader.findResourceInternalFromJars(WebappClassLoader.java:2253)
    at org.glassfish.web.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:2095)
    - locked <0x00000000e2f202a0> (a [Ljava.util.jar.JarFile;)
    at org.glassfish.web.loader.WebappClassLoader.findResource(WebappClassLoader.java:1036)
    at org.glassfish.web.loader.WebappClassLoader.findResource(WebappClassLoader.java:1020)
    at org.glassfish.web.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:1254)
    at java.lang.Class.getResourceAsStream(Class.java:2032)
    at net.sf.ehcache.util.ProductInfo.parseProductInfo(ProductInfo.java:67)
    at net.sf.ehcache.util.ProductInfo.<init>(ProductInfo.java:49)
    at net.sf.ehcache.util.ProductInfo.<init>(ProductInfo.java:40)
    at net.sf.ehcache.util.UpdateChecker.buildParamsString(UpdateChecker.java:125)
    at net.sf.ehcache.util.UpdateChecker.buildUpdateCheckUrl(UpdateChecker.java:121)
    at net.sf.ehcache.util.UpdateChecker.doCheck(UpdateChecker.java:69)
    at net.sf.ehcache.util.UpdateChecker.checkForUpdate(UpdateChecker.java:60)
    at net.sf.ehcache.util.UpdateChecker.run(UpdateChecker.java:51)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)
"admin-thread-pool-4848(5)":
    at org.glassfish.web.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:2095)
    - waiting to lock <0x00000000e2f202a0> (a [Ljava.util.jar.JarFile;)
    at org.glassfish.web.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:2066)
    at org.glassfish.web.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1976)
    at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:901)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1476)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
    at org.hibernate.hql.internal.ast.SqlASTFactory.initializeSqlNode(SqlASTFactory.java:242)
    at org.hibernate.hql.internal.ast.SqlASTFactory.create(SqlASTFactory.java:257)
    at antlr.ASTFactory.create(ASTFactory.java:153)
    at antlr.ASTFactory.create(ASTFactory.java:186)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:543)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:248)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
    - locked <0x00000000f8044b10> (a org.hibernate.hql.internal.ast.QueryTranslatorImpl)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
    at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:1132)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:525)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:206)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:120)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

Found 1 deadlock.

PS 我使用休眠 4.1.4、ehcache 2.6.0、glassfish 3.1.2、jpa2.0

4

0 回答 0