anskaffelser / vefa-validator

Generic validator as a Java library originally created for use within eProcurement.
17 stars 17 forks source link

ValidatorBuilder.build throws ExceptionInInitializerError when processing asicmanifest.xml #40

Closed thierryvt closed 5 years ago

thierryvt commented 7 years ago

Title says it, when I try to build the validator the program crashes.

Code used (I downloaded the necessary artifacts to a local directory):

ValidatorBuilder builder = ValidatorBuilder.newValidator();
builder.setSource(new RepositorySource(new File("D:\\workspace\\validator_artifacts").toURI()));            
validator = builder.build();

as soon as "builder.build" is run the following excecption is thrown:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at no.difi.asic.AbstractAsicReader.handleMetadataEntry(AbstractAsicReader.java:146)
    at no.difi.asic.AbstractAsicReader.getNextFile(AbstractAsicReader.java:75)
    at no.difi.asic.AsicReader.getNextFile(AsicReader.java:21)
    at no.difi.vefa.validator.source.AbstractSourceInstance.unpackContainer(AbstractSourceInstance.java:71)
    at no.difi.vefa.validator.source.RepositorySourceInstance.<init>(RepositorySourceInstance.java:32)
    at no.difi.vefa.validator.source.RepositorySource.createInstance(RepositorySource.java:48)
    at no.difi.vefa.validator.ValidatorInstance.<init>(ValidatorInstance.java:72)
    at no.difi.vefa.validator.Validator.load(Validator.java:126)
    at no.difi.vefa.validator.ValidatorBuilder.build(ValidatorBuilder.java:188)
    at eu.sendregning.oxalis.Main.main(Main.java:51)
Caused by: java.lang.IllegalStateException: Unable to create JAXBContext: 22 counts of IllegalAnnotationExceptions
    at no.difi.asic.CadesAsicManifest.<clinit>(CadesAsicManifest.java:28)
    ... 10 more
Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 22 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://www.w3.org/2000/09/xmldsig#}DigestMethodType". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
            at org.w3._2000._09.xmldsig_.DigestMethodType
            at protected org.w3._2000._09.xmldsig_.DigestMethodType org.w3._2000._09.xmldsig_.ReferenceType.digestMethod
            at org.w3._2000._09.xmldsig_.ReferenceType
            at protected java.util.List org.w3._2000._09.xmldsig_.SignedInfoType.reference
            at org.w3._2000._09.xmldsig_.SignedInfoType
            at protected org.w3._2000._09.xmldsig_.SignedInfoType org.w3._2000._09.xmldsig_.SignatureType.signedInfo
            at org.w3._2000._09.xmldsig_.SignatureType
            at public javax.xml.bind.JAXBElement org.w3._2000._09.xmldsig_.ObjectFactory.createSignature(org.w3._2000._09.xmldsig_.SignatureType)
            at org.w3._2000._09.xmldsig_.ObjectFactory
            at protected java.util.List org.w3._2000._09.xmldsig_.DigestMethod.content
            at org.w3._2000._09.xmldsig_.DigestMethod
            at protected org.w3._2000._09.xmldsig_.DigestMethod org.etsi.uri._02918.v1_2.DataObjectReference.digestMethod
            at org.etsi.uri._02918.v1_2.DataObjectReference
            at protected java.util.List org.etsi.uri._02918.v1_2.ASiCManifest.dataObjectReferences
            at org.etsi.uri._02918.v1_2.ASiCManifest
    this problem is related to the following location:

left out a big part of repeating the same "two classes have the same xml type name" errors. (that and the part below it repeat 10 times or so) Followed by about 10 of these

There's no ObjectFactory with an @XmlElementDecl for the element {http://www.w3.org/2000/09/xmldsig#}HMACOutputLength.
    this problem is related to the following location:
            at protected java.util.List org.w3._2000._09.xmldsig_.SignatureMethod.content
            at org.w3._2000._09.xmldsig_.SignatureMethod
            at protected org.w3._2000._09.xmldsig_.SignatureMethod org.w3._2000._09.xmldsig_.SignedInfo.signatureMethod
            at org.w3._2000._09.xmldsig_.SignedInfo
            at protected org.w3._2000._09.xmldsig_.SignedInfo org.w3._2000._09.xmldsig_.Signature.signedInfo
            at org.w3._2000._09.xmldsig_.Signature
            at protected java.util.List org.etsi.uri._02918.v1_2.XAdESSignatures.signatures
            at org.etsi.uri._02918.v1_2.XAdESSignatures
            at public org.etsi.uri._02918.v1_2.XAdESSignatures org.etsi.uri._02918.v1_2.ObjectFactory.createXAdESSignatures()
            at org.etsi.uri._02918.v1_2.ObjectFactory
            at protected java.util.List org.etsi.uri._02918.v1_2.AnyType.content
            at org.etsi.uri._02918.v1_2.AnyType
            at org.etsi.uri._02918.v1_2.Extension
            at protected java.util.List org.etsi.uri._02918.v1_2.ExtensionsListType.extensions
            at org.etsi.uri._02918.v1_2.ExtensionsListType
            at protected org.etsi.uri._02918.v1_2.ExtensionsListType org.etsi.uri._02918.v1_2.DataObjectReference.dataObjectReferenceExtensions
            at org.etsi.uri._02918.v1_2.DataObjectReference
            at protected java.util.List org.etsi.uri._02918.v1_2.ASiCManifest.dataObjectReferences
            at org.etsi.uri._02918.v1_2.ASiCManifest

And finally ending with

at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source)
    at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
    at javax.xml.bind.ContextFinder.find(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
    at no.difi.asic.CadesAsicManifest.<clinit>(CadesAsicManifest.java:26)
    ... 10 more

I don't really enjoy the idea of having to do major changes in the sourcecode of the validator/asic parser projects so I'm hoping it's just a setting I'm missing.

Any help is appreciated.

thierryvt commented 7 years ago

log.txt

added complete log if you need it

ftonik commented 7 years ago

I think that you have some problems with ResourceRepository. If you have Internet connection on develop PC try remove:

builder.setSource(new RepositorySource(new File("D:\\workspace\\validator_artifacts").toURI()));

and run again. Artifacts will downloaded from remote server. And all be OK. To use locally artifacts downloaded from server I write:

Path path = Paths.get("d:/downloads/Production"); DirectorySource source = new DirectorySource(path) Validator validator = ValidatorBuilder.newValidator().setSource(source).build() Validation validation = validator.validate(<any file>) def report = validation.getReport()

thierryvt commented 7 years ago

Bot running it without settings the source and the way you paste it there produce the same set of exceptions.

this is how I run it now:

Path path = Paths.get("D:/peppol-workspace/validator_artifacts");
DirectorySource source = new DirectorySource(path);
Validator validator = ValidatorBuilder.newValidator().setSource(source).build();

Leaving the "setSource" out of it makes no difference, it's always the "build" method that throws the exception. The last line that outputs (before stacktraces) is always:

2017-01-24 14:31:18,818 INFO [no.difi.asic.AbstractAsicReader] Found file: META-INF/asicmanifest.xml

So might there be an issue with reading the asicmanifest.xml? log.txt

Log once more attached should you want to take a look at it.