0

I am trying to upgrade my spring 3.4 application to spring 4.0.2

I imported all the spring-4.0.2 jar files but am getting errors in the dispatcher-servlet.xml

if I use this code, I get Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd)

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">


        <!--  automatic scan base folder to detect controllers -->
    <context:component-scan base-package="com.shaw.csdss"/>
    <mvc:annotation-driven />

    <!--  This file will contain the view name mappings to the jsp -->
    <bean id = "jspViewResolver" 
          class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
         <property name="prefix"><value>/</value></property>
         <property name="suffix"><value>.jsp</value></property>
         <property name="order" value="1" />
    </bean>

</beans>

I tried to remove the -4.0 from the xsd references but I get same error on spring-mvc-xsd now.

I even tried to discard everything and just copy the xml from the spring reference documentation as follow

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<mvc:annotation-driven />

<bean id = "jspViewResolver" 
    class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
    <property name="prefix"><value>/</value></property>
    <property name="suffix"><value>.jsp</value></property>
    <property name="order" value="1" />
</bean>
</beans>

but with this simple file I get error on

cvc-complex-type.2.4.c: the matching wildcard is strict, but no declaration can be found of element 'mvcannotation-driven

Any example I take from spring4.0 reference document, gives me same error.

is this a problem with spring4.0.2 or am I missing something?

Thank you for your help

Ashot Karakhanyan
  • 2,804
  • 3
  • 23
  • 28
daoud175
  • 106
  • 1
  • 18
  • For starters it is recommended to use the version less schemas as this will always point to the most recent version of the xsd. If the xsd cannot be found the jars aren't on the classpath or there is some classpath error. I suggest using something like Gradle or Maven to manage your dependencies. – M. Deinum Mar 12 '14 at 18:58
  • That works for me. Try to copy paste this back to a new file, maybe there's a trailing character or something. – Stephane Nicoll Mar 13 '14 at 08:35
  • Thank you for the reply. I noticed in the logs now that there is an error. Maybe a missing Jar as you mentioned. ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 53) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is java.lang.VerifyError: Bad type on operand stack – daoud175 Mar 13 '14 at 13:56

0 Answers0