Decription:
1. Spring+log4j
Description:
ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
or
Error configuring application listener of classorg.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener
Solution:
Include the follow jars
Log4j-1.2.14.jar
Spring-web-3.2.0.RELEASE.jar
Spring-orm-3.2.0.RELEASE.jar
Clean the project and redeploy
Ref maven pom.xml
Refweb.xml
2. BasicDataSource
Description:
java.lang.ClassNotFoundException:org.apache.commons.dbcp.BasicDataSource
or
Exception sending context initialized event to listenerinstance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException:Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name'dataSource' defined in ServletContext resource[/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException:org.apache.commons.dbcp.BasicDataSource
atorg.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1263)
Solution:
Include the follow jar files
commons-pool.jar
commons-dbcp-1.4.jar
commons-collections-3.2.jar
Clean the project and reploy
Refpom.xml
3. SpringObjectFactory
Description:
At starting tomcat we got the error:
Class: com.opensymphony.xwork2.spring.SpringObjectFactory
File: SpringObjectFactory.java
Method: getClassInstance
Line: 209 -com/opensymphony/xwork2/spring/SpringObjectFactory.java:209:-1
Caused by: java.lang.NullPointerException
atcom.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:209)
Solution:
There2 reason:
1. Includedstruts2-spring-plugin-2.1.8, but we didn’t use spring (and any spring profiles),delete this jar.
2. Projectusing spring, but we didn’t add thespirngContext listener int web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
Clean the project and reploy
4. ConfigurableEnvironment
Description:
Exception sending context initialized event to listenerinstance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError:org/springframework/core/env/ConfigurableEnvironment
atjava.lang.Class.getDeclaredConstructors0(Native Method)
Caused by: java.lang.ClassNotFoundException:org.springframework.core.env.ConfigurableEnvironment
Solution:
A: spring to maintain a consistent version of the jar
B: exclusion
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
Clean the project and reploy
5. Hibernate3 CacheProvider
Description:
Exception sending context initialized event to listenerinstance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'sessionFactory' defined in ServletContextresource [/WEB-INF/applicationContext.xml]: Initialization of bean failed;nested exception is java.lang.NoClassDefFoundError:org/hibernate/cache/CacheProvider
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532)
Caused by: java.lang.NoClassDefFoundError:org/hibernate/cache/CacheProvider
Caused by: java.lang.ClassNotFoundException:org.hibernate.cache.CacheProvider
Solution:
Because there is no longer cacheprovider class in hibernate4, cacheprovideronly int hibernate3. Change hibernate3 to hibernate4.
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
Clean the project and reploy
6. 34
Description:
Java:
Solution:
Include the follow jar files
*.jar
Clean the project and reploy