Tomee错误:javax.persistence.JoinColumn.foreignKey()

时间:2016-05-26 04:36:32

标签: hibernate jpa java-ee tomee

我正在构建我的第一个webapp。我正在使用hibernate,postgresql和tomee作为容器。我正在使用豆子和面孔。当我尝试在我的tomee localhost上运行我的webapp时,一切都按预期工作。当我将它加载到我的AWS(安装了相同版本的tomee)时,我收到此错误。我已经坚持了几个小时没有得到解决方案。 这是我的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>

这个Java EE真让我讨厌。

2 个答案:

答案 0 :(得分:1)

您可以使用tomee 7或只是升级tomee / lib中的JPA API jar(需要在conf / catalina.properties#common.loader中的tomee / lib / javaee-api之前)作为变通方法。

答案 1 :(得分:0)

说到营销语言:TomEE 6实现JavaEE 6规范。 JavaEE 6表示JPA 2.0JPA 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)。< / p>

要查找不正确的jar,您可以在servlet中的某个位置使用此代码,或使用ContextListener

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

最简单的解决方法是不使用TomeEE。您可以使用TomcatWildfly

<强>更新

@Kevgretor关于修复问题的评论

  

我遵循了你的建议..但我发现tomcat不支持EJB所以我不得不回到TomEE。我通过重新排列tomee / lib和WEB-INF / lib中的库来解决这个问题(只有hibernate-jpa-2.1-api-1.0.0.Final必须在tomee的库中)。另一个奇怪的事实是,如果我在我的服务器上克隆我的工作本地tomee文件夹没有工作(对于jsf初始化,nullpointerexception)。我终于通过在WEB-INF / lib中添加javax.faces-2.2.8.jar来实现它(tomee并不喜欢它在lib文件夹中)。