在使用 Hibernate 进行数据库操作的时候,在启动 Tomcat 服务器后,Console 控制台可能会打印出这样的异常:java.lang.NoClassDefFoundError: javax/persistence/EntityListeners

一、异常描述:

 严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'mysessionFactory' defined in class path resource [spring/applicationContext.xml]:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:
javax/persistence/EntityListeners
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean
(AbstractAutowireCapableBeanFactory.java:555)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject
(AbstractBeanFactory.java:306)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton
(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean
(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:197)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:742)
at
org.springframework.context.support.AbstractApplicationContext.
finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:542)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext
(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext
(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized
(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart
(StandardContext.java:5068)
at org.apache.catalina.core.StandardContext.startInternal
(StandardContext.java:5584)
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.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults
(JPAMetadataProvider.java:96)
at
org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults
(JavaReflectionManager.java:226)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1385)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory
(LocalSessionFactoryBean.java:660)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet
(AbstractSessionFactoryBean.java:191)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 25 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
(WebappClassLoaderBase.java:1858)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
(WebappClassLoaderBase.java:1701)
... 33 more
五月 08, 2017 7:31:51 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'mysessionFactory' defined in class path resource [spring/applicationContext.xml]:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:
javax/persistence/EntityListeners
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean
(AbstractAutowireCapableBeanFactory.java:555)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject
(AbstractBeanFactory.java:306)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton
(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean
(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:197)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:742)
at
org.springframework.context.support.AbstractApplicationContext.
finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:542)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext
(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext
(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized
(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart
(StandardContext.java:5068)
at org.apache.catalina.core.StandardContext.startInternal
(StandardContext.java:5584)
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.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults
(JPAMetadataProvider.java:96)
at
org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults
(JavaReflectionManager.java:226)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1385)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory
(LocalSessionFactoryBean.java:660)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet
(AbstractSessionFactoryBean.java:191)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 25 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
(WebappClassLoaderBase.java:1858)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
(WebappClassLoaderBase.java:1701)
... 33 more

二、错误分析:

Hibernate 需要 jpa 支持,检查 WEB-INF/lib 下是否缺少 jpa 的 jar 包 hibernate-jpa-2.0-api-1.0.1.Final.jar ,

导入即可。

java.lang.NoClassDefFoundError: javax/persistence/EntityListeners的更多相关文章

  1. java.lang.ClassNotFoundException: javax.persistence.EntityListeners

    Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListene ...

  2. Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners

    Answer: This seems to be caused by Hibernate 3.6. It is now dependent on JPA, so it must have a JPA ...

  3. Caused by: java.lang.ClassNotFoundException: javax.persistence.NamedStoredProcedureQuery

    1.错误描述 2014-7-12 21:06:37 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreat ...

  4. Caused by: java.lang.ClassNotFoundException: javax.persistence.Entity

    1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...

  5. java.lang.NoClassDefFoundError: javax/el/ELResolver 问题解决

    HTTP Status 500 - java.lang.NoClassDefFoundError: javax/el/ELResolver type Exception report message ...

  6. spring -java.lang.NoClassDefFoundError: javax/mail/MessagingException

    今天遇到这个问题,网上找了半天,终于解决了,最后记录一下. spring集成了mail,于是就测试了下,结果报了java.lang.NoClassDefFoundError: javax/mail/M ...

  7. Caused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode

    进行 spring mvc jpa整合时.Junit方法测试时. 异常: org.springframework.beans.factory.BeanCreationException: Error ...

  8. java.lang.NoClassDefFoundError: javax/transaction/UserTransaction

    在运行定时任务的时候报错: Java.lang.NoClassDefFoundError: javax/transaction/UserTransaction 原因:缺少jta的jar包 解决方法:下 ...

  9. 执行quartz报错java.lang.NoClassDefFoundError: javax/transaction/UserTransaction

    使用maven ,可以在 http://mvnrepository.com 中去查找 pom 配置如何写 <!-- https://mvnrepository.com/artifact/org. ...

随机推荐

  1. UIViewController的初始化

    UIViewController的初始化一般有两个: -(instancetype)init; -(instancetype)initWithNibName:(NSString *)nibNameOr ...

  2. 将输出语句打印至tomcat日志文件中

    tomcat-9.0.0 将程序中            System.out.println("------------这是输出语句System.out.println()-------- ...

  3. idea 安装lombok 插件过程

    一.作用 Lombok是一个可以通过简单的注解的形式来帮助我们简化消除一些必须有但显得很臃肿的 Java 代码的工具,bean,entity等类,绝大部分数据类类中都需要get.set.toStrin ...

  4. ASP.NET中的另类控件

    首先看一个aspx文件里的部分内容: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  5. 学号20155308 2016-2017-2 《Java程序设计》第5周学习总结

    学号20155308 2016-2017-2 <Java程序设计>第5周学习总结 教材学习内容总结 8.1 语法与继承架构 使用try...catch 注意多个catch一定把父类放后面 ...

  6. 什么是EOF -- 转

    转载地址:http://www.ruanyifeng.com/blog/2011/11/eof.html 我学习C语言的时候,遇到的一个问题就是EOF. 它是end of file的缩写,表示&quo ...

  7. python实现梯度下降法

    # coding:utf-8 import numpy as np import matplotlib.pyplot as plt x = np.arange(-5/2,5/2,0.01) y = - ...

  8. Linux服务-配置Nginx反向代理

    任务目标:实现基于轮询的方式调度三台web,并验证结果:实现基于权重的方式调度三台web,并验证结果:实现基于hash的方式调用三台web,并验证结果 由于刚刚做了nfs设置,为了提现实验结果,我在w ...

  9. glut glew区别

    GLEW是一个跨平台的C++扩展库,基于OpenGL图形接口.使用OpenGL的朋友都知道,window目前只支持OpenGL1.1的涵数,但 OpenGL现在都发展到2.0以上了,要使用这些Open ...

  10. Linux内存初始化【转】

    转自:http://www.cnblogs.com/super-king/p/3291120.html start_kernel -> setup_arch 在这个函数中我们主要看这几个函数. ...