4

i'm starting with Spring 3 (3.1.2) and Google App Engine.

I've followed a tutoria online, now, i've my bean-realted xml which has a problem while starting.

this is the code

<?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:context="http://www.springframework.org/schema/context"
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">
<context:component-scan base-package="my.example">

where the root package of all the java file is "my.example". The subpackage are "model" and "controller" with subpackages as well. now.

when i start the app i receive back this error:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

with a lot of more stacktrace.

does anyone know how i can solve this? i checked the XSD and they seems to be correct.

EsseTi
  • 4,079
  • 5
  • 36
  • 63

3 Answers3

1

You are probably missing spring-context.jar, that is the one which contains the definition for context schema.

Biju Kunjummen
  • 49,138
  • 14
  • 112
  • 125
  • i actually add ALL the library just to be sure. but notihing changed. PS: there's no "spring-context" , there's "context", "context.support" – EsseTi Jul 12 '12 at 08:41
  • doesn't sound right @EsseTi, there should have been a spring-context-3.1.2.RELEASE.jar , unless you are using osgi jars distributed by Spring. – Biju Kunjummen Jul 12 '12 at 12:12
  • can you provide a link from where download the jars? anyway the problem was in the XML since i didn't close the `` right after but at the end of the file (i took this from an online example). – EsseTi Jul 12 '12 at 15:26
1

I don't know if this helps any, but I had an error very similar to yours while using the maven shade plugin to make a single .jar, and the shade plugin wiped out the spring.handlers and spring.schemas from META-INF/.

This SO answer pointed me in the right direction: https://stackoverflow.com/a/3650844/7008

And the document on using an AppendingTransformer to add those spring bits back in to your META-INF/ folder did the trick for me: http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer

Community
  • 1
  • 1
Nick Klauer
  • 5,893
  • 5
  • 42
  • 68
1

Problem is incompatible schema locations with your spring-context dependencies.

Replace

http://www.springframework.org/schema/context/spring-context.xsd

by

http://www.springframework.org/schema/context/spring-context-2.5.xsd

That should do the trick! I was using spring-context 3.1.1 and I was getting the same error referring to http://www.springframework.org/schema/context/spring-context-2.1.xsd

However, you should also do a maven tree dependendency and check if you've got different spring versions. This error could be due to this fact also...

dustEffect
  • 156
  • 1
  • 3