0

Update :Now Working properly. Kindly follow the comments.
This is my Spring configuration file:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
    ">
    <context:component-scan  base-package="report.frontcontroller"/>
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <mvc:annotation-driven />
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix"> <value>/WEB-INF/</value></property>
        <property name="suffix"> <value>.jsp</value></property>
    </bean>
</beans>

All jars are included in this project, and the configuration file is shown above. I get errors for this part:

<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />

Errors: * Matching wildcard is strict but no declaration is found for mvc:resource and mvc:annotation * Multiple annotations found at this line: - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:resources'. - schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/mvc/spring- mvc-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . Multiple annotations found at this line:* - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:resources'. - schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/mvc/spring- mvc.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .

user2677600
  • 153
  • 1
  • 2
  • 11
  • The configuration file itself is correct. What is your Spring (MVC) version? – meskobalazs Feb 04 '15 at 10:51
  • Which spring jars do you have in your application? – Ralph Feb 04 '15 at 10:56
  • its spring-webmvc-4.1.1.RELEASE-sources and all others jars are of same version too. – user2677600 Feb 04 '15 at 10:59
  • Now Running The problem was with the ips ie blocking the request for http://www.springframework.org/schema/mvc/spring-mvc.xsd file. There are two solutions for it either download it on local and include it on classpath or ask network engineer for not blocking the request. – user2677600 Feb 04 '15 at 13:43
  • This file is included in spring jars already. You most likely have a dependency issue in your project. – Brian Clozel Feb 05 '15 at 08:49

2 Answers2

0

can you try below configuration that is copied from GIT - spring-mvc-showcase

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <resources mapping="/resources/**" location="/resources/" />

    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <task:annotation-driven />

</beans:beans>
Braj
  • 46,415
  • 5
  • 60
  • 76
  • Still same issue.. Multiple annotations found at this line: - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:resources'. - schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/mvc/spring- mvc-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . – user2677600 Feb 04 '15 at 11:41
  • Now Running The problem was with the ips ie blocking the request for http://www.springframework.org/schema/mvc/spring-mvc.xsd file. There are two solutions for it either download it on local and include it on classpath or ask network engineer for not blocking the request. – user2677600 Feb 04 '15 at 13:44
  • This file is included in spring jars. You probably have a classpath or version conflict issue. – Brian Clozel Feb 08 '15 at 10:35
-1

change to spring-mvc.xsd to spring-mvc-3.0.xsd .Similarly change at all the remaining places too.

Refer here

Edit

   <?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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="report.frontcontroller" />
    <mvc:annotation-driven/>
    <mvc:resources mapping="/resources/**" location="/resources/" /> 
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/views/" />
      <property name="suffix" value=".jsp" />
   </bean>
</beans> 
Community
  • 1
  • 1
Sumeet Sharma
  • 2,573
  • 1
  • 12
  • 24
  • I am using spring-mvc-4.1.1. According the documents we have to use same version of jars. – user2677600 Feb 04 '15 at 11:09
  • Yeah.. that's not the point I wanted to highlight giving you the link. Its the bugs in spring that were reported in that thread. Anyway changing the xsd to as suggested above will resolve your issue. – Sumeet Sharma Feb 04 '15 at 11:11
  • So do i need to downgrade all the jars or will it work only by changing in configuration file. Because its not working as you suggested above. – user2677600 Feb 04 '15 at 11:20
  • https://www.dropbox.com/s/b568mxps1e93pww/Screenshot%20from%202015-02-04%2017%3A03%3A43.png?dl=0 Kindly refer the above link. It still having the same issue. – user2677600 Feb 04 '15 at 11:36
  • just try the web.xml config i updated in the edit section , I am using spring 4.1 and that is my spring-context.xml ... i have changed the base package.. so you can copy paste and try... – Sumeet Sharma Feb 04 '15 at 12:50
  • Now Running The problem was with the ips ie blocking the request for http://www.springframework.org/schema/mvc/spring-mvc.xsd file. There are two solutions for it either download it on local and include it on classpath or ask network engineer for not blocking the request. – user2677600 Feb 04 '15 at 13:44
  • you should always use versionless schemas! http://stackoverflow.com/questions/20894695/spring-configuration-xml-schema-with-or-without-version/20900801#20900801 – Brian Clozel Feb 05 '15 at 08:50
  • @BrianClozel hey.. I just posted a solution that solved my problem .. I had the same problem.. Now to use it or not or the best practice is a different scenario .. There are solutions posted here and the user has to compare and choose the best one.. downvoting on that context is just plainly wrong. – Sumeet Sharma Feb 05 '15 at 08:57