facebook

MVC Showcase example from springsource does not build in 8.6

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #313584 Reply

    mitab
    Member

    Hi,
    I have MyEclipse for Spring 8.6. I download the MVC showcase example from the springsource samples repository. This does not build – In the servlet context.xml there is a line
    <!– Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory –>
    <resources mapping=”/resources/**” location=”/resources/” />which is giving the error

    cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘resources’. servlet-context.xml /mvc-showcase/src/main/webapp/WEB-INF/spring/appServlet line 16 XML Problem

    On googling this I found that it is suggested that we should use mvc:resources and include the corresponding declarations which I did

    <beans:beans xmlns=”http://www.springframework.org/schema/mvc&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xmlns:beans=”http://www.springframework.org/schema/beans&#8221;
    xmlns:mvc=”http://www.springframework.org/schema/mvc&#8221;
    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”&gt;

    and changed the line concerned to
    <mvc:resources mapping=”/resources/**” location=”/resources/” />

    but I still get the error

    Description Resource Path Location Type
    cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘mvc:resources’. servlet-context.xml /mvc-showcase/src/main/webapp/WEB-INF/spring/appServlet line 16 XML Problem

    How do I get rid of this error.
    If it needs a spring update how do I do that ?, From the workscenter I see that there are no updates available.

    Thanks

    #313622 Reply

    mitab
    Member

    Hi,
    Related to my previous post I found this at the springsource blog – http://blog.springsource.com/2009/12/21/mvc-simplifications-in-spring-3-0/ namely –

    “the next line hightlights a new feature added in version 3.0.4:

    view sourceprint?
    1 <!– Handles GET requests for /resources/** by efficiently serving static content in the ${webappRoot}/resources dir –>

    2 <mvc:resources mapping=”/resources/**” location=”/resources/” />
    The mvc:resources tag lets you configure a handler for static resources, such as css and javascript files. In this case, requests for /resources/** are mapped to files inside the /resources directory.

    So it looks like this needs Spring webmvc 3.0.4. How do I update MyEclipse with this version – nothing comes up in the Software Configuration Center

    #313667 Reply

    I just grabbed this project from the spring samples repo. It compiles and runs just fine for me. I wonder if they updated the project recently?

    If you are still having problems with the project, you can easily update the spring version that is used. Since this project is a maven project, it uses whatever version of the spring framework you tell it to use. Simply open the /mvc-showcase/pom.xml. you will see a bunch of entries in the pom that determine the spring libraries to be used. for example:

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${org.springframework-version}</version>
    </dependency>

    This is actually a handy maven feature, it enables you to set a single property that sets the Spring version and that is then used by all of hte spring component. At the top of the file look for this:

    <properties>
    <java-version>1.6</java-version>
    <org.springframework-version>3.0.5.RELEASE</org.springframework-version>
    <org.springframework.roo-version>1.1.0.RELEASE</org.springframework.roo-version>
    <org.aspectj-version>1.6.9</org.aspectj-version>
    <org.slf4j-version>1.6.1</org.slf4j-version>
    </properties>

    In the version I just pulled from the repo, you can see that this one is setting the “org.springframework-version” property to “3.0.5.RELEASE” If you want to change it, for instance to an older version that is 3.0.4, simply change the property. It will now look like:

    <org.springframework-version>3.0.4.RELEASE</org.springframework-version>

    And that is all you have to do in Maven projects to change the version of Spring in use. The projects created by ME4S are quite similar. Here is the same snippet created as part of an ME4S project.

    <properties>
    <org.springframework.webflow.version>2.0.7.RELEASE</org.springframework.webflow.version>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    <org.springframework.security.version>3.0.0.RELEASE</org.springframework.security.version>
    </properties>

    Maven makes this all really easy to do. Let me know if you have any other questions.

    #313669 Reply

    neyde
    Member

    The mvc-showcase project is a Maven project, and dependencies should be resolved using Maven. According to the springsource blog you reference, the validation error shouldn’t cause any problems running the project. Can you confirm?

    #313676 Reply

    mitab
    Member

    Hi,

    Thanks for your replies.

    Firstly – I downloaded the mvc showcase sample again and this time the pom referred to 3.0.5 as mentioned but that did not remove the validation error.
    Secondly – I checked that at least the JUnit test for the SimpleController runs even with validation error.
    But I was finally able to get rid of the validation errors as follows

    Found that the problem was because the spring mvc 3.0 xsd which came wth the my eclipse installation is old and does not have the resources element. So downloaded the xsd from the location at springsource http://www.springframework.org/schema/mvc.
    Then manually replaced my local xsds with the downloaded copies which had the resources element – this finally resolved the error.

    What I am wondering now is there any way to get these xsds updated other than manually replacing them.

    The local xsds can be found at MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles\91\1\.cp\catalog-xsd and MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles\1153\1\.cp\org\springframework\web\servlet\config

    #313677 Reply

    @mitab wrote:

    Hi,

    Thanks for your replies.

    Firstly – I downloaded the mvc showcase sample again and this time the pom referred to 3.0.5 as mentioned but that did not remove the validation error.
    Secondly – I checked that at least the JUnit test for the SimpleController runs even with validation error.
    But I was finally able to get rid of the validation errors as follows

    Found that the problem was because the spring mvc 3.0 xsd which came wth the my eclipse installation is old and does not have the resources element. So downloaded the xsd from the location at springsource http://www.springframework.org/schema/mvc.
    Then manually replaced my local xsds with the downloaded copies which had the resources element – this finally resolved the error.

    What I am wondering now is there any way to get these xsds updated other than manually replacing them.

    The local xsds can be found at MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles<!– [\.cp\catalog-xsd and MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles53<!– [\.cp\org\springframework\web\servlet\config

    Unfortunately, this is a manual process for now. We are updated the schemas in 9.0, so the error will go away when you upgrade. It is strange though, I did not manually upgrade my schema and I did not see the validation error. I will see if I can figure out why that is the case.

    #313805 Reply

    onenpro
    Member

    I have followed the stpes to try to remove the error around <mvc:resources …>. Replaced the file spring-mvc-3.0.xsd by the new one including the new annotations but something strange is happening:

    Only found one instance of the file under

    MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles\ 1176\ 1\ .cp\ org\springframework\web\servlet\config

    (Sorry for the spaces)

    As soon as I start MyEclipse 8.6.1 I open de file and inmediatly add the tag <mvc:resources (Ctrl+Tab detects it). Less than a minute later the error appears again, and even if I check again (Ctrl+Tab) looking for the <mvc: resources…> the tag does not appear any more.

    I’m sure I’m missing something, the key detail… any idea?

    Thanks in advance

    PD: The project compiles and works fine anyway, just want to fix the xsd point.

    @mitab wrote:

    Found that the problem was because the spring mvc 3.0 xsd which came wth the my eclipse installation is old and does not have the resources element. So downloaded the xsd from the location at springsource http://www.springframework.org/schema/mvc.
    Then manually replaced my local xsds with the downloaded copies which had the resources element – this finally resolved the error.

    The local xsds can be found at MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles<!– [\.cp\catalog-xsd and MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles53<!– [\.cp\org\springframework\web\servlet\config

    #313877 Reply

    frensley
    Member

    @onenpro wrote:

    I have followed the stpes to try to remove the error around <mvc:resources …>. Replaced the file spring-mvc-3.0.xsd by the new one including the new annotations but something strange is happening:

    Only found one instance of the file under

    MyEclipse for Spring 8.6\configuration\org.eclipse.osgi\bundles\ 1176\ 1\ .cp\ org\springframework\web\servlet\config

    (Sorry for the spaces)

    I thought I would document my success.

    I was able to make this work using a similar method described in this thread. You can locate the xsd that is in use by looking in MyEclipse->Files and Editors->XML Catalog

    In the XML catalogs entry click on “http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd&#8221;

    In the details window at the bottom, the Location field will tell you where the xsd is being loaded from. Replace that xsd with the 3.0.5 xsd and restart Eclipse. I cleared MyEclipse->Internet Tools->Cache before restarting.

    Good luck.

    #313892 Reply

    onenpro
    Member

    @frensley wrote:

    @onenpro wrote:

    I cleared MyEclipse->Internet Tools->Cache before restarting.

    Restarting only MyEclipse the error continued there but it worked after restarting computer. I don’t understand but it’s working now, thanks!

    #314266 Reply

    b.benitez
    Member

    Hello everyone,

    I’m currently using 9.0 M2 and I noticed the included Spring libraries are still outdated (3.0.1) vs current release 3.0.5.

    Are you going to update them before GA?
    I assume this would solve the issue regarding the new mvc:resources tag.

    Also: please update Hibernate from 3.3 to 3.6.1 while you are at it. 😉

    Thank you very much.

    #314297 Reply

    neyde
    Member

    @b.benitez wrote:

    Hello everyone,

    I’m currently using 9.0 M2 and I noticed the included Spring libraries are still outdated (3.0.1) vs current release 3.0.5.

    Are you going to update them before GA?

    They will be updated for GA.

Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: MVC Showcase example from springsource does not build in 8.6

You must be logged in to post in the forum log in