本文介绍了Tomee错误:javax.persistence.JoinColumn.foreignKey()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建我的第一个webapp。我使用hibernate,postgresql和tomee作为容器。我正在使用豆子和脸。当我尝试在我的tomee localhost上运行我的web应用程序时,一切都按预期工作。当我在我的AWS上加载它时(它有安装的同一版本的tomee),我得到这个错误。我坚持几个小时而没有得到解决方案。
这是我的catalina.out

  

谈到营销语言: TomEE 6 实现 JavaEE 6 规范。 JavaEE 6 表示 JPA 2.0 。 JPA 2.0 表示 @JoinColumn 没有 foreignKey 属性的注解。这个属性被添加到 JPA 2.1中。



说到人类语言:你有一个 jar 与旧的 javax.persistence.JoinColumn 类的类路径中。你的Hibernate版本需要一个新的 JPA 2.1 jar :类似于 hibernate-jpa-2.1-api-1.0.0.Final.jar



您已经拥有 jar ,但 TomEE 可以使用它自己的 JPA 2.0 jar 来覆盖它的一些类,例如: javaee-api-7.0.jar 与旧的 javax.persistence.JoinColumn 类。所以你需要找到并删除(或更新) jar ,或者,也许你可以调整 TomEE 来使用单独的类加载器(或从类路径中排除 JPA jar)。



要找到不正确的 jar 你可以在servlet的某处使用这段代码,或者使用 ContextListener 。

  URL url = Thread.currentThread()。getContextClassLoader()
.getResource(javax / persistence / JoinColumn.class);
System.out.println(url);

最简单的解决方法是不使用 TomeEE 。您可以使用 Tomcat 或 Wild <。

更新



@Kevgretor关于解决问题的注释
$ b


I was building my first webapp. I am using hibernate, postgresql, and tomee as container. I am using beans and faces. When i try to run my webapp on my tomee localhost everything works as expected. When i load it on my AWS (wich has the same version of tomee installed) i get this error. I'm stick since hours without getting at the solution. Here is my catalina.out

May 26, 2016 4:18:24 AM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [
        name: clinica-unit
        ...]
May 26, 2016 4:18:24 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.1.0.Final}
May 26, 2016 4:18:24 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
May 26, 2016 4:18:24 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
May 26, 2016 4:18:24 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
May 26, 2016 4:18:25 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL94Dialect
May 26, 2016 4:18:25 AM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
May 26, 2016 4:18:25 AM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@66b53b0d
May 26, 2016 4:18:26 AM org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory createDelegate
INFO: PersistenceUnit(name=clinica-unit, provider=org.hibernate.ejb.HibernatePersistence) - provider time 1747ms
May 26, 2016 4:18:26 AM org.apache.openejb.assembler.classic.Assembler destroyApplication
INFO: Undeploying app: /usr/share/apache-tomee-webprofile-1.7.4/webapps/PortaleClinica
May 26, 2016 4:18:26 AM org.apache.catalina.core.ContainerBase removeChild
SEVERE: ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/PortaleClinica]] in state [STARTING_PREP]
        at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:401)
        at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:291)
        at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1038)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1537)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1518)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.undeployWebApps(TomcatWebAppBuilder.java:762)
        at org.apache.openejb.assembler.classic.Assembler.destroyApplication(Assembler.java:1982)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:839)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:677)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
        at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

May 26, 2016 4:18:26 AM org.apache.openejb.assembler.classic.Assembler destroyResource
INFO: Closing DataSource: PortaleClinica/clinica-unit-db
May 26, 2016 4:18:26 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [/PortaleClinica] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
May 26, 2016 4:18:26 AM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal
SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/PortaleClinica]
org.apache.openejb.OpenEJBException: Creating application failed: /usr/share/apache-tomee-webprofile-1.7.4/webapps/PortaleClinica: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:843)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:677)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
        at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
        at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:2898)
        at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1742)
        at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:906)
        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
        at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:848)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:876)
        at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:50)
        at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:64)
        at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:116)
        at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.<init>(ReloadableEntityManagerFactory.java:102)
        at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:154)
        at org.apache.openejb.assembler.classic.Assembler.loadPersistenceUnits(Assembler.java:982)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:741)
        ... 18 more

May 26, 2016 4:18:26 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/PortaleClinica]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Creating application failed: /usr/share/apache-tomee-webprofile-1.7.4/webapps/PortaleClinica: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
        at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1270)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
        at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 10 more
Caused by: org.apache.openejb.OpenEJBException: Creating application failed: /usr/share/apache-tomee-webprofile-1.7.4/webapps/PortaleClinica: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:843)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:677)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
        ... 16 more
Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
        at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:2898)
        at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1742)
        at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:906)
        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
        at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:848)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:876)
        at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:50)
        at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:64)
        at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:116)
        at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.<init>(ReloadableEntityManagerFactory.java:102)
        at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:154)
        at org.apache.openejb.assembler.classic.Assembler.loadPersistenceUnits(Assembler.java:982)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:741)
        ... 18 more

May 26, 2016 4:18:26 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /usr/share/apache-tomee-webprofile-1.7.4/webapps/PortaleClinica.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/PortaleClinica]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

May 26, 2016 4:18:26 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /usr/share/apache-tomee-webprofile-1.7.4/webapps/PortaleClinica.war has finished in 3,950 ms
May 26, 2016 4:18:26 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/manager
May 26, 2016 4:18:26 AM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: ------------------------- localhost -> /manager
May 26, 2016 4:18:26 AM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /usr/share/apache-tomee-webprofile-1.7.4/webapps/manager
May 26, 2016 4:18:26 AM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/usr/share/apache-tomee-webprofile-1.7.4/webapps/manager" loaded.
May 26, 2016 4:18:26 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /usr/share/apache-tomee-webprofile-1.7.4/webapps/manager
May 26, 2016 4:18:26 AM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@53743c4f
May 26, 2016 4:18:26 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
May 26, 2016 4:18:26 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
May 26, 2016 4:18:26 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
May 26, 2016 4:18:26 AM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
INFO: All injection points were validated successfully.
May 26, 2016 4:18:26 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 127 ms.
May 26, 2016 4:18:26 AM org.apache.tomee.catalina.TomcatWebAppBuilder deployWebApps
INFO: using context file /usr/share/apache-tomee-webprofile-1.7.4/webapps/manager/META-INF/context.xml
May 26, 2016 4:18:26 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/usr/share/apache-tomee-webprofile-1.7.4/webapps/manager)
May 26, 2016 4:18:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/manager has finished in 706 ms
May 26, 2016 4:18:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/ROOT
May 26, 2016 4:18:27 AM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: ------------------------- localhost -> /
May 26, 2016 4:18:27 AM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /usr/share/apache-tomee-webprofile-1.7.4/webapps/ROOT
May 26, 2016 4:18:27 AM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/usr/share/apache-tomee-webprofile-1.7.4/webapps/ROOT" loaded.
May 26, 2016 4:18:27 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /usr/share/apache-tomee-webprofile-1.7.4/webapps/ROOT
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@53743c4f
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
May 26, 2016 4:18:27 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
May 26, 2016 4:18:27 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
May 26, 2016 4:18:27 AM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
INFO: All injection points were validated successfully.
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 12 ms.
May 26, 2016 4:18:27 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/usr/share/apache-tomee-webprofile-1.7.4/webapps/ROOT)
May 26, 2016 4:18:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/ROOT has finished in 127 ms
May 26, 2016 4:18:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/docs
May 26, 2016 4:18:27 AM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: ------------------------- localhost -> /docs
May 26, 2016 4:18:27 AM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /usr/share/apache-tomee-webprofile-1.7.4/webapps/docs
May 26, 2016 4:18:27 AM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/usr/share/apache-tomee-webprofile-1.7.4/webapps/docs" loaded.
May 26, 2016 4:18:27 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /usr/share/apache-tomee-webprofile-1.7.4/webapps/docs
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@53743c4f
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
May 26, 2016 4:18:27 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
May 26, 2016 4:18:27 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
May 26, 2016 4:18:27 AM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
INFO: All injection points were validated successfully.
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 7 ms.
May 26, 2016 4:18:27 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/usr/share/apache-tomee-webprofile-1.7.4/webapps/docs)
May 26, 2016 4:18:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/docs has finished in 125 ms
May 26, 2016 4:18:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/host-manager
May 26, 2016 4:18:27 AM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: ------------------------- localhost -> /host-manager
May 26, 2016 4:18:27 AM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /usr/share/apache-tomee-webprofile-1.7.4/webapps/host-manager
May 26, 2016 4:18:27 AM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/usr/share/apache-tomee-webprofile-1.7.4/webapps/host-manager" loaded.
May 26, 2016 4:18:27 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /usr/share/apache-tomee-webprofile-1.7.4/webapps/host-manager
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@53743c4f
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
May 26, 2016 4:18:27 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
May 26, 2016 4:18:27 AM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
May 26, 2016 4:18:27 AM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
INFO: All injection points were validated successfully.
May 26, 2016 4:18:27 AM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 8 ms.
May 26, 2016 4:18:27 AM org.apache.tomee.catalina.TomcatWebAppBuilder deployWebApps
INFO: using context file /usr/share/apache-tomee-webprofile-1.7.4/webapps/host-manager/META-INF/context.xml
May 26, 2016 4:18:27 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/usr/share/apache-tomee-webprofile-1.7.4/webapps/host-manager)
May 26, 2016 4:18:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/share/apache-tomee-webprofile-1.7.4/webapps/host-manager has finished in 120 ms
May 26, 2016 4:18:27 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 26, 2016 4:18:27 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 26, 2016 4:18:27 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5129 ms

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>PortaleClinica</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

  <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
  </context-param>

  <!-- Facelets pages will use the .xhtml extension -->

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

   <filter>
    <filter-name>AuthFilter</filter-name> <!-- mandatory -->
    <filter-class>it.uniroma3.servlet.AuthFilterServlet</filter-class> <!-- mandatory -->
  </filter>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>

   <filter-mapping>
        <filter-name>AuthFilter</filter-name>
        <url-pattern>/amministrazione/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>AuthFilter</filter-name>
        <url-pattern>/utente/*</url-pattern>
    </filter-mapping>

</web-app>

resources.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <Resource id="clinica-unit-db" type="DataSource">
        #  PostgreSQL example
        #
        #  This connector will not work until you download the driver at:
        #  http://jdbc.postgresql.org/download.html
        JdbcDriver   org.postgresql.Driver
        JdbcUrl  jdbc:postgresql://localhost/clinica
        UserName     postgres
        Password     postgres
    </Resource>
</resources>

persistence.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="clinica-unit" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>clinica-unit-db</jta-data-source>
        <class>it.uniroma3.db.Medico</class>
        <class>it.uniroma3.db.Utente</class>
        <class>it.uniroma3.db.TipologiaEsame</class>
        <class>it.uniroma3.db.Esame</class>
    </persistence-unit>
</persistence>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
    version="2.1">
</faces-config>

This Java EE is really annoying me.

解决方案

Speaking on the marketing language: TomEE 6 implements JavaEE 6 specification. JavaEE 6 means JPA 2.0. JPA 2.0 means @JoinColumn annotation without foreignKey property. This property was added in JPA 2.1.

Speaking on the human language: you have a jar in the class path with an old javax.persistence.JoinColumn class. Your version of Hibernate needs a new JPA 2.1 jar: something like hibernate-jpa-2.1-api-1.0.0.Final.jar.

You can already has this jar, but TomEE can override some classes from it, using its own JPA 2.0 jar, for an example: javaee-api-7.0.jar with an old javax.persistence.JoinColumn class. So you need to find and delete (or update) that jar, or, maybe, you can tweak TomEE to use separate classloaders (or exclude JPA jars from the class path).

To find incorrect jar you can use this code, somewhere in the servlet, or using ContextListener.

URL url = Thread.currentThread().getContextClassLoader()
    .getResource("javax/persistence/JoinColumn.class");
System.out.println(url);

The simplest workaround is not using TomeEE. You can useTomcat or Wildfly.

Update

@Kevgretor comment about fixing the problem

这篇关于Tomee错误:javax.persistence.JoinColumn.foreignKey()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 01:28