Error with batch-int:job-launching-gateway when using spring batch - spring

I am trying to use batch-int:job-launching-gateway but I get the following error:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:spring/integration-context.xml]
Offending resource: class path resource [spring/application-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 68 in XML document from class path resource [spring/integration-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException;
lineNumber: 68; columnNumber: 156; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'batch-int:job-launching-gateway'.
My xml contains the following:
<beans:beans xsi:schemaLocation=" http://www.springframework.org/schema/batch-integration
http://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:batch-int="http://www.springframework.org/schema/batch-integration"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns="http://www.springframework.org/schema/beans">
And the line the error occurs at is:
<batch-int:job-launching-gateway job-launcher="jobLauncher" reply-channel="jobLaunchReplyChannel" request-channel="channelStart"/>
The channel "channelStart" is defined above this.
I'm new to spring batch so any help would be great. I also have spring-batch-integration, spring-batch-core, spring-batch-infrastructure and spring-integration-event on the classpath.

I have resolved the issue. I initially had different versions for both spring-batch-core and spring-batch-integration. When I made these two the same versions the error did not appear.

Related

Spring Security 3.0

I am adding the http tag for security reason in my security-context.xml.
For that I have addded security name space.
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
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/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
I am getting the below exception not sure why this exception is getting even if I added the name space for bean.
I have 3.0.5 spring version.
Am I missing something in this please suggest. ?
Stacktrace :
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 URL location [classpath*:spring-security/*-context.xml]
Offending resource: class path resource [spring-security/context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 31 in XML document from file [security.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 'bean'.
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 'bean'.
Remove the -3.0 from the schema location as spring automatically seeks the highest version in your workspace -
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
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/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

error message with spring “Cannot find the declaration of element 'beans'.”

I'm trying to set up a simple spring application and I'm getting the below exception.
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from class path resource [NewFile.xml] is invalid; nested e
xception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
I don't find my problem. this is my NewFile.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mail="http://www.springframework.org/schema/integration/mail"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration/mail
http://www.springframework.org/schema/integration/mail/spring-integration-mail-1.0.xsd" >
I use Spring Integration 1.0.4, Spring core 2.5.6, and javamail 1.4
Best Regards
There are two "schema" in the path:
<beans xmlns="http://www.springframework.org/schema/schema/beans"
IIRC only one is required:
<beans xmlns="http://www.springframework.org/schema/beans"

Camel/Spring giving the error: "The Prefix broker for element 'broker:broker' is not bound" when declaring ActiveMQ broker

I am trying to use the embedded camel activemq broker. When I include the following xml in my Spring file, I get the error (more complete stack trace at bottom):
Line 13 in XML document ... is invalid; ... The prefix "broker" for element "broker:broker" is not bound
The xml referenced:
<broker:broker useJmx="false" persistent="false" brokerName="localhost">
<broker:transportConnectors>
<broker:transportConnector uri="tcp://localhost:61616"/>
</broker:transportConnectors>
</broker:broker>
This XML is taken from the Camel in Action book. I (believe that I) have all the required maven dependencies.
More complete stack trace:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [META-INF/spring/filecopycontext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 73; The prefix "broker" for element "broker:broker" is not bound.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at ...
I figured it out. Missing from the topmost tag, was the line: xmlns:broker="http://activemq.apache.org/schema/core"
you need to specify the broker XML namespace/xsd...
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:broker="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">

The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'

I am using Spring 3.2.3.RELEASE with maven to pull the dependencies. When building the project in Eclipse am getting following error:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from class path resource [META-INF/spring/application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 64; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
My appication-context.xml has the following:
<?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-3.2.xsd
http://www.springframework.org/schema/context/
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:component-scan base-package="com.example" />
I know that I am pulling the correct jar files as my Maven Dependencies shows:
Inside the META-INF/sping.schemas I can see that I have the right schema declaration in my 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-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd
http\://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd
http\://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd
I have also looked at these to no avail:
Can't load spring 3 schemas
The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'
No declaration can be found for element 'context:component-scan'
The matching wildcard is strict, but no declaration can be found for element 'context:component-scan
Please help, it's driving me crazy .... :(
For starters you should fix your dependencies. You are mixing Spring 3.2.3 and 2.0.6 jars (that is problems waiting to happen).
Next to that your declaration is wrong http://www.springframework.org/schema/context/ must be http://www.springframework.org/schema/context.

no declaration can be found for 'mvc:annotation-driven'

I have got simple web app (spring 3 + thymeleaf, deploy on glassfish 3.x). When I try run it there is an error:
SEVERE: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 16 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 24; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
here is 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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
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-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/context/spring-mvc-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="arek" />
<mvc:annotation-driven></mvc:annotation-driven>
</beans>
I searched but nothing. Thanks for help.
Try http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd instead of http://www.springframework.org/schema/context/spring-mvc-3.1.xsd .
Hope this helps.
The spring MVC schema file that you are trying to reference in your application context (http://www.springframework.org/schema/context/spring-mvc-3.1.xsd) doesn't exist. Open this link yourself in a browser and you will see 404 error. The latest MVC schema file location is (http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd). Use this and you won't get the exception.

Resources