I am using Spring and in application-context.xml I have the following definitions:
<?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:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.xsd"
>
.....
When my internet connection is lost, I cannot run my application via tomcat or jetty.
It gives:
[main] WARN org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document '/spring-beans-2.0.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>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:2541)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:2532)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:1836)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:531)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2408)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1753)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:685)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3095)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:921)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
2009-11-13 15:31:25,675 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from class path resource [application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinit........
Any suggestions how to fix it?
There is no need to use the classpath: protocol in your schemaLocation URL if the namespace is configured correctly and the XSD file is on your classpath.
Spring doc "Registering the handler and the schema" shows how it should be done.
In your case, the problem was probably that the spring-context jar on your classpath was not 2.1. That was why changing the protocol to classpath: and putting the specific 2.1 XSD in your classpath fixed the problem.
From what I've seen, there are 2 schemas defined for the main XSD contained in a spring-* jar. Once to resolve the schema URL with the version and once without it.
As an example see this part of the spring.schemas contents in spring-context-3.0.5.RELEASE.jar:
http\://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd
http\://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd
http\://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.0.xsd
This means that (in xsi:schemaLocation)
http://www.springframework.org/schema/context/spring-context-2.5.xsd
will be validated against
org/springframework/context/config/spring-context-2.5.xsd
in the classpath.
http://www.springframework.org/schema/context/spring-context-3.0.xsd
or
http://www.springframework.org/schema/context/spring-context.xsd
will be validated against
org/springframework/context/config/spring-context-3.0.xsd
in the classpath.
http://www.springframework.org/schema/context/spring-context-2.1.xsd
is not defined so Spring will look for it using the literal URL defined in schemaLocation.
I solved it
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/context
classpath:spring-context-2.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.xsd"
>
classpath:spring-context-2.1.xsd is the key for working offline mode (no internet connection). Also i copied spring-context-2.1.xsd near (same directory) the application-context.xml file
Something like this worked for me.
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/beans/factory/xml/spring-context-3.0.xsd"
In case anyone arrives here via the same root I did - I hit this problem because I was building a single JAR with all dependencies, including Spring JARs. As a result the spring.schemas file in some of the META-INF directories of Spring JARs was overwritten.
I found suggested solutions here: How to create spring-based executable jar with maven?
Ran into a similar issue today. In my case, it was the shade plugin that was the culprit, in addition to springframework.org having an outage. The following snippet cleared things up:
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
HTH someone
You should check that the spring.handlers and spring.schemas files are on the classpath and have the right content.
This can be done with ClassLoader.getResource(..). You can run the method with a remote debugger in the runtime environment. The extensible XML authoring setup is described in the Spring Reference B.5. Registering the handler and the schema.
Normally, the files should be in the spring jar (springframework.jar/META-INF/) and on the classpath when Spring can be initiated.
Find class path
If you are using eclipse click on corresponding jar file. Goto ->META-INF-> open file spring.schemas
you will see the lines something like below.
http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.1.xsd
copy after = and configure beans something like below.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/rabbit classpath:org/springframework/amqp/rabbit/config/spring-rabbit-1.1.xsd
http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http://www.springframework.org/schema/context classpath:org/springframework/context/config/spring-context-3.1.xsd
http://www.springframework.org/schema/util classpath:org/springframework/beans/factory/xml/spring-util-3.1.xsd">
You need to add schema locations to your bean definition, and then they can be found in classpath instead of fetched over the net. Given your formatting problems, I'm not 100% sure that you aren't doing this already.
<?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-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!-- empty: the beans we use are in the base class's context. -->
</beans>
We solved the problem doing this:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false); // This avoid to search schema online
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "TransactionMessage_v1.0.xsd");
Please note that our application is a Java standalone offline app.
If you are using eclipse for your development , it helps if you install STS plugin for Eclipse [ from the marketPlace for the specific version of eclipse .
Now When you try to create a new configuration file in a folder(normally resources) inside the project , the options would have a "Spring Folder" and you can choose a "Spring Bean Definition File " option
Spring > Spring Bean Configuation File .
With this option selected , when you follow steps , it asks you to select for namespaces and the specific versions :
And so the possibility of having a non-existent jar Or old version can be eliminated .
Would have posted images as well , but my reputation is pretty low.. :(
I would like to add some additional aspect of this discussion. In windows OS I have observed that when a jar file containing schema is stored in a directory whose path contains a space character, for instance like in the following example
"c:\Program Files\myApp\spring-beans-4.0.2.RELEASE.jar"
then specifying schema location URL in the following way is not sufficient when you are developing some standalone application that should work also offline
<beans
xsi:schemaLocation="
http://www.springframework.org/schema/beans org/springframework/beans/factory/xml/spring-beans-2.0.xsd"
/>
I have learned that result of such schema location URL resolution is a file which has a path like the following
"c:\Program%20Files\myApp\spring-beans-4.0.2.RELEASE.jar"
When I started my application from some other directory which didn't contain space character on its path then schema location resolution worked fine. Maybe somebody faced similar problems? Nevertheless I discoverd that classpath protocol works fine in my case
<beans
xsi:schemaLocation="
http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-2.0.xsd"
/>
The problem lies in the JAR files that you use in your application.
What I did, which worked, was to get inside the JARs for SPRING-CORE, SPRING-BEANS, SPRING-CONTEXT, SPRING-TX that match the version I am using. Within the META-INF folder, I concatenated all the spring.handlers and spring.schemas that come in those JARs.
I killed two birds with one stone, I solved the problem of the schemas so this also works correctly in offline mode.
P.S. I tried the maven plugin for SHADE and the transformers but that did not work.
I had this problem. For posterity, my exception was:
org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 117;
schema_reference.4: Failed to read schema document
'http://www.springframework.org/schema/beans/spring-beans-4.2.xsd'
I solved it when I realised the the version of spring-beans specified in my Maven pom.xml was 4.1.x, thus meaning the specific .xsd could not be found on the classpath.
This was masked for a long time because I normally am online, so I thought being offline had "broken" the build. But it really had nothing to do with it. Updating my pom.xml to specify the correct version of spring-beans, namely 4.2.x, fixed it.
I had the same problem when I'm using spring-context version 4.0.6 and
spring-security version 4.1.0.
When changing spring-security version to 4.0.4 (because 4.0.6 of spring-security not available) in my pom and security xml-->schemaLocation, it gets compiled without internet.
So that mean you can also solve this by:
changing spring-security to a older or same version than
spring-context.
changing spring-context to a newer or same version than
spring-security.
(any way spring-context to be newer or same version to spring-security)
I had ran into this similar problem as well. In my case, my resolution is quite different. Here's my spring context xml file:
...
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
...
I'm not specifying any xsd version as I want spring to use the latest xsd version inside spring dependencies. The spring version my application used was spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE and when I assembly my application into jar, all spring dependencies exist in my classpath. However, I received following error during startup of my spring application context:
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans.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>.
After some hard time troubleshooting, I found the issue is due to the index.list inside the META-INF folder of my jar file. With index.list file, spring namespace handlers cannot be located to parse the spring application context xml correctly. You can read more about this spring issue SPR-5705
By removing indexing from my maven-jar-plugin, I manage to resolve the issue. Hope this will save some times for people having the same problem.
Just make sure the relevant spring jar file are in your runtime classpath. In my case this we were missing spring-tx-4.3.4.RELEASE.jar from runtime classpath. After adding this jar, the issue was resolved.
If there is no internet connection in your platform and you use Eclipse, follow these steps (it solves my problem)
Find the exact xsd files (You can unzip these files from their jars. For example, spring-beans-x.y.xsd in spring-beans-x.y.z.RELEASE.jar)
Add these xsd files to Eclipse XML Catalog. (Preferences->XML->XML Catalog, Add files)
Add these files location to configuration file. (Be careful, write the exact version of file)
Example:
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-x.y.xsd "
Remove jars you added recently in the web-inf ->lib. for example jstl jars.
Related
I a project I use spring jdbc:embedded-database xml config for JUNIT tests. The spring version is 4.3.3.RELEASE.
When i try to configure in xml spring-jdbc in JBoss Developer Studio 7.1.1.GA i got the following issue:
Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/jdbc/spring-jdbc.xsd',
because 1) could not find the document; 2) the document could not be
read; 3) the root element of the document is not .
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jdbc:embedded-database'.
The failing configuration is as follows
<?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:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
...
<jdbc:embedded-database id="dataSource" type="H2" />
Instead, using
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
JBoss Developer Studio doesn't give errors.
Also, I note that the error comes up ONLY from JBoss Developer Studio UI, if I launch tests from maven (or install) I don't have any error.
How can I solve this ?
Thanks for your help.
It looks like JBoss has some problems finding the xsd file inside war/jar.
The workaround are specific to JBoss, details here if you have some Redhat account (I don't) :
https://access.redhat.com/solutions/2381041
https://access.redhat.com/solutions/62251
I migrate resources from different Mule Projects to one Mule Domain Project (which should be used by all the other Mule Projects). Everything works fine except the configuration for the mongodb. If I start everything and the domain starts initialization I get the following error:
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd'
See the corresponding mule-domain-config.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<mule-domain
xmlns="http://www.mulesoft.org/schema/mule/domain"
xmlns:mule="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/domain http://www.mulesoft.org/schema/mule/domain/current/mule-domain.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<!-- configure here resource to be shared within the domain -->
<context:property-placeholder location="${mule.env}.properties "/>
<mongo:config name="mongoconfig" host="${mongo.host}" port="${mongo.port}" database="${mongo.database}" doc:name="Mongo DB" connectTimeout="5000" connectionsPerHost="1" autoConnectRetry="true" threadsAllowedToBlockForConnectionMultiplier="50" username="${mongo.username}">
<mongo:connection-pooling-profile maxActive="150" initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW" maxIdle="50" ></mongo:connection-pooling-profile>
<mule:reconnect frequency="1000"></mule:reconnect>
</mongo:config>
<http:listener-config name="HTTP_Listener_Configuration" host="${http.host}" port="${http.port}" doc:name="HTTP Listener Configuration"/>
</mule-domain>
My first idea was, that I need to add the mule-module-mongo dependency to the pom.xml. But this didn't change anything.
In the Mule Projects the same configuration, with the same schema declaration work just fine. Do I miss something here?
The problem is that Mongo is not supported as a shared resource so you cannot define it's config at the domain level.
You can find more information on what connectors are supported here.
HTH
I am trying to bring up a tomcat server, and am facing problems with loading definitions of spring beans. The applicationContext.xml reads as follows :
<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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task" xmlns:hz="http://www.hazelcast.com/schema/spring"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:solr="http://www.springframework.org/schema/data/solr" xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd
http://www.hazelcast.com/schema/spring META-INF/hazelcast-spring-2.0.xsd
http://www.springframework.org/schema/data/solr http://www.springframework.org/schema/data/solr/spring-solr.xsd
http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd">
..
..
..
..
The IDE (Idea) says it is unable to resolve the file hazelcast-spring-2.0.xsd
The error log says:
13:19:59,909 INFO [localhost-startStop-1][XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [applicationContext.xml]
13:20:02,964 ERROR [localhost-startStop-1][ContextLoader] - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 2 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://hazelcast.com/schema/spring/hazelcast-spring-2.0.xsd; lineNumber: 2; columnNumber: 35; s4s-elt-character:
**Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '301 Moved Permanently'.**
What am I doing wrong here ? I did not touch this file.
I solved it. The problem was that the hazelcast schema version mentioned in the applicationContext.xml "http://www.hazelcast.com/schema/spring META-INF/hazelcast-spring-2.0.xsd" was different than the actual jar I was using, I think mine was 2.4 , so changing it to "http://www.hazelcast.com/schema/spring META-INF/hazelcast-spring-2.4.xsd" solved the problem.
The explanation is that spring is first searching the xsds in the jars and then on internet. So because of the wrong version it was not finding it in the jar, but was hitting the internet.
Had the same problem for http://www.hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd and solved it by adding hazelcast-all with version 3.5 in the maven dependencies rather than simply hazelcast.
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-all</artifactId>
<version>3.5</version>
</dependency>
I am trying to build a Java application that accesses data stored in Database.com using the Database.com Java SDK. I have followed the steps given at qucik start guide # http://forcedotcom.github.com/java-sdk/quick-start. When the application is deployed on tomcat server, i was getting the following exception
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [security- config.xml]
Offending resource: ServletContext resource [/WEB-INF/spring/servlet-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 15 in XML document from ServletContext resource [/WEB-INF/spring/security-config.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 'fss:oauth'.
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at
Here is the security-config.xml 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:security="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:fss="http://www.salesforce.com/schema/springsecurity"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
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.salesforce.com/schema/springsecurity
http://media.developerforce.com/schema/force-springsecurity-1.2.xsd">
<!-- SFDC OAuth security config -->
<fss:oauth logout-from-force-dot-com="true">
<fss:connectionName name="forceDatabase"/>
</fss:oauth>
<!-- Configure Spring Security -->
<!-- use-expressions and hasRole only needed if jsp tags are used.
If not using jsp tags you can omit the use-expressions property and set access="ROLE_USER" on the intercept-url tags -->
<security:http entry-point-ref="authenticationProcessingFilterEntryPoint" use-expressions="true">
<security:anonymous />
<!-- Uncomment this section to enable security -->
<!--
<security:intercept-url pattern="/**" access="isAuthenticated()" />
-->
<!-- sets this as the authentication filter over the default -->
<security:custom-filter position="FORM_LOGIN_FILTER" ref="authenticationFilter"/>
<security:custom-filter position="LOGOUT_FILTER" ref="logoutFilter"/>
</security:http>
I can see that the element oauth is available at the xsd http://media.developerforce.com/schema/force-springsecurity-1.2.xsd. I have tried changing it to different verisons of xsd. But I was not successful.
Please help me to resolve this issue.
I am not sure if this will help, but I was experiencing some similar issue with the tag: .
This was my XML:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
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 http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:endpoint id="HelloWorldService" implementor="com.client.webservices.ratecard.StandardHelloWorldService" address="/HelloWorldService" />
I tried everything without avail, until I discovered that somehow Eclipse proxy was set to direct and I was behind a proxy. Still I was able to get the first set of XSD definitions from the Apache site (http://cxf.apache.org/jaxws) nevertheless within it you can see they are importing a couple more XSD and at this point the redirection was failing and thus I was getting extremely strange errors like this.
Then I set the Eclipse proxy as Native in the preferences and the error magically disappeared.
I hope this will also work in your case.
This typically means your classpath is not setup correctly, it is not an xsd issue. To verify (if you are using Eclipse) you can right click the document and click "validate". If the xsd validates with Eclipse then you don't have to worry about that part.
What I believe happens is that Spring finds the XSD and validates but then when it encounters the fss:oauth tag it tries to find a Java class that is registered to implement the behavior for that tag and fails. Are you certain you have the Salesforce jars on your classpath?
I notice in the included schema force-springsecurity-1.2.xsd, the prefix beans is undefined. What if you modify
<beans xmlns="http://www.springframework.org/schema/beans"
to
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
(and the last line too)?
Following Aravind A advice I simply had this dependency to my POM.
<dependency>
<groupId>org.kubek2k</groupId>
<artifactId>springockito</artifactId>
</dependency>
In fact you just need to put mockito.xsd in your path.
The problem is that the element fss:oauth should be defined in a schema (xsd file) listed at www.salesforce.com/schema/springsecurity, as defined in the declaration xmlns:fss="http://www.salesforce.com/schema/springsecurity" at the top of the page.
However the xsd file that should be in that URL it just isn't there. I guess Salesforce moved it. If you go to www.salesforce.com/schema/springsecurity you see that you get a 404 error.
I've had the same problem and I observed that the application tried to get the xsd file from the internet instead of using the jar file one. The problem was caused because a mismatch in the xsd location definition between the spring.schemas file and the location specified in the applicationContext.xml file. Changing the url from http://media.developerforce.com/schema/force-springsecurity-1.3.xsd to http://www.salesforce.com/schema/springsecurity/force-springsecurity-1.3.xsd in the applicationContext.xml file solved my problem.
I had a similar issue to this going through an integration tutorial for SFDC. In my search to resolve the issue I found this issue on the force.com github repo.
According to Github user todc
The issue, I believe, is with the media.developerforce.com URL, not the salesforce.com URL. Given the age of the repo and the lack of recent activity, I'm guessing the XSD files won't be made available again.
I was able to find archived versions of the XSD file at:
http://grepcode.com/file/repo1.maven.org/maven2/com.force.sdk/force-springsecurity/22.0.8-BETA/com/force/sdk/springsecurity/config/force-springsecurity-1.2.xsd?av=f
You can package that file into your app and refer to the local copy instead, e.g.
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.salesforce.com/schema/springsecurity
classpath:force-springsecurity-1.2.xsd">
</beans>
There's probably a better way, but that's what I was able to get working. Good luck!
Github user iandrosov stated
I now host this "deprecated" fiorsce-springsecurity-1.2.xsd on Heroku to give access to may apps. Sharing my public URL here so it may help others. http://force-spring.herokuapp.com/force-springsecurity-1.2.xsd
I solved this issue by using iandrosov's hosted xsd file, replacing the original
http://media.developerforce.com/schema/force-springsecurity-1.3.xsd
with his hosted xsd
http://force-spring.herokuapp.com/force-springsecurity-1.2.xsd
I've done this simply becaus I am doing a tutorial. For anybody else running into this issue it's probably better to do as Github user todc suggests and
package the file into your app and refer to the local copy instead.
I try to implement a webservice in an existing standalone spring application.
I configured spring:
<?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:jaxws="http://cxf.apache.org/jaxws"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:beans/webservice.xml" />
....
webservice.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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="CheckService" class="test.ws.CheckService">
</bean>
<jaxws:endpoint
id="checkService"
implementor="#CheckService"
address="http://localhost:9000/CheckService" />
I made the configuration according to official documentation and samples from books. I get exception:
03/11/2010 09:34:12 WARN Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://cxf.apache.org/schemas/jaxws.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>.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.warning(Unknown Source)
...
http://cxf.apache.org/schemas/jaxws.xsd is accessible from browser and I think it is well formed (official xsd).
I suspect that the problem is not related to cxf rather swing configuration related.
Thanks,
Hubidubi
This means that it could not access the url when you are running it. This happens to us when we start our struts/tiles application without internet connection first. What you can do as an alternative is download the xsd and put it somewhere where you application can read it.
and replace http://cxf.apache.org/schemas/jaxws.xsd with /path/to/file/jaxws.xsd
Could it be that you're in an environment where you need to set up a proxy to access the web?
You have set the proxy in you browser and can thus access the .xsd via browser.
You need to set up your IDE appropriately or set a system-wide proxy.
Hope I guessed right :p
Finally I figured out the resolution. I had to add appropirate dependencies to maven pom.xml.
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.2</version>
</dependency>
for me works w/ this.
Clearing the files from the Eclipse cache fixed this problem for me.
In Eclipse preferences, I went to General > Network Connections > Cache and removed the cxf files that were causing the issue. The error went away the next time I validated the file.