views:

356

answers:

1

I create a simple webapp using tomcat 6, spring 2.5.6 and maven.

The problem is when I boot up tomcat, I am getting the following errors:

SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/springframework/ui/ModelMap
...
Caused by: java.lang.ClassNotFoundException: org.springframework.ui.ModelMap

The ModelMap class does exist in spring-2.5.6.jar and spring-context-2.5.6.jar, I also have some other spring jars. All of them are being deployed to tomcat correctly, when I check the application WEB-INF (deployed to tomcat) I found all those jars there!

I have only one @Controller that has a @RequestMapping("/home.htm") showForm(ModelMap model) method. My applicationContext is quite simple:

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
              http://www.springframework.org/schema/aop 
              http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-2.5.xsd
              http://www.directwebremoting.org/schema/spring-dwr
              http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"
    default-autowire="byName">

<context:component-scan base-package="org.myapp"/>
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
        <property name="prefix" value="/WEB-INF/view/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
</beans>
+1  A: 

spring-2.5.6.jar is the JAR that contains all of the spring framework. If you use that JAR, you should not use any of the other JARs like spring-context-2.5.6.jar. These smaller JARs are there if you want to pick ands choose the bits of Spring that you need.

It's possible that the classloader is getting confused between the duplicate copies of the classes between the JARs. Take out all of the Spring JARs except for spring-2.5.6.jar, and see if that makes a difference.

skaffman