Back Forum Reply New

spring batch amp; Jaxb2Marshaller

.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)       at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1916)       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)       at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:549)       at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:89)       at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:71)       at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:148)       at org..xml.stream.StaxEventXmlReader.handleStartElement(StaxEventXmlReader.java:154)       at org..xml.stream.StaxEventXmlReader.parseInternal(StaxEventXmlReader.java:98)       at org..xml.stream.AbstractStaxXmlReader.parse(AbstractStaxXmlReader.java:132)       at org..xml.stream.AbstractStaxXmlReader.parse(AbstractStaxXmlReader.java:115)       at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)       ... 33 more
I have seen numerous posts with similar problems, but none of the recommended solutions have resolved the issue.  I suspect that the issue is with the namespace / element declarations in my XSD, but I can't seem to find the right combination.  Any help would be greatly appreciated.  

Here is my Spring config:Code:
lt;beans xmlns=quot;schema/beansquot;
xmlns:batch=quot;schema/batchquot;
xmlns:p=quot;schema/pquot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xmlns:util=quot;schema/utilquot;
xsi:schemaLocation=quot;
schema/beans schema/beans/spring-beans-3.0.xsd
schema/batch schema/batch/spring-batch-2.1.xsd
schema/util schema/util/spring-util-3.0.xsdquot;gt;

lt;batch:job-repository id=quot;jobRepositoryquot;
data-source=quot;dataSourcequot;
transaction-manager=quot;transactionManagerquot;
isolation-level-for-create=quot;READ_COMMITTEDquot;
table-prefix=quot;BATCH_quot; /gt;

lt;bean id=quot;jobLauncherquot;
class=quot;org..batch.core.launch.support.SimpleJobLauncherquot;gt;
lt;property name=quot;jobRepositoryquot; ref=quot;jobRepositoryquot; /gt;
lt;!-- This will allow asynchronous launching of jobs (eg. from a browser) --gt;
lt;property name=quot;taskExecutorquot;gt;
lt;bean class=quot;org..core.task.SimpleAsyncTaskExecutorquot; /gt;
lt;/propertygt;
lt;/beangt;

lt;batch:job id=quot;cfImportJobquot;gt;
lt;batch:step id=quot;cfImportStepquot;gt;
lt;batch:taskletgt;
lt;batch:chunk
reader=quot;cfImportReaderquot;
processor=quot;cfImportProcessorquot;
writer=quot;cfImportWriterquot;
commit-interval=quot;1quot;gt;
lt;batch:streamsgt;
lt;batch:stream ref=quot;cfImportReaderquot; /gt;
lt;/batch:streamsgt;
lt;/batch:chunkgt;
lt;batch:transaction-attributes isolation=quot;READ_COMMITTEDquot; /gt;
lt;/batch:taskletgt;
lt;/batch:stepgt;
lt;/batch:jobgt;

lt;bean id=quot;cfImportReaderquot; class=quot;org..batch.item.xml.StaxEventItemReaderquot;gt;
lt;property name=quot;strictquot; value=quot;truequot; /gt;
lt;property name=quot;fragmentRootElementNamequot; value=quot;Accountquot; /gt;
lt;property name=quot;resourcequot; ref=quot;fileInputLocatorquot; /gt;
lt;property name=quot;unmarshallerquot; ref=quot;jaxbCFMarshallerquot; /gt;
lt;/beangt;

lt;bean id=quot;cfImportProcessorquot; class=quot;com.mydomain.validation.feed.cf.CFImportProcessorquot; /gt;

lt;bean id=quot;cfImportWriterquot; class=quot;com.mydomain.validation.feed.cf.CFImportWriterquot;gt;
lt;property name=quot;sessionFactoryquot; ref=quot;sessionFactoryquot; /gt;
lt;/beangt;

lt;bean id=quot;jaxbCFMarshallerquot; class=quot;org..oxm.jaxb.Jaxb2Marshallerquot;gt;
lt;property name=quot;classesToBeBoundquot;gt;
lt;listgt;
lt;valuegt;com.mydomain.validation.feed.cf.accountextract.Recordslt;/valuegt;
lt;valuegt;com.mydomain.validation.feed.cf.accountextract.Accountslt;/valuegt;
lt;valuegt;com.mydomain.validation.feed.cf.accountextract.Accountlt;/valuegt;
lt;/listgt;
lt;/propertygt;
lt;property name=quot;schemaquot; value=quot;classpath:schemas/CF.xsdquot;/gt;
lt;/beangt;

lt;bean id=quot;fileInputLocatorquot;
class=quot;org..core.io.FileSystemResourcequot; scope=quot;stepquot;gt;
lt;constructor-arg type=quot;java.lang.Stringquot; value=quot;#{jobParameters[filename]}quot; /gt;
lt;/beangt;

lt;/beansgt;
My schema:Code:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;xs:schema
xmlns:xs=quot;2001/XMLSchemaquot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xmlns:cf=quot;cf/accountextractquot;
targetNamespace=quot;cf/accountextractquot;
attributeFormDefault=quot;unqualifiedquot;
elementFormDefault=quot;qualifiedquot; gt;

lt;xs:element name=quot;Recordsquot;gt;
lt;xs:complexTypegt;
lt;xs:sequencegt;
lt;xs:element name=quot;Accountsquot; type=quot;cf:Accountsquot; /gt;
lt;/xs:sequencegt;
lt;/xs:complexTypegt;
lt;/xs:elementgt;

lt;xs:complexType name=quot;Accountsquot;gt;
lt;xs:sequencegt;
lt;xs:element name=quot;Accountquot; type=quot;cf:Accountquot; minOccurs=quot;0quot; maxOccurs=quot;unboundedquot;/gt;
lt;/xs:sequencegt;
lt;/xs:complexTypegt;

lt;xs:complexType name=quot;Accountquot;gt;
lt;xs:sequencegt;
lt;!-- Account --gt; lt;xs:element name=quot;AccountNamequot; type=quot;xs:stringquot; /gt;     lt;xs:element name=quothonequot; type=quot;xs:stringquot; /gt;     lt;xs:element name=quot;ClientNoquot; type=quot;xs:stringquot; minOccurs=quot;0quot;/gt;
lt;/xs:sequencegt;
lt;/xs:complexTypegt;

lt;/xs:schemagt;
... and my XML input file:Code:
lt;?xml version=quot;1.0quot; encoding=quot;utf-8quot;?gt;
lt;Records xmlns=quot;cf/accountextractquot;gt; lt;Accountsgt;   lt;Accountgt;     lt;AccountNamegt;Sample Companylt;/AccountNamegt;     lthonegt;5145551212lt;/PhoneNpagt;     lt;ClientNogt;1234567890lt;/ClientNogt;   lt;/Accountgt;   lt;Accountgt;     lt;AccountNamegt;Sample Companylt;/AccountNamegt;     lthonegt;5145551212lt;/PhoneNpagt;     lt;ClientNogt;1234567890lt;/ClientNogt;   lt;/Accountgt; lt;/Accountsgt;
lt;/Recordsgt;
Thanks in advance!

You can probably avoid the schema error by simply switching off the validation (miss out the schema= declaration in the unmarshaller).

I'm not sure anyone who hangs out in this forum knows the answer.  OXM is not a Batch feature so you might get more help on the main Spring forum, or the Web Services forum.  If you re-post there you probably need to include the .java source for your Account object.

lthonegt;5145551212lt;/PhoneNpagt;

This is wrong,  it needs to be lthonegt;5145551212lt;/Phonegt;
¥
Back Forum Reply New