问题描述
最近要把hibernate从3.2升级到3.67。更换JAR包之后,报以下错误,但那个entity在hibernate3.jar包里面是有。先谢谢大家!gframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)atweblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:465)atweblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)atweblogic.security.service.SecurityManager.runAs(UnknownSource)atweblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:175)atweblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1784)atweblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2999)atweblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1371)atweblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)atweblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)atweblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)atweblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)atweblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)atweblogic.application.internal.EarDeployment.activate(EarDeployment.java:16)atweblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)atweblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)atweblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)atweblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)atweblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)atweblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:196)atweblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)atweblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)atweblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)atweblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)atweblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)atweblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)atweblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)atweblogic.work.ExecuteThread.execute(ExecuteThread.java:201)atweblogic.work.ExecuteThread.run(ExecuteThread.java:173)java.lang.NoClassDefFoundError:org/hibernate/annotations/Entityatorg.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean.<init>(AnnotationSessionFactoryBean.java:93)atsun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)atjava.lang.reflect.Constructor.newInstance(Constructor.java:513)atorg.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)atorg.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)atweblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:465)atweblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)atweblogic.security.service.SecurityManager.runAs(UnknownSource)atweblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:175)atweblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1784)atweblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2999)atweblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1371)atweblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)atweblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)atweblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)atweblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)atweblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)atweblogic.application.internal.EarDeployment.activate(EarDeployment.java:16)atweblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)atweblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)atweblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)atweblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)atweblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)atweblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:196)atweblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)atweblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)atweblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)atweblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)atweblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)atweblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)atweblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)atweblogic.work.ExecuteThread.execute(ExecuteThread.java:201)atweblogic.work.ExecuteThread.run(ExecuteThread.java:173)>
解决方案
解决方案二:
java.lang.ClassNotFoundException:org.hibernate.annotations.Entityatweblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)atweblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)atjava.lang.ClassLoader.loadClass(ClassLoader.java:306)atjava.lang.ClassLoader.loadClass(ClassLoader.java:251)atweblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)atjava.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)atorg.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean.<init>(AnnotationSessionFactoryBean.java:93)atsun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)atjava.lang.reflect.Constructor.newInstance(Constructor.java:513)atorg.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)atorg.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)atweblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:465)atweblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)atweblogic.security.service.SecurityManager.runAs(UnknownSource)atweblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:175)atweblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1784)atweblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2999)atweblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1371)atweblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)atweblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)atweblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)atweblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)atweblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)atweblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)atweblogic.application.internal.EarDeployment.activate(EarDeployment.java:16)atweblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)atweblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)atweblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)atweblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)atweblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)atweblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:196)atweblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)atweblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)atweblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)atweblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)atweblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)atweblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)atweblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)atweblogic.work.ExecuteThread.execute(ExecuteThread.java:201)atweblogic.work.ExecuteThread.run(ExecuteThread.java:173)
解决方案三:
看看有没有重复的包或者少包
解决方案四:
引用2楼aqqbjlgu的回复:
看看有没有重复的包或者少包
org.hibernate.annotations.Entity这个类在hibernate3.jar包里是有的。
解决方案五:
有没有重复的包?
解决方案六:
弄了好几天。把hibernate-jpa-2.0-api-1.0.1.Final.jar包重命名为javax.persistence_1.0.0.0_1-0.jar然后覆盖到D:bea103modules(weblogic安装目录)目录下就正常了,不知道是什么原因呢?
解决方案七:
引用5楼brave112的回复:
弄了好几天。把hibernate-jpa-2.0-api-1.0.1.Final.jar包重命名为javax.persistence_1.0.0.0_1-0.jar然后覆盖到D:bea103modules(weblogic安装目录)目录下就正常了,不知道是什么原因呢?
什么情况??
解决方案八:
解决方案九:
引用5楼brave112的回复:
弄了好几天。把hibernate-jpa-2.0-api-1.0.1.Final.jar包重命名为javax.persistence_1.0.0.0_1-0.jar然后覆盖到D:bea103modules(weblogic安装目录)目录下就正常了,不知道是什么原因呢?
是不是hibernate-jpa-2.0-api-1.0.1.Final.jar和javax.persistence_1.0.0.0_1-0.jar有相同的Entity类导致调用混淆了
解决方案十:
你hibernate2的jar都完全删除了吗?在工程里面搜一下,看org.hibernate.annotations.Entity这个class文件有几个?如果有多个,系统就不知道找哪一个,报找不到错误了。
解决方案十一:
什么情况?我也遇到了这个问题,求合理的解决方法