Error in Bean Configuration xml file header - - java

I am getting below error when running my application on apache tomcat.
HTTP Status 500 - Servlet.init() for servlet spring threw exception
root cause
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 11 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid;
nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
My spring-context.xml is this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cotext="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:beans="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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc">
<mvc:annotation-driven/>
<cotext:component-scan base-package="springmvc"/>
I've tried https://jira.springsource.org/browse/SPR-3372 with no luck.
please help.

Few things looks off to me:
1) You have to remove " http://java.sun.com/xml/ns/javaee" in xmlns attribute. I think this is the main problem here. "xmlns" attribute can't take multiple URIs according to spec:
http://www.w3schools.com/xml/xml_namespaces.asp
2) Some XML libraries don't like the spaces in the beginning of XML file in front of (in particular Eclipse will complain)
3) xsi:schemaLocation value is missing location URI for mvc. It should probably look like this:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/context/spring-mvc-3.0.xsd">
You can as well remove extra "beans" declaration as previous answer suggests, unless you really want to use "beans" namespace prefix for some reason.

You have repeating entry of xmlns:beans="http://www.springframework.org/schema/beans" in your XML header. Remove one instance of it and try as below:
<beans xmlns="http://www.springframework.org/schema/beans http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cotext="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc">
<mvc:annotation-driven/>
<cotext:component-scan base-package="springmvc"/>

Related

The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "beans" is not bound

Why am I having this error
[Fatal Error]: The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "beans" is not bound.
at the header of my XML file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
The error is at the last line of my XML declaration.
Please what can I do to remove this error?
Simply add
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
to your bean element to eliminate that error.

Getting an error in compiling simple spring core application [duplicate]

I have the spring jars of spring-3.2.0.RC1.jar and trying to implement Apache ActiveMQ helloWorld program from tutorial given here. The xml configuration file is:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:p="http://www.springframework.org/schema/p"
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.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd">
<bean class="org.apache.activemq.command.ActiveMQQueue" id="destination">
<constructor-arg value="TEST.Q1"></constructor-arg>
</bean>
<bean class="org.apache.activemq.ActiveMQConnectionFactory" id="connectionFactory"
p:brokerurl="tcp://localhost:8161"></bean>
<bean class="com.jms.helloworld.listner.MessageListenerImpl" id="simpleMessageListener">
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
id="jmsContainer">
<property name="connectionFactory" ref="connectionFactory"></property>
<property name="destination" ref="destination"></property>
<property name="messageListener" ref="simpleMessageListener"></property>
</bean>
</bean>
</beans>
main:
public static void main(String[] args) throws JMSException {
System.out.println("LISTNER STARTED");
ApplicationContext context = new FileSystemXmlApplicationContext("src/com/jms/helloworld/config/JMSConfig.xml");
}
**Exception on console**
LISTNER STARTED
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from file [/home/neal/workspace/ActiveMQListener/src/com/jms/helloworld/config/JMSConfig.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 61; cvc-elt.1: Cannot find the declaration of element 'beans'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
at com.jms.helloworld.test.TestJMSListner.main(TestJMSListner.java:15)
Caused by: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 61; cvc-elt.1: Cannot find the declaration of element 'beans'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:387)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:321)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1920)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:709)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3080)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:899)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:288)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 14 more
I don't know what is wrong with the beans.So far any suggestion in other question doesn't help. Any help?
Try this, assuming you're on Spring 3.1:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
Replace 3.1 on the last line with whatever major Spring version you use. Meaning: there is no 3.1.1 XSD even though there is a Spring version 3.1.1.
Found it on another thread that solved my problem... was using an internet connection less network.
In that case copy the xsd files from the url and place it next to the beans.xml file and change the xsi:schemaLocation as under:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
spring-beans-3.1.xsd">
Add this code ..It helped me
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
classpath:/org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
classpath:/org/springframework/context/config/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
classpath:/org/springframework/aop/config/spring-aop-3.0.xsd
">
</beans>
This error of Cannot find the declaration of element 'beans' but for a whole different reason
It turs out my internet connection was not very reliable, so i decided to check first for this url
http://www.springframework.org/schema/context/spring-context-4.0.xsd
Once I saw that the xsd was open succesfully I clean the Eclipse(IDE) project and the error was gone
If you try this steps and still get the error then
check the Spring version so that it matches as mentioned by another answer
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-**[MAYOR.MINOR]**.xsd">
Replace [MAYOR.MINOR] on the last line with whatever major.minor Spring version that you are using
For Spring 4.0
http://www.springframework.org/schema/context/spring-context-4.0.xsd
For Sprint 3.1
http://www.springframework.org/schema/beans
spring-beans-3.1.xsd
All the contexts are available here
http://www.springframework.org/schema/context/
I had this issue and the root cause turned out to be white-space (shown as dots below) after the www.springframework.org/schema/beans reference in xsi:schemaLocation, i.e.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans....
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
I have encountered this same as you.
With my solution as follows:
Reconfig file: Spring Configuration File (no use XSD namespace declaration).
-> with the main purpose of not having tag name( bean, ...)
Create tag with class you want to use.
---HappyCoding---
I resolved this using the following 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:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
</Beans>
Try Using this- Spring 4.0. Working
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
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">
Make sure if all the spring jar file's version in your build path and the version mentioned in the xml file are same.
For me the problem was my file encoding...I used powershell to write the xml file and this was not UTF-8 ...
It seems that spring requires UTF8 because as soon as I changed the encoding (using notepad++) it works again without any errors
Now i Use in my powershellscript the following line to output the xml file in UTF-8:
[IO.File]::WriteAllLines($fname_dataloader_xml_config_file, $dataloader_configfile)
instead of using the redirection operator > to create my file
Note: I didn't put any xml parameters in my beans tag and it works
For me the problem was that spring was not able to download http://www.springframework.org/schema/beans/spring-beans.xsd or http://www.springframework.org/schema/context/spring-context.xsd
However I was able to access those from my browser as it was using my machines proxy. So I just copied the content of the two xsds to files named spring-beans.xsd and spring-context.xsd and replaced the http url with the file names and it worked for me.
Try using this:
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">
For Spring 5.1.0.RELEASE, the configuration file format specified in an answer for another question works for me.
This is the copy:
<?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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Bean declaration and other configurations -->
</beans>
Use this to solve your problem:
<context:annotation-config/>

Spring frame work config issue "prefix context for for element context:annotation-config is not bound"

I am having a weird issue that I can't seem to track down. I have this working with other servers without a problem, but I can't seem to get this one to work. The closest post that I see to my problem was this post The prefix "context" for element "context:component-scan" is not bound
All others really were just because the prefix was not in the xml file. I am hoping someone might be able to point me in the right direction here.
Spring XML file:
<?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"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">
<context:annotation-config/>
So I have that, but getting this error:
org.xml.sax.SAXParseException: The prefix "context" for element "context:annotation-config" is not bound.
Appreciate any help. Let me know what else I can provide.
Thanks
I was experiencing the same problem until I realized beans tag attribute xmlns:context was missing. Just added the below lines
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
...."
Then rebuilt the project.
It worked well then on.
The following works for me:
test.xml
<?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"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">
<context:annotation-config/>
</beans>
When I use the following class to run it:
Test.java
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) throws Exception {
new ClassPathXmlApplicationContext("test.xml");
System.out.println("Finished!");
}
}
Can you please see if this runs for you? You will need the following libraries in the classpath: commons-logging, spring-asm, spring-beans, spring-context, spring-core, and spring-expression.
Please let me know if it worked. If it didn't, please post the full stack-trace. Finally, I used Spring 3.1.1 for the above.
This error comes when you have xmlns:context missing from your spring xml file. So add it. Your beans header should look something like the following -
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd" >
<context:annotation-config />
<context:component-scan base-package="controller" />
</beans>
I encountered the same problem but i was able to solve it by moving
from applicationContext.xml to spring-servlet.xml and adding xmlns:context in the spring-servlet.xml

JAX-WS Schema http://jax-ws.dev.java.net/spring/servlet.xsd not able to be found

I am implementing JAX-WS with Spring framework.
The following is my Spring applicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://jax-ws.dev.java.net/spring/core
http://jax-ws.dev.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet
http://jax-ws.dev.java.net/spring/servlet.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
However, Eclipse is complaining:
Referenced file contains errors (http://jax-ws.dev.java.net/spring/servlet.xsd).
After investigation, I find the URL:
http://jax-ws.dev.java.net/spring/servlet.xsd
Does not exist.
Instead, it seems be move to:
http://jax-ws.java.net/spring/servlet.xsd
(You can open this link in the brower)
Therefore, I updated XSD schema URL from
http://jax-ws.dev.java.net/spring/servlet.xsd
to
http://jax-ws.java.net/spring/servlet.xsd
Now my applicationContext.xml looks like this:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://jax-ws.dev.java.net/spring/core
http://jax-ws.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet
http://jax-ws.java.net/spring/servlet.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
Actually with this change the Eclipse error goes away.
The problem is after launching the web service in Tomcat 7, I get the following runtime error instead:
org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 29; schema_reference.4: Failed to read schema document 'http://jax-ws.java.net/spring/servlet.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:99)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:433)
Please advise.
Thank you very much.
Regards,
Your problem is that you change the location from http://jax-ws.dev.java.net/spring/servlet.xsd to http://jax-ws.java.net/spring/servlet.xsd. Even though the latter one is the right url, it does not match what is defined in your jaxws-spring.jar META-INF/spring.schema file. That file should have the following content
http\://jax-ws.dev.java.net/spring/core.xsd=spring-jax-ws-core.xsd
http\://jax-ws.dev.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd
http\://jax-ws.dev.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd
Spring uses this mapping to search the schema in the classpath rather than to internet. Those schema files are located at the root of the jaxws-spring.jar file.
Please take a look Registering the handler and the schema
are you using spring in your project?, I had the same problem, but when I included spring-jaxws in my maven dependencies the problem solved, in fact, yo can see in that jar that the META-INF/spring.schemas file is redefining the XSDs locations
Resources have moved, final config should be:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://jax-ws.dev.java.net/spring/core
http://jax-ws.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet
http://jax-ws.java.net/spring/servlet.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
default-lazy-init="true">
Probably not a case with yours. But in such a scenario, do clean and make a fresh build. Reason being the older spring jar and xsd from there would be taken if the two jars exits. Hope that helps for other guys .... generically this exception will be thrown for many reasons.

Spring metro integration cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'

I try to integrate metro web-service with spring. But I get errors in my applicationContext.xml
<?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:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://jax-ws.dev.java.net/spring/core
http://jax-ws.dev.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet
https://jax-ws.dev.java.net/spring/servlet.xsd">
//Some beans
//!!!!!!!!ERROR
<wss:binding url="/ws">
<wss:service>
<ws:service bean="#newsWebService" />
</wss:service>
</wss:binding>
<bean id="newsWebService" class="com.news.webservice.NewsWebService">
<property name="newsBo" ref="newsBo"/>
</bean>
</beans>
Error message:
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 'wss:binding'.
- schema_reference.4: Failed to read schema document 'https://jax-ws.dev.java.net/spring/servlet.xsd', because 1) could
not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
I add lib x-bean-spring-3.7.jar and jaxws-spring-1.8.jar
Also I check spring.schemas in jaxws-spring-1.8.jar and get
# See XBEAN-60. To work around the overwriting issue, this file is maintained manually.
# this file is used by Spring to resolve resources locally.
# the key is the system ID and the value is the actual file location in this jar.
http\://jax-ws.dev.java.net/spring/core.xsd=spring-jax-ws-core.xsd
http\://jax-ws.dev.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd
http\://jax-ws.dev.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd
I included shemas according with this.
#UPDATED
I found something strange. I open in spring-beans-3.2.0.M1.jar spring.shemas
http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.2.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd
http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd
I get applicationContext.xml without error just with http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd next pair
Please, help me find reason.
EDIT: The previous answer was accepted by eclipse, but triggered an exception at runtime. Here is my final working config
Use this, the xsd schemas have been moved :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://jax-ws.dev.java.net/spring/core http://jax-ws.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet http://jax-ws.java.net/spring/servlet.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
default-lazy-init="true">
The java.net hosting web master administrator has caused problems by changing hosting paths.
Change all jax-ws.dev.java.net to jax-ws.java.net and the error disappears as on 28-Aug-2014.
It appears, thousands of developers time got wasted due to this.
Try replacing the line: http://www.springframework.org/schema/beans/spring-beans.xsd as it conflicts. Had same issue with similar configuration borrowed off an example on the Internet and this resolved it.
The head of the content of your applicationContext.xml should be:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://jax-ws.dev.java.net/spring/core
http://jax-ws.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet
http://jax-ws.java.net/spring/servlet.xsd">
The problem is because there isn't exist the URL http://jax-ws.dev.java.net/.
The project has been relocated and probably discontinued. Then, I suggest an alternative solution.
Download to local the files (spring-jax-ws-core.xsd,spring-jax-ws-servlet.xsd) from the source jar in this URL https://repo1.maven.org/maven2/org/jvnet/jax-ws-commons/spring/jaxws-spring/1.9/jaxws-spring-1.9-sources.jar
I have placed in the path "W:/dev/Spring4WebApp/", you can choose another one. I recommend you to upload and publish them in any own server in your company.
Modify the appContext with the following lines:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://jax-ws.dev.java.net/spring/core
file:///W:/dev/Spring4WebApp/spring-jax-ws-core.xsd
http://jax-ws.dev.java.net/spring/servlet
file:///W:/dev/Spring4WebApp/spring-jax-ws-servlet.xsd">
Note the lines starting with "file:///". These lines reference to your local files.
And voilĂ !! It runs!

Categories

Resources