i am working on marshalling java objects to xml using spring.oxm and jaxb2 with SAX Parser.
I am running into a problem with my marshaller throwing an org.xml.sax.SAXParseException stating that there is:
Invalid content was found starting with element 'ns59:ArtID'. One of {[...],http://www.bipro.net/namespace/gevo":ArtID, [...]} is expected.
In my org.springframework.oxm.jaxb.JAXBMarshaller.graph everything seems to be ok, at least for my understanding. The graph shows these variables in debug mode: This is the jaxax.xml.transform.result.writer before breaking off with the error and leaving the output string like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns43:getShipmentResponse
xmlns="http://www.bipro.net/namespace/basis"
xmlns:ns2="http://www.bipro.net/namespace/nachrichten"
xmlns:ns3="http://www.bipro.net/namespace/abrechnung"
xmlns:ns4="http://www.bipro.net/namespace/allgemein"
xmlns:ns5="http://www.bipro.net/namespace/schaden-leistung"
xmlns:ns6="http://www.bipro.net/namespace/partner"
xmlns:ns7="http://www.bipro.net/namespace/sachen"
xmlns:ns8="http://www.bipro.net/namespace/versicherung/produktmodell/rechtsschutz"
xmlns:ns9="http://www.bipro.net/namespace/produktmodell"
xmlns:ns10="http://www.bipro.net/namespace/versicherung/produktmodell"
xmlns:ns11="http://www.bipro.net/namespace/kapitalanlage/basis"
xmlns:ns12="http://www.bipro.net/namespace/versicherung/produktmodell/komposit"
xmlns:ns13="http://www.bipro.net/namespace/kapitalanlage/transaktion"
xmlns:ns14="http://www.bipro.net/namespace/provision"
xmlns:ns15="http://www.bipro.net/namespace/beteiligungsverhaeltnis"
xmlns:ns16="http://www.bipro.net/namespace/kapitalanlage"
xmlns:ns17="http://www.bipro.net/namespace/versicherung/produktmodell/kraftfahrt"
xmlns:ns18="http://www.bipro.net/namespace/fragen"
xmlns:ns19="http://www.bipro.net/namespace/versicherung/produktmodell/kranken"
xmlns:ns20="http://www.bipro.net/namespace/vertrag"
xmlns:ns21="http://www.bipro.net/namespace/foerderung"
xmlns:ns22="http://www.bipro.net/namespace/versicherung/produktmodell/leben"
xmlns:ns23="http://www.bipro.net/namespace/versicherung/unfall"
xmlns:ns24="http://www.bipro.net/namespace/sepa"
xmlns:ns25="http://www.bipro.net/namespace/versicherung/haftpflicht"
xmlns:ns26="http://www.bipro.net/namespace/schaden-objekte"
xmlns:ns27="http://www.bipro.net/namespace/schaden-details"
xmlns:ns28="http://www.bipro.net/namespace/versicherung/sach"
xmlns:ns29="http://www.bipro.net/namespace/fahrzeug"
xmlns:ns30="http://www.bipro.net/namespace/gevo"
xmlns:ns32="http://www.bipro.net/namespace/evb"
xmlns:ns33="http://www.bipro.net/namespace/prozesse/foerderdaten"
xmlns:ns34="http://www.bipro.net/namespace/prozesse/partner"
xmlns:ns35="http://www.bipro.net/namespace/prozesse/schaden"
xmlns:ns36="http://www.bipro.net/namespace/prozesse/vertrag"
xmlns:ns37="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/komposit"
xmlns:ns38="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/kraftfahrt"
xmlns:ns39="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/kranken"
xmlns:ns40="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/leben"
xmlns:ns41="http://www.bipro.net/namespace/versicherung/tarifierung"
xmlns:ns42="http://www.bipro.net/namespace/tools/iban"
xmlns:ns43="http://www.bipro.net/namespace/transfer"
xmlns:ns44="http://www.bipro.net/namespace/transfer/abrechnung"
xmlns:ns45="http://www.bipro.net/namespace/transfer/gevo"
xmlns:ns46="http://www.bipro.net/namespace/transfer/inkassostoerfall"
xmlns:ns47="http://www.bipro.net/namespace/transfer/schaden-leistung"
xmlns:ns48="http://www.bipro.net/namespace/transfer/schadenrueckfrage"
xmlns:ns49="http://www.bipro.net/namespace/transfer/sepa"
xmlns:ns50="http://www.bipro.net/namespace/transfer/vertrag"
xmlns:ns51="http://www.bipro.net/namespace/kontext/beruf"
xmlns:ns52="http://www.bipro.net/namespace/kontext/betriebsart"
xmlns:ns53="http://www.bipro.net/namespace/kontext/fahrzeug"
xmlns:ns54="http://www.bipro.net/namespace/kontext/partner"
xmlns:ns55="http://www.bipro.net/namespace/kontext/schaden"
xmlns:ns56="http://www.bipro.net/namespace/kontext/unternehmen"
xmlns:ns57="http://www.bipro.net/namespace/kontext/vertrag"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime"> <ns43:Response>
<ns2:BiPROVersion>2.6.1.0.0</ns2:BiPROVersion>
<ns2:Status>
<ns2:ProzessID>1530635989611</ns2:ProzessID>
<ns2:Zeitstempel>2018-07-03T18:41:12</ns2:Zeitstempel>
<ns2:StatusID>OK</ns2:StatusID>
<ns2:Schwebe>false</ns2:Schwebe>
<ns2:Meldung>
<ns2:ArtID>Hinweis</ns2:ArtID>
<ns2:MeldungID>04000</ns2:MeldungID>
</ns2:Meldung>
</ns2:Status>
<ns43:Lieferung>
<ns43:ID>1530636072667</ns43:ID>
<ns43:Einstellzeitpunkt>2016-12-05T00:00:00</ns43:Einstellzeitpunkt>
<ns43:Kategorie>120000000</ns43:Kategorie>
<ns43:VerfuegbarBis>2019-12-05</ns43:VerfuegbarBis>
<ns43:Transfer xsi:type="ns45:CT_GeVoTransfer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Has anyone an idea and can point me to the right direction?
Lexicore asked for 2 things. 1. the complete XSD, which you can take from my open github repo at https://github.com/JoBieker/soap-bipro/tree/master/securess-bipro/src/main/resources/xsd. 2. the complete xml, which i have not, as i wanted to create it. but if i would have been successful something like this should have come out. this is a nother gevo-transfer case, but the structure should be the same. You can download here: https://github.com/JoBieker/soap-bipro/blob/master/securess-bipro/src/main/resources/target-xml.xml
Finally lexicores questions taught me that i totally forgot to mention that i wanted to marshall a xml. So here it is and there is the code on my public github repo: https://github.com/JoBieker/soap-bipro And here is the complete exception as provided by the console:
2018-07-04 22:19:46.407 ERROR 12986 --- [ main] o.s.boot.SpringApplication
: Application run failedorg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securessBiproApplication': Unsatisfied dependency expressed through field 'marshaller'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'createJaxb2Marshaller' defined in class path resource [de/securess/bipro/config/Jaxb2Config.class]: Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'context.path' in value "${context.path}" at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1350) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:580) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at de.securess.bipro.SecuressBiproApplication.main(SecuressBiproApplication.java:43) [classes/:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'createJaxb2Marshaller' defined in class path resource [de/securess/bipro/config/Jaxb2Config.class]: Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'context.path' in value "${context.path}" at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] ... 18 common frames omitted Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'context.path' in value "${context.path}" at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:839) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1086) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:474) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1256) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1105) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] ... 26 common frames omitted
Best regards, jcb
I've figured it out.
The problem was not in marshalling, but in the validation.
You have configured JAXB to validate the marshalled XML agains the specified schemas:
marshaller.setSchemas(
new ClassPathResource("/xsd/bipro-nachrichten-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-transfer-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-transfer-gevo-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-gevo-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-prozesse-vertrag-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-basis-2.6.0.xsd")
);
The problem appears in the ArtID
element of the CT_Geschaeftsvorgang
type. This is how you set this element in your Java code:
JAXBElement<String> value = new JAXBElement<String>(
new QName("http://wwww.bipro.net/namespace/transfer/gevo","ArtID"), String.class, "value"
);
value.setValue("120000000");
CTGeschaeftsvorgang ctVertragsauskunft = new CTVertragsauskunft();
ctVertragsauskunft.setArtID(value);
Note the namespace URI: http://wwww.bipro.net/namespace/transfer/gevo
, with four w
s and transfer
before gevo
.
Now if you carefully check your schema bipro-gevo-2.6.0.xsd
you will see that it has a different namespace:
The correct namespace is http://www.bipro.net/namespace/gevo
.
Changing http://wwww.bipro.net/namespace/transfer/gevo
to http://www.bipro.net/namespace/gevo
in your Java code fixes the problem.