Skip to main content

cvc-complex-type.2.4.c issues - a few things to check

I've battled with the Spring cvc-complex-type.2.4.c issue on a few occasions but with them far enough apart that I can't remember what the steps are to solve it. This time round I thought I would write it down...

You are writing a Spring-based app and you have some of your bean declarations in XML (I also use annotations but that's not important here). You wire your beans, you write your code and you build your application. Everything compiles and builds correctly, you run up your app in your container (in my case the dreaded Glassfish) and BOOM:
Caused by: org.xml.sax.SAXParseException;
    lineNumber: 30; columnNumber: 76;
    cvc-complex-type.2.4.c: The matching wildcard is strict,
    but no declaration can be found for element 'jms:listener-container'.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.
        createSAXParseException(ErrorHandlerWrapper.java:198)
Here are a few things to check:

Check that you have a element in your XML of the mentioned type, in my case it complained about 'jms:listener-container' and I correctly had this in the config:
<jms:listener-container
    acknowledge="transacted"
    concurrency="5"
    connection-factory="jmsAsyncMLQueueConnectionFactory"
    destination-resolver="jndiDestinationResolver"/>
Check that you have the mentioned namespace declared correctly, it complained about 'jms:listener-container' and I correctly had this in the beans header part of the XML:
<beans
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:jms="http://www.springframework.org/schema/jms"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemalocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/jms
        http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
        http://www.springframework.org/schema/jee
        http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
    ">
    ....
As you can see I've declared the xmlnss:jms and then put the correct schema location URL in as well.

None of this was the problem, in fact the problem wasn't to do with mistakes in the XML configuration, or incorrect namespace URLs or even whether the correct SAX parser was being used (look out for this one though).

The problem was that the spring jms schema file couldn't be found, the Spring XML parser doesn't go to the internet to get the schema files, it looks for them in the Spring jars. I'd completely forgotten to declare the use of sping-jms in my maven config and so it couldn't find the Spring JMS schema.

By adding the following to my Maven project sorted out the issue:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jms</artifactId>
</dependency>
Why couldn't the XML parser have told me that it couldn't find one of the schema files?!?! >:O

Comments

Mark said…
Thanks for this app once i deleted the conflicting file winmail.dat it worked.
Sony Kolli said…
It worked when i put the spring jms dependency in the pom.xml,I spent almost an hour to get this working. Thanks
Bill Comer said…
Yo Mr B.
Just came across your post, but it turns out I had a different cause. We were using or own namespace & the NamespaceHandlerSupport classes were defined in a child project. The problem was that my project was not including the handler files in the build path so they were not being included the child.jar - That took me a good while to track down. Trust all is good with you all on the beach ;-)