java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z出错解决

今天整合最新的struts2.3.15.1+spring3.2.3+hibernate4.2.3

用的是weblogic,忘记什么版本,总之10以上

结果使用注解方式配置一对一映射的时候,发布项目报错。

出错显示如下:

 

ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319)
org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
	at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1868)
	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
	at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
	at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
	at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
	at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
	at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44)
	at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
	at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
	at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
	at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
	at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
	at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
	at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
	at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
	at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
	at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
	at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
	at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
	at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1641)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3512)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3466)
	at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1756)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
	at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247)
	at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373)
	at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
	... 48 more
<2013-8-5 下午04时48分28秒 CST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1641)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3512)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3466)
	Truncated. see log file for complete stacktrace
> 
<2013-8-5 下午04时48分28秒 CST> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application '_appsdir_ssh2_dir'.
weblogic.application.ModuleException: 
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1520)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
	Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1641)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3512)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3466)
	Truncated. see log file for complete stacktrace
> 
<2013-8-5 下午04时48分28秒 CST> <Notice> <LoggingService> <BEA-320400> <The log file D:\oracle\Middleware\user_projects\domains\base_domain\servers\AdminServer\logs\base_domain.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms like Windows.> 
<2013-8-5 下午04时48分28秒 CST> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to D:\oracle\Middleware\user_projects\domains\base_domain\servers\AdminServer\logs\base_domain.log00779. Log messages will continue to be logged in D:\oracle\Middleware\user_projects\domains\base_domain\servers\AdminServer\logs\base_domain.log.> 
<2013-8-5 下午04时48分28秒 CST> <Notice> <Log Management> <BEA-170027> <The Server has established connection with the Domain level Diagnostic Service successfully.> 
<2013-8-5 下午04时48分28秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN> 
<2013-8-5 下午04时48分28秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING> 
ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319)
org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
	at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1868)
	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
	at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
	at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
	at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
	at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
	at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44)
	at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
	at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
	at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
	at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
	at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
	at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
	at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
	at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
	at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
	at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
	at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1641)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3512)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3466)
	at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1756)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
	at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247)
	at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373)
	at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
	... 49 more
<2013-8-5 下午04时48分33秒 CST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1641)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3512)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3466)
	Truncated. see log file for complete stacktrace
> 
<2013-8-5 下午04时48分33秒 CST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1375692508859' for task '0'. Error is: 'weblogic.application.ModuleException: '
weblogic.application.ModuleException: 
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1520)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
	Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1641)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3512)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3466)
	Truncated. see log file for complete stacktrace
> 
<2013-8-5 下午04时48分33秒 CST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application '_appsdir_ssh2_dir'.> 
<2013-8-5 下午04时48分33秒 CST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application '_appsdir_ssh2_dir'.> 
<2013-8-5 下午04时48分33秒 CST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: 
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1520)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
	Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1641)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3512)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3466)
	Truncated. see log file for complete stacktrace
> 

 

网上找了很多答案,都是jar包有冲突什么的。

一般的按照这个解决就行:

http://hi.baidu.com/woodcock1017/item/4172f72ce52a870971863e94 写道
解决办法汇总:java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
今天用了OneToOne注解,结果报异常java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
网上有几种解决的方法,现在汇总如下
(1)
如果是使用MyEclipse创建JavaEE5.0的Web项目,解决办法:删除对Java EE 5 Libraries的使用。
问题原因:javaee.jar中的部分类与hibernate-jpa-2.0-api-1.0.0.Final.jar存在版本冲突。
参考文章:http://hi.baidu.com/siasmen/blog/item/7253e954e3abdb55d0090607.html
(2)
如果使用了ejb的jar包,删除引用,
问题原因:与hibernate-jpa-2.0-api-1.0.0.Final.jar冲突
(3)
如果是用junit测试,junit4自带的jpa包与hibernate的jpa包冲突

本人是第一种问题,一般好像都是第一种和第二种。
另外奇异的是本人只在使用OneToOne注解时报了错,而只用ManyToOne的时候却没有。。。题外话了,不知道为何

另转载注明请出处http://hi.baidu.com/woodcock1017/blog/item/cde710dc2f981ef877c63811.html

 但我的既没有用ejb和junit,也是用javaEE6版本,所以这三个方案都不行。

意外地找到另一篇文章,于是受到启发:

http://www.uroot.com/archives/389 写道
javax.persistence.OneToMany.orphanRemoval()Z的另一种原因及解决办法
2012年2月21日 由 urootcom 阅读:994 次 留言 »
项目的持久层替换为了Hibernate3.6.9,本地tomcat启动正常,bamboo自动发布项目到开发服务器(部署到Resin)上,访问项目服务出现:javax.persistence.OneToMany.orphanRemoval()Z异常 。

第一反应是,Maven的配置中存在问题,检查maven的配置,没有发现配置上的问题,软件版本的引用正确。接着到网上搜索,出现最多的答案是:Java EE 5 Libraries和Hibernate的冲突,还有,hibernate-jpa-2.0-api-1.0.0.Final和ejb3-persistence有冲突。但是我们的项目这方面配置没有问题。

接着分析问题的原因,本地启动正确,而开发服务器的启动有问题,差异在于部署的服务器Tomcat和Resin上,检查线上Resin的lib目录中有一个jpa-15.jar,查看这个jar文件只有一个package:javax.persistence,当中包括OneToMany文件,问题明确了。解决的办法是备份jpa-15.jar,然后删除,重新启动resin,访问项目,问题解决。

不负责猜测,Resin提供部分JPA功能,但服务器的版本难和软件版本同步,不知算不算Resin的问题?

问题总结:JavaEE项目中因为class的冲突导致的启动,运行问题比较多,尤其是开发经验较少的时候,非常让人头疼。此类问题,有一种常用的解决办法,可以在运行的代码中,打印出现问题的类路径信息。得到当前类信息的办法,通过Java反射,下面是其中一个方法。
类路径查找方法,打印如下信息:

Class.forName( "package+className" ).getProtectionDomain().getCodeSource().getLocation().getFile();
以javax.persistence.OneToMany为例,我的项目在Windows+Tomcat上,

System.out.println(Class.forName( "javax.persistence.OneToMany" ).getProtectionDomain().getCodeSource().getLocation().getFile());
信息的内容大致如:
D:/apache-tomcat-6.0.32/webapps/*****/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar
通过以上方法,可以快速的想要定位的类是否正确加载。

PS:上面的方法不要对外暴露,否则能够泄露服务器的路径信息。

 上面写到,什么类出错,可以让控制台输出这个类所在的目录,于是就可以找到问题所在了。

这种解决方法特别适合NoSuchMethodError和包冲突的情况。

于是我找到了在我的D盘目录:D:\oracle\Middleware\modules

下面一大堆jar包库。。。

我把MyEclipse的JavaEE6的javax.persistence.jar包复制过去,然后全部替换javax.persistence*.jar文件(一定要跟原来这个目录的文件名一样),再次启动项目,无错,正确运行。。。果然解决掉!

 

还真是非常感谢http://www.uroot.com/archives/389的博主。

正所谓授人与鱼不如授人与渔!

你可能感兴趣的:(weblogic,Hibernate4)