Closed MrMikeFloyd closed 4 years ago
A little update that might help narrowing down the issue: Since we previously worked with two separate modules (api
for all frontend-facing code; logic
for all business logic, containing the validator) I had a look at how the validator would behave when placing all code in the same module. Using a flat structure with all code in a single maven module, the code initializing the validator wouldn't reside in a separate jar, but in the WAR's classes
directory. The validator can then be used without running into a FileNotFoundException
. The packaged EAR looks like this:
├───exploded_war
│ ├───META-INF
│ │ MANIFEST.MF
│ └───WEB-INF
│ ├───classes
│ │ ├───de
│ │ │ └───xxxx
│ │ │ └───xxxx
│ │ │ └───xxxx
│ │ │ └───xxxx
│ │ │ └───api
│ │ │ ├───config
│ │ │ │ AppInitializer.class
│ │ │ │ WebServiceConfig.class
│ │ │ │
│ │ │ └───xrechnung
│ │ │ ├───boundary
│ │ │ │ *.class files here
│ │ │ │
│ │ │ ├───config
│ │ │ │ *.class files here
│ │ │ │
│ │ │ ├───control
│ │ │ │ *.class files here
│ │ │ │
│ │ │ └───logic <-- All code from logic module moved here
│ │ │ ├───kosit
│ │ │ │ KositValidator.class <-- Validator is initialized and used here
│ │ │
│ │ └───xRechnung_v120
│ │ │ EN16931-CII-validation.xslt
│ │ │ EN16931-UBL-model.xslt
│ │ │ scenarios.xml
│ │ │
│ │ ├───resources
│ │ │ │ default-report.xsl
│ │ │ │ xrechnung-report.xsl
│ │ │ │
│ │ │ ├───cii
│ │ │ │ └───16b
│ │ │ │ ├───xsd
│ │ │ │ │ CrossIndustryInvoice_100pD16B.xsd
│ │ │ │ │ CrossIndustryInvoice_QualifiedDataType_100pD16B.xsd
│ │ │ │ │ ... other schemas omitted for brevity
│ │ │ │ │
│ │ │ │ └───xsl
│ │ │ │ EN16931-CII-validation.xsl
│ │ │ ├───ubl
│ │ │ │ └───2.1
│ │ │ │ ├───xsd
│ │ │ │ │ ├───common
│ │ │ │ │ │ CCTS_CCT_SchemaModule-2.1.xsd
│ │ │ │ │ │ UBL-CommonAggregateComponents-2.1.xsd
│ │ │ │ │ | ... other schemas omitted for brevity
│ │ │ │ │ │
│ │ │ │ │ └───maindoc
│ │ │ │ │ UBL-ApplicationResponse-2.1.xsd
│ │ │ │ │ UBL-AttachedDocument-2.1.xsd
│ │ │ │ │ ... other schemas omitted for brevity
│ │ │ │ └───xsl
│ │ │ │ EN16931-UBL-validation.xsl
│ │ │ ├───xrechnung
│ │ │ │ └───1.2.0
│ │ │ │ └───xsl
│ │ │ │ XRechnung-CII-validation.xsl
│ │ │ │ XRechnung-UBL-validation-CreditNote.xsl
│ │ │ │ XRechnung-UBL-validation-Invoice.xsl
│ │ │ │
│ │ │ └───xsd
│ │ │ report.xsd
│ │ │ scenarios.xsd
│ │ │
│ │ └───schematron
│ │ EN16931-CII-validation-expanded.sch
│ │ EN16931-CII-validation-unabstract.sch
│ │ ... other schematron files omitted for brevity
│ │
│ └───lib
│ validationtool-1.1.0.jar <-- Validator lies here
| ... all other external libraries here
├───META-INF
│ application.xml
│ MANIFEST.MF
This setup looks similar to issue 28 and has already been confirmed to work fine. Since we deploy into an enterprise infrastructure we will need to maintain a maven multi-module setup though- moving all code to the same module is fine for testing purposes, but not a viable approach for production. My question would therefore be: How can the validator successfully load the schema definitions from scenarios.xml
in a multi-module project setup? My gut feeling is that this simply isn't possible with the current validator release.
I don't know whether this is still relevant to you (sorry for the late reply), but loading the scenario contents from a jar should be possible when all of the stuff is packaged in the same jar. There is test case that loads relative resources from a jar.
The problem is, that jar-URIs are opaque, not hierarchical. so loading relative stuff is impossible. To circumvent this, we implemented a workaround (see RelativeUriResolver.java for details).
I guess the problem is somewhat related to the ear-deployment. We need to investigate this.
I don't know whether this is still relevant to you (sorry for the late reply), but loading the scenario contents from a jar should be possible when all of the stuff is packaged in the same jar. There is test case that loads relative resources from a jar.
The problem is, that jar-URIs are opaque, not hierarchical. so loading relative stuff is impossible. To circumvent this, we implemented a workaround (see RelativeUriResolver.java for details).
I guess the problem is somewhat related to the ear-deployment. We need to investigate this.
Cheers for checking in. In the meantime we simply refrained from putting the Validator into a separate module. Currently we build and ship a single-module application (which results in everything being packaged into the same jar just like you mentioned). This works ok and doesn't pose any issues to us. It might be necessary to seperate the modules at a later point in time, but this is not a requirement we currently have.
I would then close issue and wait for a feature request requesting EAR - support. thank you for sharing your workaround.
I would then close issue and wait for a feature request requesting EAR - support. thank you for sharing your workaround.
Thanks. We will have a discussion whether EAR support is something we will need in the future and create a feature request if need be. I wish you happy holidays!
When creating a new
DefaultCheck
from aCheckConfiguration
, Validator release v1.1.0 throws aFileNotFoundException
, apparently because it is unable to load the schema files listed inscenarios.xml
. The behaviour is very similar to this Issue. I can also confirm that the validator works fine in a Spring Boot standalone fat jar, however our setup looks slightly different, resulting in a failing startup sequence:Our code initializing the validator, including its
scenarios.xml
and xsd files reside in thekositvalidator-logic*.jar
. More information on the package structure can be found in the attached gist.Details/ additional information All information on how we call the Validator, as well as log files and the exact EAR package structure can be found in this gist.
Thanks a lot for any helpful advice!