maven整合ssh3启动出现错误java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
上网搜了一下,都说没加入log4j的包,但我明明加入进去了啊
slf4j-api, slf4j-log4j12, commons-logging, log4j 都加了,还是报错
下面是我的错误信息和pom.xml
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:209)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:221)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newConfiguration(LocalSessionFactoryBean.java:813)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:549)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 52 more
<project xmlns="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.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cms</groupId>
<artifactId>cms</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>gdcms Maven Webapp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.0.2.RELEASE</spring.version>
<slf4j.version>1.5.6</slf4j.version>
<aspectj.version>1.6.12</aspectj.version>
<struts2.version>2.3.15.1</struts2.version>
<hibernate.version>3.3.2.GA</hibernate.version>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency>
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
</dependency>
<!-- struts2的核心包,其依赖包会自动下载 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<!-- struts2与spring的整合插件 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<!-- spring的核心包,其他依赖包会自动下载 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 使用spring的aop,aop要依赖aspectjweaver -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
</dependency>
<!-- 使用这里的工具类对字符串进行MD5加密 -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<!-- j2ee web spec -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- hibernate的核心包,使用hibernate4时报错就改用了hibernate3 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jmx</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- spring整合hibernate需要添加上spring的orm的jar包, 由于spring-orm是
依赖于spring-jdbc的, 所以这里即使不配spring-jdbc,maven也会帮我们
下载下来这些依赖
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<!-- hibernate-core依赖于slf4j-api,而slf4j-api需要一个实现类,这个
实现类jar可以是slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar,
slf4j-jdk14.jar ,logback-classic.jar其中之一 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<!-- log4j日志记录 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>compile</scope>
</dependency>
<!-- json -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<!-- junit4用来进行单元测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>gdcms</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.1.2.v20100523</version>
<configuration>
<webAppConfig>
<contextPath>/cms</contextPath>
</webAppConfig>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8088</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<!--scanIntervalSeconds>1</scanIntervalSeconds -->
</configuration>
</plugin>
<plugin>
<!-- Must use java 1.5 or higher for annotations -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
问题补充:以下是Caused by前面的详细的错误信息
严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/home/allen/workspace/cms/target/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:636)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:188)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:995)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:579)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:381)
at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:114)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:162)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
at org.eclipse.jetty.server.Server.doStart(Server.java:226)
at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:433)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:377)
at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:577)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
相关推荐
Maven整合SSH案例 ************************************************************************************* 注意:运行前请配置Maven环境,和修改config.properties中数据库名称用户和密码,并且修改Tuser中的...
【标题】"Maven 整合SSH之一" 涉及到的是在Java开发中如何使用Maven构建工具来整合Spring、Struts2和Hibernate这三个流行框架,这通常被称为SSH集成。SSH是一套强大的Java Web应用程序开发解决方案,可以帮助开发者...
整合SSH框架意味着在Maven项目中配置Struts2、Spring和Hibernate的依赖,以及相应的插件和配置文件。Struts2提供MVC模式的前端控制,Spring负责依赖注入和事务管理,Hibernate则处理对象关系映射,实现数据库操作。 ...
** Maven 整合 SSH2 知识点详解 ** Maven 是一个强大的项目管理和构建工具,在Java开发领域广泛应用。SSH2 则是 Spring、Struts 和 Hibernate 三个开源框架的组合,它们分别负责控制层、视图层和持久层的处理。将 ...
利用Maven整合SSH,包括整合说明以及实例代码,导入Eclipse可直接运行,适合初学SSH开发框架的同学
本篇将详细介绍如何在Eclipse环境下,利用Maven整合SSH项目,并包含数据库连接的配置与测试。 首先,我们需要了解SSH框架的基本概念: 1. Struts2:这是一个基于MVC设计模式的Web应用框架,负责处理用户请求并返回...
利用maven技术整合ssh框架的pom.xml! 利用maven技术整合ssh框架的pom.xml 利用maven技术整合ssh框架的pom.xml
现在,我们将深入探讨如何在Maven环境中整合SSH框架。 首先,让我们从Maven的配置开始。在你的`pom.xml`文件中,你需要添加SSH相关框架的依赖。Spring、Struts2和Hibernate的最新稳定版本可以在Maven中央仓库中找到...
现在让我们深入探讨如何使用Maven整合SSH框架。 首先,**Struts** 是一个基于MVC(Model-View-Controller)设计模式的Java Web应用框架,它主要负责处理HTTP请求,提供视图和控制器的分离,使得业务逻辑与展示层...
这个压缩包文件提供的内容应该是已经完成了上述整合和配置的项目,可以直接导入到IDE中运行,对于初学者来说,这是一个很好的学习和实践SSH框架与Maven整合的实例。通过查看和分析代码,可以深入理解各个组件如何...
这个框架是不通过maven将spring strus2 hibernate整合到一起的 包括两个方法 显示 (product_show)和 新增(addProduct.jsp) 数据库名称mavenssh 数据库表名称 product
这是自己根据别人写的资料,自己搭载的框架,运行没有问题,用的是eclipse_luna(mars与最新的maven我没有弄好,报错),jak1.7,tomcat7.数据库用的是mysql,希望对初学者有用!
在IT行业中,SSH(Struts2、Spring、Hibernate)是一个常见的Java Web开发框架组合,而Maven则是一个项目管理和综合工具。"构建基于Maven的SSH原型项目"这个主题,旨在帮助初学者理解和掌握如何使用这些技术搭建一个...
现在,让我们详细探讨"Maven ssh整合框架"的相关知识点。 1. Maven: Maven是Apache软件基金会开发的一款项目管理工具,它通过POM(Project Object Model)文件来管理项目的依赖、构建过程和配置。Maven提供了标准...
3. **SSH整合**:SSH通常指的是Spring、Hibernate和Struts,但在Maven SSH中,SSH更多地指代Spring Security与Maven的结合。这使得开发者能够利用Maven的自动化特性,同时享受Spring Security提供的高级安全特性。 ...
<listener-class>org.springframework.web.context.ContextLoaderListener </listener> <param-name>contextConfigLocation <param-value>classpath:applicationContext.xml </context-param>
"eclipse+maven+ssh"就是一个常见的组合,其中eclipse是Java开发的集成开发环境,maven是项目管理和构建工具,而ssh则是三个流行框架的简称,包括Spring、SpringMVC和Hibernate。下面我们将详细探讨这些知识点。 1....
【标题】"maven+ssh+Json整合"指的是在Java Web开发中,使用Maven作为构建工具,Spring、Struts2(SSH框架)作为后端技术,并结合Json进行数据交互的一种常见集成方案。这种整合方式在企业级应用开发中非常普遍,...
在本项目中,Maven被用来整合SSH框架,构建出一个完整的Java Web项目。 **Struts2框架** Struts2是基于Struts1发展起来的,提供了更强大的Action和拦截器机制。它支持多种结果类型,如JSP、FreeMarker、Velocity等...