问题描述
org.hibernate.engine.SessionFactoryImplementor三月13,201511:43:07上午org.apache.catalina.core.StandardContextlistenerStart严重:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationExceptionErrorcreatingbeanwithnamesysUserDao':Injectionofresourcedependenciesfailed;nestedexceptionisjava.lang.NoClassDefFoundError:org/hibernate/engine/SessionFactoryImplementoratorg.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4630)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)atorg.apache.catalina.core.StandardHost.start(StandardHost.java:785)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)atorg.apache.catalina.startup.Embedded.start(Embedded.java:825)atorg.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)atorg.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)atorg.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)atorg.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)atorg.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)atorg.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)atorg.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)atorg.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)atorg.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)atorg.apache.maven.cli.MavenCli.execute(MavenCli.java:584)atorg.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)atorg.apache.maven.cli.MavenCli.main(MavenCli.java:157)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:606)atorg.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)atorg.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)atorg.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Causedby:java.lang.NoClassDefFoundError:org/hibernate/engine/SessionFactoryImplementoratorg.springframework.orm.hibernate3.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:123)atorg.springframework.orm.hibernate3.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:412)atorg.springframework.orm.hibernate3.HibernateTransactionManager.<init>(HibernateTransactionManager.java:175)atcn.jacore.db.AbstractBaseDao.setSessionFactory(AbstractBaseDao.java:76)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:606)atorg.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:164)atorg.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)atorg.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)...43moreCausedby:java.lang.ClassNotFoundException:org.hibernate.engine.SessionFactoryImplementoratorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)...54more
解决方案
解决方案二:
spring-jdbc.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:jee="http://www.springframework.org/schema/jee"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:lang="http://www.springframework.org/schema/lang"xmlns:jpa="http://www.springframework.org/schema/data/jpa"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.0.xsdhttp://www.springframework.org/schema/langhttp://www.springframework.org/schema/lang/spring-lang-2.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.0.xsdhttp://www.springframework.org/schema/jeehttp://www.springframework.org/schema/jee/spring-jee-2.0.xsdhttp://www.springframework.org/schema/data/jpahttp://www.springframework.org/schema/data/jpa/spring-jpa.xsd"><!--读取配置文件--><beanid="configProperties"class="org.springframework.beans.factory.config.PropertiesFactoryBean"><propertyname="locations"><list><value>classpath:setting.properties</value><value>classpath:jdbc.properties</value></list></property></bean><beanid="propertyConfigurer"class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"><propertyname="properties"ref="configProperties"/></bean><!--数据库的相关配置--><beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><propertyname="driverClassName"value="${jdbc.driverClassName}"/><propertyname="url"value="${jdbc.url}"/><propertyname="username"value="${jdbc.username}"/><propertyname="password"value="${jdbc.password}"/><propertyname="maxActive"value="80"/><propertyname="maxIdle"value="20"/><propertyname="maxWait"value="3000"/></bean><!--配置事务管理器--><beanid="transactionManager"class="org.springframework.orm.hibernate4.HibernateTransactionManager"><propertyname="dataSource"ref="dataSource"/><propertyname="sessionFactory"ref="sessionFactory"/></bean><tx:annotation-driventransaction-manager="transactionManager"/><!--为JdbcTemplate装配本地JDBC对象抽取器--><beanid="nativeJdbcExtractor"class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"lazy-init="true"/><!--设置本地Jdbc对象抽取器--><beanid="oracleLobHandler"class="org.springframework.jdbc.support.lob.OracleLobHandler"lazy-init="true"><propertyname="nativeJdbcExtractor"ref="nativeJdbcExtractor"/></bean><!--设置LOB处理器--><beanid="lobHelper"class="cn.jacore.db.LobHelper"><constructor-argindex="0"ref="oracleLobHandler"></constructor-arg></bean><!--公用数据库操作类--><beanid="rowMappingTool"class="cn.jacore.tools.RowMappingTool"scope="prototype"><propertyname="lobHandler"ref="oracleLobHandler"/></bean><beanid="entityMappingTool"class="cn.jacore.tools.EntityMappingTool"scope="prototype"><propertyname="lobHandler"ref="oracleLobHandler"/></bean><!--hibernate--><beanid="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"><propertyname="dataSource"><refbean="dataSource"></ref></property><propertyname="hibernateProperties"><props><propkey="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop><propkey="hibernate.show_sql">false</prop></props></property><propertyname="mappingDirectoryLocations"><list><value>classpath:com/emdms/hbm</value></list></property></bean></beans>
spring-mvc.xml<beansxmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:util="http://www.springframework.org/schema/util"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util-3.0.xsd"><!--导入其他配置文件--><importresource="classpath:spring-jdbc.xml"/><!--<importresource="classpath:spring-jpa.xml"/>--><!--拦截器拦截所有<mvc:interceptors><beanclass="com.oss.services.common.OSSInterceptors"/></mvc:interceptors>--><mvc:annotation-driven/><context:component-scanbase-package="com.emdms.base.sys.user"><!--com.oss.services--><context:include-filtertype="annotation"expression="org.springframework.stereotype.Controller"/></context:component-scan><beanid="messageAdapter"class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"><propertyname="messageConverters"><list><beanclass="org.springframework.http.converter.StringHttpMessageConverter"><propertyname="supportedMediaTypes"><list><value>text/html;charset=UTF-8</value></list></property></bean><beanclass="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/></list></property></bean><beanid="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver"p:defaultEncoding="utf-8"><propertyname="maxUploadSize"value="20000000"/><!--10M--></bean><beanid="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver"><propertyname="viewClass"value="org.springframework.web.servlet.view.JstlView"/><propertyname="prefix"value="/"/><propertyname="suffix"value=".jsp"></property></bean></beans>
解决方案三:
pom.xml<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>emdms</groupId><artifactId>web</artifactId><packaging>war</packaging><version>0.0.1-SNAPSHOT</version><name>webMavenWebapp</name><url>http://maven.apache.org</url><properties><org.springframework.version>3.2.8.RELEASE</org.springframework.version></properties><dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>${org.springframework.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>${org.springframework.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-oxm</artifactId><version>${org.springframework.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-orm</artifactId><version>${org.springframework.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>${org.springframework.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${org.springframework.version}</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-entitymanager</artifactId><version>4.1.6.Final</version><scope>runtime</scope></dependency><dependency><groupId>org.hibernate.javax.persistence</groupId><artifactId>hibernate-jpa-2.0-api</artifactId><version>1.0.1.Final</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>4.1.6.Final</version></dependency><!--apache-commons的引用--><dependency><groupId>commons-attributes</groupId><artifactId>commons-attributes-api</artifactId><version>2.2</version></dependency><dependency><groupId>commons-attributes</groupId><artifactId>commons-attributes-compiler</artifactId><version>2.2</version></dependency><dependency><groupId>commons-beanutils</groupId><artifactId>commons-beanutils-core</artifactId><version>1.8.3</version></dependency><dependency><groupId>commons-collections</groupId><artifactId>commons-collections</artifactId><version>3.1</version></dependency><dependency><groupId>commons-lang</groupId><artifactId>commons-lang</artifactId><version>2.4</version></dependency><dependency><groupId>commons-dbcp</groupId><artifactId>commons-dbcp</artifactId><version>1.4</version></dependency><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.3.1</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.0.1</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency><dependency><groupId>org.codehaus.jackson</groupId><artifactId>jackson-mapper-asl</artifactId><version>1.9.13</version></dependency><dependency><groupId>org.codehaus.jackson</groupId><artifactId>jackson-core-asl</artifactId><version>1.9.13</version></dependency><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.16</version></dependency><dependency><groupId>org.json</groupId><artifactId>json</artifactId><version>20090211</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency></dependencies><build><finalName>emdms</finalName><pluginManagement><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>tomcat-maven-plugin</artifactId><version>1.1</version><configuration><path>/emdms</path><warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory><port>8080</port><uriEncoding>utf-8</uriEncoding></configuration></plugin></plugins></pluginManagement></build></project>
在线等待