title: Exception starting Spring application from Java
body: <p>I am able to compile and start my Spring project using Maven:</p>
  
  <pre><code>mvn -e clean compile exec:java -Dexec.mainClass=de.fraunhofer.fkie.tet.vmware.manager.Test
  </code></pre>
  
  <p>However, when I assemble all jars in a single file using the <code>maven-assembly-plugin</code> (including <code>applicationContext.xml</code>), I always get an <code>Exception</code> during the <code>java</code> execution:</p>
  
  <pre><code>java -cp target/test-jar-with-dependencies.jar:. de.fraunhofer.fkie.tet.vmware.manager.Test
  
    INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
    Sep 6, 2010 10:37:21 AM org.springframework.util.xml.SimpleSaxErrorHandler warning
    WARNING: Ignored XML validation warning
    org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not &lt;xsd:schema&gt;.
    ...
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 
    Line 10 in XML document from class path resource [applicationContext.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:annotation-config'.
    ...
    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: 
    The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
  </code></pre>
  
  <p>I also tried to attach the schema definitions, i.e. <code>spring-context.xsd</code> etc., directly to the classpath, but without any success.</p>
  
  <pre><code>less src/main/resources/applicationContext.xml
  
    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;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"&gt;
  
        &lt;context:annotation-config /&gt;   &lt;!-- wegen '@PostConstruct' --&gt;
    &lt;!--&lt;context:component-scan base-package="de.fraunhofer" /&gt;     --&gt;
    ...
    &lt;/beans&gt;
  </code></pre>