Tomee error: javax.persistence.JoinColumn.foreignKey()

为君一笑 提交于 2019-12-12 03:52:03

问题


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.


回答1:


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

I followed your suggestion..but i found that tomcat dosen't support EJB so i had to go back to TomEE. I solved this problem by rearranging libraries inside tomee/lib and WEB-INF/lib (only hibernate-jpa-2.1-api-1.0.0.Final has to be inside tomee's library). Another weird fact was that if i clone my working local tomee folder on my server didn't worked (nullpointerexception for jsf initialization). I finally got it working by adding javax.faces-2.2.8.jar in WEB-INF/lib (tomee didn't like it in his lib folder).




回答2:


You can use tomee 7 or just upgrade JPA API jar in tomee/lib (needs to be before tomee/lib/javaee-api in conf/catalina.properties#common.loader) as workarounds.



来源:https://stackoverflow.com/questions/37451711/tomee-error-javax-persistence-joincolumn-foreignkey

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!