Results 1 to 4 of 4

Thread: The matching wildcard is strict, but no declaration can be found for element 'bean'

  1. #1
    Join Date
    Jun 2011
    Posts
    9

    Default The matching wildcard is strict, but no declaration can be found for element 'bean'

    I am trying to read from cvs and write to csv using FlatFileItemReader and FlatFileItemWriter . When trying to execute getting following error

    Code:
    ERROR - Job Terminated in error: Line 44 in XML document from class path resource [my-job.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'.
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 44 in XML document from class path resource [my-job.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'.
    	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: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.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:282)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574)
    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'.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    	... 15 more
    I have configured my job as

    Code:
    code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans
    	xmlns="http://www.springframework.org/schema/beans"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schem...spring-aop.xsd
    		http://www.springframework.org/schema/batch http://www.springframework.org/schem...-batch-2.1.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    		
    
    
    <import resource="MEMORY_JOBREPOSITORY.xml"/>   
    <!--<import resource="DB-JOBREPOSITORY.xml"/> --> 
    
    <bean name="myItemReader" id="myItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
    	<property name="resource" value="file:InputFolder\nodes.csv" />		
    	<property name="lineMapper">
    	<bean 
    	class="org.springframework.batch.item.file.mapping.DefaultLineMapper">	
    	<property name="lineTokenizer">				
    	<bean 
    	class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
    	<property name="delimiter" value=","/>
    	<property name="names" 
    	value="nodeID,analysisConfigID,nodeParamID,operatorParamID" />
    	</bean>
    	</property>
    	<property name="fieldSetMapper">
    	<bean class="com.file.InputPOJOFieldMapper" />
    	</property>
    	</bean>
    	</property>
    </bean>
    
    <bean id="mytemProcessor" 	class="com.my.CountProcessor" >
    
    
    
    <bean name="myItemWriter" id="myItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"
    xmlns="http://www.springframework.org/schema/batch">
    	<property name="resource" value="file:OutputFolder\output.txt" /> 
    	<property name="shouldDeleteIfExists" value="true"/>
    	<property name="lineAggregator">
    	<bean 
    	class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
    	<property name="delimiter" value="-"/>
    	<property name="fieldExtractor">
    	<bean 
    	class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
    	<property name="names" value="nodeID,analysisID"/>
    	</bean>
    	</property>
    	</bean>
    	</property>
    </bean>
    
    
     <bean id="dynamicJobParameters" 
    class="com.support.DynamicJobParameters" />
    
    <job id="myJob" job-repository="jobRepository" incrementer="dynamicJobParameters" xmlns="http://www.springframework.org/schema/batch"> 
    	<step id="step_my"> 
    		<tasklet transaction-manager="jobRepository-transactionManager" >
    			<chunk reader="myItemReader" processor="myItemProcessor" 
    				writer="myItemWriter" 
    				 commit-interval="1" /> 
    		</tasklet>
    	</step>		
    </job>	
    
    </beans>
    I searched through forum but got no clue.
    Could anyone please tell exaclty what is wrong with the code?
    Last edited by amrudhta; Jul 20th, 2011 at 07:22 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Code:
    <bean name="myItemWriter" id="myItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"
    xmlns="http://www.springframework.org/schema/batch">
    If you copy/paste code you still need to know what is going on... Remove the part in read..Bean is not in the batch namespace it is in the beans name space which you declared as root.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jun 2011
    Posts
    9

    Default

    Yes thx Marten ..got to know the mistake..that error got resolved but now getting another error as :
    ERROR - Job Terminated in error: Line 9 in XML document from class path resource [Ipredict-job.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans:beans'.

    I declared batch as root . Here is the namespace :
    <beans:beans xmlns="http://www.springframework.org/schema/batch"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.1.xsd
    http://www.springframework.org/schema/batch
    http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">

    What this error exactly means? As I am new to spring batch , plz let me know if I need to go through any document related to this..

    thx in adv..

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Please use [ code][/code ] tags when pasting code... There is no 2.1 version of spring so not sure which xsd you are trying to include... I really suggest you readup on xsd and namespaces and how they work, because you seem to lack that knowledge.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •