You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by Christofer Dutz <ch...@c-ware.de> on 2019/05/09 10:19:50 UTC

Referencing DFDL schemas in other jars?

Hi all,

after solving my last problem, I am stuck with another one … as I mentioned in the other thread I have one DFDL schema, which defines all the simple types that will be used by any PLC4X schema.
In order to do so, this is located in a dedicated maven module and a dedicated jar.

Now I added a dependency to that jar an now want to reference this in my protocol jar.

No matter what I try, DFDL always complains about not being able to resolve this.

So how can I reference and/or import schemas contained in another jar that’s in my classpath?

Chris

Re: Referencing DFDL schemas in other jars?

Posted by "Beckerle, Mike" <mb...@tresys.com>.
Suggest this behavior description go on a user site page for daffodil.

I think the trick we use to deal with dependencies like how milstd2045 and VMF are kept independent is also a technique many users will need.

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Steve Lawrence <sl...@apache.org>
Sent: Friday, May 10, 2019 8:40:25 AM
To: users@daffodil.apache.org
Subject: Re: Referencing DFDL schemas in other jars?

After some more research on XML Catalogs, I have a much better idea of
what's going on here.

First, we use Apache XML Commons Catalog Resolver for resolving URIs
from an XML Catalog. So we probably don't want to change the behavior of
that too much. The Catalog Resolver will always return an absolute
path-there's no way around it that I can see. So by the time Daffodil
gets the resolved URI, it's going to be absolute and we cannot use the
same logic as we use for import/include schemaLocation. This was part of
the problem you were seeing. The XML Catalog Resolver converted the
relative paths to absolute, but did so in a way that returned locations
that don't actually exist.

So how does it calculate an absolute path when the XML Catalog contains
relative URLS? It has the concept of "base", which specifies the base
path to use when paths are relative. You can manually change the base in
the XML Catalog file, but this is probably a bad idea since the absolute
base is going to be different on different systems. By default, the base
is the absolute path to the XML Catalog file it resolved a URI from.

When I tested this yesterday, I saw attempts to access the current
working directory because I was actually testing with an XML Catalog
file in my current working directory. So that became the base and
resulted in bad absolute paths. You saw errors for a similar reason of
an incorrect base, but not current working directory issues.

In your case, you had overridden daffodil-built-in-catalog.xml, and you
did so in each of your jars. Daffodil actually only finds the first one
on the classpath, so specifying multiple daffodil-built-in-catalog.xml's
won't actually help, so this is one thing that needs to change.

In this case, it finds the xml catalog in the s7 jar. So the base for
your XML Catalog is something like


jar:file:/path/to/plc4x-protocols-s7-0.4.0-SNAPSHOT.jar!/daffodil-built-in-catalog.xml

Note the syntax for specifying the location of a file inside a jar.

So this means any URI found in this XML catalog will get an absolute
path to that s7 jar. When we try to find the plc4x protocol.dfdl.xsd
file, it won't be able to find it because that's in a different jar.
This is why duplicating the file in the s7 jar solved the problem.

I'd probably recommend just using schemaLocation, but what's the
solution if you still want to use XML Catalogs?

First you need to specify an XML catalog file in each jar, and each
catalog should only contain references to files in that jar. So
plc4x/src/main/resources/xcatalog should have:

  <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="http://plc4x.apache.org/plc4x"
         uri="org/apache/plc4x/protocols/protocol.dfdl.xsd"/>
  </catalog>

And s7/src/main/resources/xcatalog should have:

  <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="http://plc4x.apache.org/s7"
         uri="org/apache/plc4x/protocols/s7/protocol.dfdl.xsd"/>
  </catalog>

With the different XML Catalogs in different jars with the correct
content, you need to tell the XML Catalog Resolver where they are.
There's a handful of ways to do this, but maybe the easiest is to add
the absolute paths to the catalog files in the jars to the
"xml.catalog.files" property. Multiple files can be separated with a
semicolon. For example:

-Dxml.catalog.files=jar:file:/path/to/plc4x.jar!/xcatalog;jar:file:/path/to/s7.jar!/xcatalog

Note that I've changed the names from daffodil-built-in-catalog.xml to
"xcatalog". In general, it's probably a bad idea to override the built
in catalog, since Daffodil uses that for some internal resolutions.

With that, or something very similar, you should be able to use XML
Catalogs provided in jars for resolving import/include.

We do still need to change the Assert so that when a file can't be
opened we don't abort. But I believe the resolution of XML Catalogs is
behaving correctly, and can't be easily changed to use logic similar to
schemaLocation.

- Steve



On 5/9/19 12:15 PM, Steve Lawrence wrote:
> Thanks, was able to reproduce and track down the issue.
>
> The problem here is the use of the xml catalog. When we resolve to a URI
> from the XML catalog, we treat is as a plain old URI. We don't attempt
> to resolve it to classpath or anything fancy like we do with the
> schemaLocation attribute in an include/import. So when you have this in
> your schema:
>
>   <xs:import namespace="http://plc4x.apache.org/plc4x"/>
>
> And this in your XML catalog:
>
>   <uri name="http://plc4x.apache.org/plc4x"
>        uri="org/apache/plc4x/protocols/protocol.dfdl.xsd"/>
>
> Then we assume that it is a file and look for it relative to CWD. So we
> think we've found a uri since it was in the catalog, but it doesn't
> actually exist.
>
> If you instead had done:
>
>   <xs:import namespace="http://plc4x.apache.org/plc4x"
>     schemaLocation="org/apache/plc4x/protocols/protocol.dfdl.xsd" />
>
> Then that would work.
>
> The question is if we should resolve uri's from an XML catalog the same
> as a schemaLocation. I'm not super familar with XML catalogs and if they
> have well-defined semantics on how the uri should be resolved, but if
> not, we should make the two behave the same.
>
> - Steve
>
>
>
> On 5/9/19 11:27 AM, Christofer Dutz wrote:
>> Aaahh ... wait a minute ... I think I had added some dependencies as surefire wasn't automatically picking up the Junit5 tests.
>> If you update now, it should execute the tests.
>>
>> Chris
>>
>> Am 09.05.19, 16:39 schrieb "Steve Lawrence" <sl...@apache.org>:
>>
>>     I can't reproduce any failures, but I'm not even sure I'm running the
>>     testsuite. Here are the steps I ran:
>>
>>       git checkout feature/code-gen
>>       cd protocols/plc4x && mvn install # needed as a dependency for s7
>>       cd ../s7/
>>       rm src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd
>>       mvn test
>>
>>     I don't get any errors, but it looks like no tests are run:
>>
>>     [INFO] -------------------------------------------------------
>>     [INFO]  T E S T S
>>     [INFO] -------------------------------------------------------
>>     [INFO] Running org.apache.plc4x.protocols.s7.ManualTest
>>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
>>     0.003 s - in org.apache.plc4x.protocols.s7.ManualTest
>>     [INFO] Running org.apache.plc4x.protocols.s7.ProtocolTest
>>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
>>     0.001 s - in org.apache.plc4x.protocols.s7.ProtocolTest
>>     [INFO]
>>     [INFO] Results:
>>     [INFO]
>>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
>>
>>     Any idea what am I doing wrong?
>>
>>     - Steve
>>
>>     On 5/9/19 9:59 AM, Christofer Dutz wrote:
>>     > Hi Steve.
>>     >
>>     > Yes it is. Just go to:
>>     > https://github.com/apache/plc4x/tree/feature/code-gen/protocols/s7
>>     >
>>     > the protocols/s7 module in the "code-gen" branch. But you have to rename the
>>     > org/apache/plc4x/protocols/protocol.dfdl.xsd to something else (I currently duplicated the file as a workaround)
>>     >
>>     > As part of the maven build the testsuite is executed and it should demonstrate the problem.
>>     >
>>     > Chris
>>     >
>>     >
>>     > Am 09.05.19, 15:48 schrieb "Steve Lawrence" <sl...@apache.org>:
>>     >
>>     >     Hmmmm, so with the XML catalog it doesn't even need to look in the jar.
>>     >     I don't see an obvious reason why things would fail to open the file://...
>>     >
>>     >     Are your changes available in a github repo/branch somewhere? I could
>>     >     test it out on my machine and see if I can reproduce.
>>     >
>>     >     I think the first step I'd take is to modify DaffodilXMLLoader.scala to
>>     >     not catch the IOException and just let it bubble up so we can see the
>>     >     actual error. Ultimately, this wants to become an SDE instead of an Assert.
>>     >
>>     >     - Steve
>>     >
>>     >     On 5/9/19 9:19 AM, Christofer Dutz wrote:
>>     >     > Some more information:
>>     >     > If I put the external file in the same module it works using this code ..
>>     >     > And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.
>>     >     >
>>     >     > So if I set the logging as you suggested this output is produced:
>>     >     >
>>     >     > 2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
>>     >     > 2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
>>     >     > importElementNS='None'
>>     >     > resolvedNamespaceURI='None'
>>     >     > schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
>>     >     > resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
>>     >     > 2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
>>     >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>>     >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
>>     >     > 2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>>     >     > 2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]
>>     >     >
>>     >     > org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>>     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>>     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >
>>     >     >   at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     >   at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     >   at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
>>     >     >   at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
>>     >     >   at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
>>     >     >   at scala.Option.getOrElse(Option.scala:121)
>>     >     >   at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
>>     >     >   at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
>>     >     >   at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
>>     >     >   at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
>>     >     >   at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
>>     >     >   at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
>>     >     >   at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
>>     >     >   at scala.collection.Iterator.foreach(Iterator.scala:944)
>>     >     >   at scala.collection.Iterator.foreach$(Iterator.scala:944)
>>     >     >   at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
>>     >     >   at scala.collection.IterableLike.foreach(IterableLike.scala:71)
>>     >     >   at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
>>     >     >   at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
>>     >     >   at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
>>     >     >   at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
>>     >     >   at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
>>     >     >   at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
>>     >     >   at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
>>     >     >   at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
>>     >     >   at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
>>     >     >   at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     >   at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
>>     >     >   at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
>>     >     >   at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
>>     >     >   at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
>>     >     >   at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>>     >     >   at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
>>     >     >   at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
>>     >     >   at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
>>     >     >   at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     >   at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>>     >     >   at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
>>     >     >   at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     >   at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
>>     >     >   at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
>>     >     >   at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
>>     >     >   at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
>>     >     >   at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
>>     >     >   at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
>>     >     >   at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
>>     >     >   at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
>>     >     >   at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
>>     >     >   at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
>>     >     >   at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
>>     >     >   at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
>>     >     >   at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
>>     >     >   at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
>>     >     >   at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
>>     >     >   at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
>>     >     >   at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
>>     >     >   at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
>>     >     >   at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>>     >     >   at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
>>     >     >   at java.base/java.util.Optional.ifPresent(Optional.java:183)
>>     >     >   at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
>>     >     >   at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
>>     >     >   at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
>>     >     >   at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
>>     >     >   at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>>     >     >   at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>>     >     >   at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>>     >     >   at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>>     >     >   at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>>     >     >   at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>>     >     >   at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>>     >     >   at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>>     >     >   at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>>     >     >   at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>>     >     >   at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>>     >     >   at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>>     >     >   at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>>     >     >   at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>>     >     >   at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>>     >     >   at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>>     >     >   at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>>     >     >   at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>>     >     >   at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>>     >     >   at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>>     >     >   at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>>     >     >   at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>>     >     >   at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>>     >     >   at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
>>     >     >   at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
>>     >     >   at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
>>     >     >   at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
>>     >     >   at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
>>     >     >   at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
>>     >     >   at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
>>     >     >   at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>>     >     >   at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
>>     >     >
>>     >     > Does that help any further?
>>     >     >
>>     >     > Chris
>>     >     >
>>     >     >
>>     >     >
>>     >     > Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:
>>     >     >
>>     >     >     Yeah, this looks like a bug. Based on where that exception is thrown, it
>>     >     >     does look like it's able to find the file in the jar, but cannot open it
>>     >     >     for some reason. Unfortunately, our code to open it looks like this:
>>     >     >
>>     >     >       try {
>>     >     >         uri.toURL.openStream() // This will work.
>>     >     >       } catch {
>>     >     >         case _: java.io.IOException => Assert.invariantFailed("found
>>     >     >     resource but couldn't open")
>>     >     >       }
>>     >     >
>>     >     >     So the comment "This will work" is clearly wrong, and we end up masking
>>     >     >     the reason why it failed. That definitely needs to be fixed.
>>     >     >
>>     >     >     If you bump the log level to LogLevel.Resolver, e.g.:
>>     >     >
>>     >     >       Daffodil.setLoggingLevel(LogLevel.Resolver);
>>     >     >
>>     >     >     Then it should output to the console a log starting with "Found on
>>     >     >     classpath" followed by the URI that import resolved to. That might help
>>     >     >     us figure out why it can't open a stream to the file if something looks off.
>>     >     >
>>     >     >     - Steve
>>     >     >
>>     >     >
>>     >     >
>>     >     >     On 5/9/19 8:04 AM, Christofer Dutz wrote:
>>     >     >     > Hi Steve,
>>     >     >     >
>>     >     >     > well if that's the case, then I am having trouble doing this.
>>     >     >     >
>>     >     >     > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
>>     >     >     > If I try to use it I get an error message that daffodil has found something but it unable to open it.
>>     >     >     >
>>     >     >     > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
>>     >     >     > org.apache.daffodil.exceptions.Abort:
>>     >     >     > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>>     >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>>     >     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>>     >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>>     >     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >     >     at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
>>     >     >     >
>>     >     >     >
>>     >     >     > Chris
>>     >     >     >
>>     >     >     >
>>     >     >     >
>>     >     >     > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
>>     >     >     >
>>     >     >     >     You should be able to import/include files in jars on the classpath
>>     >     >     >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
>>     >     >     >     So if foo.jar was on your classpath and contained the following
>>     >     >     >
>>     >     >     >       $ jar -jt foo.jar
>>     >     >     >       META-INF/MANIFEST.MF
>>     >     >     >       com/foo/dfdl/types.dfdl.xsd
>>     >     >     >
>>     >     >     >     Your schema could reference the types.dfdl.xsd file with:
>>     >     >     >
>>     >     >     >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
>>     >     >     >
>>     >     >     >     You don't need to specify  which jar to import from or even that the
>>     >     >     >     file comes from a jar. Daffodil will just search for that path in all
>>     >     >     >     jars on the classpath.
>>     >     >     >
>>     >     >     >     - Steve
>>     >     >     >
>>     >     >     >
>>     >     >     >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
>>     >     >     >     > Hi all,
>>     >     >     >     >
>>     >     >     >     > after solving my last problem, I am stuck with another one … as I mentioned in
>>     >     >     >     > the other thread I have one DFDL schema, which defines all the simple types that
>>     >     >     >     > will be used by any PLC4X schema.
>>     >     >     >     >
>>     >     >     >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
>>     >     >     >     >
>>     >     >     >     > Now I added a dependency to that jar an now want to reference this in my
>>     >     >     >     > protocol jar.
>>     >     >     >     >
>>     >     >     >     > No matter what I try, DFDL always complains about not being able to resolve this.
>>     >     >     >     >
>>     >     >     >     > So how can I reference and/or import schemas contained in another jar that’s in
>>     >     >     >     > my classpath?
>>     >     >     >     >
>>     >     >     >     > Chris
>>     >     >     >     >
>>     >     >     >
>>     >     >     >
>>     >     >     >
>>     >     >
>>     >     >
>>     >     >
>>     >
>>     >
>>     >
>>
>>
>>
>


Re: Referencing DFDL schemas in other jars?

Posted by Steve Lawrence <sl...@apache.org>.
After some more research on XML Catalogs, I have a much better idea of
what's going on here.

First, we use Apache XML Commons Catalog Resolver for resolving URIs
from an XML Catalog. So we probably don't want to change the behavior of
that too much. The Catalog Resolver will always return an absolute
path-there's no way around it that I can see. So by the time Daffodil
gets the resolved URI, it's going to be absolute and we cannot use the
same logic as we use for import/include schemaLocation. This was part of
the problem you were seeing. The XML Catalog Resolver converted the
relative paths to absolute, but did so in a way that returned locations
that don't actually exist.

So how does it calculate an absolute path when the XML Catalog contains
relative URLS? It has the concept of "base", which specifies the base
path to use when paths are relative. You can manually change the base in
the XML Catalog file, but this is probably a bad idea since the absolute
base is going to be different on different systems. By default, the base
is the absolute path to the XML Catalog file it resolved a URI from.

When I tested this yesterday, I saw attempts to access the current
working directory because I was actually testing with an XML Catalog
file in my current working directory. So that became the base and
resulted in bad absolute paths. You saw errors for a similar reason of
an incorrect base, but not current working directory issues.

In your case, you had overridden daffodil-built-in-catalog.xml, and you
did so in each of your jars. Daffodil actually only finds the first one
on the classpath, so specifying multiple daffodil-built-in-catalog.xml's
won't actually help, so this is one thing that needs to change.

In this case, it finds the xml catalog in the s7 jar. So the base for
your XML Catalog is something like


jar:file:/path/to/plc4x-protocols-s7-0.4.0-SNAPSHOT.jar!/daffodil-built-in-catalog.xml

Note the syntax for specifying the location of a file inside a jar.

So this means any URI found in this XML catalog will get an absolute
path to that s7 jar. When we try to find the plc4x protocol.dfdl.xsd
file, it won't be able to find it because that's in a different jar.
This is why duplicating the file in the s7 jar solved the problem.

I'd probably recommend just using schemaLocation, but what's the
solution if you still want to use XML Catalogs?

First you need to specify an XML catalog file in each jar, and each
catalog should only contain references to files in that jar. So
plc4x/src/main/resources/xcatalog should have:

  <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="http://plc4x.apache.org/plc4x"
         uri="org/apache/plc4x/protocols/protocol.dfdl.xsd"/>
  </catalog>

And s7/src/main/resources/xcatalog should have:

  <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="http://plc4x.apache.org/s7"
         uri="org/apache/plc4x/protocols/s7/protocol.dfdl.xsd"/>
  </catalog>

With the different XML Catalogs in different jars with the correct
content, you need to tell the XML Catalog Resolver where they are.
There's a handful of ways to do this, but maybe the easiest is to add
the absolute paths to the catalog files in the jars to the
"xml.catalog.files" property. Multiple files can be separated with a
semicolon. For example:

-Dxml.catalog.files=jar:file:/path/to/plc4x.jar!/xcatalog;jar:file:/path/to/s7.jar!/xcatalog

Note that I've changed the names from daffodil-built-in-catalog.xml to
"xcatalog". In general, it's probably a bad idea to override the built
in catalog, since Daffodil uses that for some internal resolutions.

With that, or something very similar, you should be able to use XML
Catalogs provided in jars for resolving import/include.

We do still need to change the Assert so that when a file can't be
opened we don't abort. But I believe the resolution of XML Catalogs is
behaving correctly, and can't be easily changed to use logic similar to
schemaLocation.

- Steve



On 5/9/19 12:15 PM, Steve Lawrence wrote:
> Thanks, was able to reproduce and track down the issue.
> 
> The problem here is the use of the xml catalog. When we resolve to a URI
> from the XML catalog, we treat is as a plain old URI. We don't attempt
> to resolve it to classpath or anything fancy like we do with the
> schemaLocation attribute in an include/import. So when you have this in
> your schema:
> 
>   <xs:import namespace="http://plc4x.apache.org/plc4x"/>
> 
> And this in your XML catalog:
> 
>   <uri name="http://plc4x.apache.org/plc4x"
>        uri="org/apache/plc4x/protocols/protocol.dfdl.xsd"/>
> 
> Then we assume that it is a file and look for it relative to CWD. So we
> think we've found a uri since it was in the catalog, but it doesn't
> actually exist.
> 
> If you instead had done:
> 
>   <xs:import namespace="http://plc4x.apache.org/plc4x"
>     schemaLocation="org/apache/plc4x/protocols/protocol.dfdl.xsd" />
> 
> Then that would work.
> 
> The question is if we should resolve uri's from an XML catalog the same
> as a schemaLocation. I'm not super familar with XML catalogs and if they
> have well-defined semantics on how the uri should be resolved, but if
> not, we should make the two behave the same.
> 
> - Steve
> 
> 
> 
> On 5/9/19 11:27 AM, Christofer Dutz wrote:
>> Aaahh ... wait a minute ... I think I had added some dependencies as surefire wasn't automatically picking up the Junit5 tests.
>> If you update now, it should execute the tests.
>>
>> Chris
>>
>> Am 09.05.19, 16:39 schrieb "Steve Lawrence" <sl...@apache.org>:
>>
>>     I can't reproduce any failures, but I'm not even sure I'm running the
>>     testsuite. Here are the steps I ran:
>>     
>>       git checkout feature/code-gen
>>       cd protocols/plc4x && mvn install # needed as a dependency for s7
>>       cd ../s7/
>>       rm src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd
>>       mvn test
>>     
>>     I don't get any errors, but it looks like no tests are run:
>>     
>>     [INFO] -------------------------------------------------------
>>     [INFO]  T E S T S
>>     [INFO] -------------------------------------------------------
>>     [INFO] Running org.apache.plc4x.protocols.s7.ManualTest
>>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
>>     0.003 s - in org.apache.plc4x.protocols.s7.ManualTest
>>     [INFO] Running org.apache.plc4x.protocols.s7.ProtocolTest
>>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
>>     0.001 s - in org.apache.plc4x.protocols.s7.ProtocolTest
>>     [INFO]
>>     [INFO] Results:
>>     [INFO]
>>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
>>     
>>     Any idea what am I doing wrong?
>>     
>>     - Steve
>>     
>>     On 5/9/19 9:59 AM, Christofer Dutz wrote:
>>     > Hi Steve.
>>     > 
>>     > Yes it is. Just go to:
>>     > https://github.com/apache/plc4x/tree/feature/code-gen/protocols/s7
>>     > 
>>     > the protocols/s7 module in the "code-gen" branch. But you have to rename the 
>>     > org/apache/plc4x/protocols/protocol.dfdl.xsd to something else (I currently duplicated the file as a workaround)
>>     > 
>>     > As part of the maven build the testsuite is executed and it should demonstrate the problem.
>>     > 
>>     > Chris
>>     > 
>>     > 
>>     > Am 09.05.19, 15:48 schrieb "Steve Lawrence" <sl...@apache.org>:
>>     > 
>>     >     Hmmmm, so with the XML catalog it doesn't even need to look in the jar.
>>     >     I don't see an obvious reason why things would fail to open the file://...
>>     >     
>>     >     Are your changes available in a github repo/branch somewhere? I could
>>     >     test it out on my machine and see if I can reproduce.
>>     >     
>>     >     I think the first step I'd take is to modify DaffodilXMLLoader.scala to
>>     >     not catch the IOException and just let it bubble up so we can see the
>>     >     actual error. Ultimately, this wants to become an SDE instead of an Assert.
>>     >     
>>     >     - Steve
>>     >     
>>     >     On 5/9/19 9:19 AM, Christofer Dutz wrote:
>>     >     > Some more information:
>>     >     > If I put the external file in the same module it works using this code ..
>>     >     > And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.
>>     >     > 
>>     >     > So if I set the logging as you suggested this output is produced:
>>     >     > 
>>     >     > 2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
>>     >     > 2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
>>     >     > importElementNS='None'
>>     >     > resolvedNamespaceURI='None'
>>     >     > schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
>>     >     > resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
>>     >     > 2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
>>     >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>>     >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
>>     >     > 2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>>     >     > 2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]
>>     >     > 
>>     >     > org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>>     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>>     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 
>>     >     > 	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     > 	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
>>     >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
>>     >     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
>>     >     > 	at scala.Option.getOrElse(Option.scala:121)
>>     >     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
>>     >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
>>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
>>     >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
>>     >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
>>     >     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
>>     >     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
>>     >     > 	at scala.collection.Iterator.foreach(Iterator.scala:944)
>>     >     > 	at scala.collection.Iterator.foreach$(Iterator.scala:944)
>>     >     > 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
>>     >     > 	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
>>     >     > 	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
>>     >     > 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
>>     >     > 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
>>     >     > 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
>>     >     > 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
>>     >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
>>     >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
>>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
>>     >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
>>     >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>>     >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
>>     >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
>>     >     > 	at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
>>     >     > 	at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
>>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>>     >     > 	at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
>>     >     > 	at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
>>     >     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
>>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>>     >     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
>>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>>     >     > 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
>>     >     > 	at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
>>     >     > 	at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
>>     >     > 	at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
>>     >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
>>     >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
>>     >     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
>>     >     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
>>     >     > 	at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
>>     >     > 	at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
>>     >     > 	at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
>>     >     > 	at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
>>     >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
>>     >     > 	at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
>>     >     > 	at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
>>     >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
>>     >     > 	at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
>>     >     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
>>     >     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
>>     >     > 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
>>     >     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
>>     >     > 	at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
>>     >     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
>>     >     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
>>     >     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>>     >     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>>     >     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>>     >     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>>     >     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>>     >     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>>     >     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>>     >     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>>     >     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>>     >     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>>     >     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>>     >     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>>     >     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>>     >     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>>     >     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
>>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
>>     >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
>>     >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
>>     >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
>>     >     > 	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
>>     >     > 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
>>     >     > 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>>     >     > 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
>>     >     > 
>>     >     > Does that help any further? 
>>     >     > 
>>     >     > Chris
>>     >     > 
>>     >     > 
>>     >     > 
>>     >     > Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:
>>     >     > 
>>     >     >     Yeah, this looks like a bug. Based on where that exception is thrown, it
>>     >     >     does look like it's able to find the file in the jar, but cannot open it
>>     >     >     for some reason. Unfortunately, our code to open it looks like this:
>>     >     >     
>>     >     >       try {
>>     >     >         uri.toURL.openStream() // This will work.
>>     >     >       } catch {
>>     >     >         case _: java.io.IOException => Assert.invariantFailed("found
>>     >     >     resource but couldn't open")
>>     >     >       }
>>     >     >     
>>     >     >     So the comment "This will work" is clearly wrong, and we end up masking
>>     >     >     the reason why it failed. That definitely needs to be fixed.
>>     >     >     
>>     >     >     If you bump the log level to LogLevel.Resolver, e.g.:
>>     >     >     
>>     >     >       Daffodil.setLoggingLevel(LogLevel.Resolver);
>>     >     >     
>>     >     >     Then it should output to the console a log starting with "Found on
>>     >     >     classpath" followed by the URI that import resolved to. That might help
>>     >     >     us figure out why it can't open a stream to the file if something looks off.
>>     >     >     
>>     >     >     - Steve
>>     >     >     
>>     >     >     
>>     >     >     
>>     >     >     On 5/9/19 8:04 AM, Christofer Dutz wrote:
>>     >     >     > Hi Steve,
>>     >     >     > 
>>     >     >     > well if that's the case, then I am having trouble doing this.
>>     >     >     > 
>>     >     >     > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
>>     >     >     > If I try to use it I get an error message that daffodil has found something but it unable to open it.
>>     >     >     > 
>>     >     >     > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
>>     >     >     > org.apache.daffodil.exceptions.Abort: 
>>     >     >     > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>>     >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>>     >     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>>     >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>>     >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>>     >     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>>     >     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>>     >     >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
>>     >     >     > 
>>     >     >     > 
>>     >     >     > Chris
>>     >     >     > 
>>     >     >     > 
>>     >     >     > 
>>     >     >     > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
>>     >     >     > 
>>     >     >     >     You should be able to import/include files in jars on the classpath
>>     >     >     >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
>>     >     >     >     So if foo.jar was on your classpath and contained the following
>>     >     >     >     
>>     >     >     >       $ jar -jt foo.jar
>>     >     >     >       META-INF/MANIFEST.MF
>>     >     >     >       com/foo/dfdl/types.dfdl.xsd
>>     >     >     >     
>>     >     >     >     Your schema could reference the types.dfdl.xsd file with:
>>     >     >     >     
>>     >     >     >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
>>     >     >     >     
>>     >     >     >     You don't need to specify  which jar to import from or even that the
>>     >     >     >     file comes from a jar. Daffodil will just search for that path in all
>>     >     >     >     jars on the classpath.
>>     >     >     >     
>>     >     >     >     - Steve
>>     >     >     >     
>>     >     >     >     
>>     >     >     >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
>>     >     >     >     > Hi all,
>>     >     >     >     > 
>>     >     >     >     > after solving my last problem, I am stuck with another one … as I mentioned in 
>>     >     >     >     > the other thread I have one DFDL schema, which defines all the simple types that 
>>     >     >     >     > will be used by any PLC4X schema.
>>     >     >     >     > 
>>     >     >     >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
>>     >     >     >     > 
>>     >     >     >     > Now I added a dependency to that jar an now want to reference this in my 
>>     >     >     >     > protocol jar.
>>     >     >     >     > 
>>     >     >     >     > No matter what I try, DFDL always complains about not being able to resolve this.
>>     >     >     >     > 
>>     >     >     >     > So how can I reference and/or import schemas contained in another jar that’s in 
>>     >     >     >     > my classpath?
>>     >     >     >     > 
>>     >     >     >     > Chris
>>     >     >     >     > 
>>     >     >     >     
>>     >     >     >     
>>     >     >     > 
>>     >     >     
>>     >     >     
>>     >     > 
>>     >     
>>     >     
>>     > 
>>     
>>     
>>
> 


Re: Referencing DFDL schemas in other jars?

Posted by Steve Lawrence <sl...@apache.org>.
Thanks, was able to reproduce and track down the issue.

The problem here is the use of the xml catalog. When we resolve to a URI
from the XML catalog, we treat is as a plain old URI. We don't attempt
to resolve it to classpath or anything fancy like we do with the
schemaLocation attribute in an include/import. So when you have this in
your schema:

  <xs:import namespace="http://plc4x.apache.org/plc4x"/>

And this in your XML catalog:

  <uri name="http://plc4x.apache.org/plc4x"
       uri="org/apache/plc4x/protocols/protocol.dfdl.xsd"/>

Then we assume that it is a file and look for it relative to CWD. So we
think we've found a uri since it was in the catalog, but it doesn't
actually exist.

If you instead had done:

  <xs:import namespace="http://plc4x.apache.org/plc4x"
    schemaLocation="org/apache/plc4x/protocols/protocol.dfdl.xsd" />

Then that would work.

The question is if we should resolve uri's from an XML catalog the same
as a schemaLocation. I'm not super familar with XML catalogs and if they
have well-defined semantics on how the uri should be resolved, but if
not, we should make the two behave the same.

- Steve



On 5/9/19 11:27 AM, Christofer Dutz wrote:
> Aaahh ... wait a minute ... I think I had added some dependencies as surefire wasn't automatically picking up the Junit5 tests.
> If you update now, it should execute the tests.
> 
> Chris
> 
> Am 09.05.19, 16:39 schrieb "Steve Lawrence" <sl...@apache.org>:
> 
>     I can't reproduce any failures, but I'm not even sure I'm running the
>     testsuite. Here are the steps I ran:
>     
>       git checkout feature/code-gen
>       cd protocols/plc4x && mvn install # needed as a dependency for s7
>       cd ../s7/
>       rm src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd
>       mvn test
>     
>     I don't get any errors, but it looks like no tests are run:
>     
>     [INFO] -------------------------------------------------------
>     [INFO]  T E S T S
>     [INFO] -------------------------------------------------------
>     [INFO] Running org.apache.plc4x.protocols.s7.ManualTest
>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
>     0.003 s - in org.apache.plc4x.protocols.s7.ManualTest
>     [INFO] Running org.apache.plc4x.protocols.s7.ProtocolTest
>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
>     0.001 s - in org.apache.plc4x.protocols.s7.ProtocolTest
>     [INFO]
>     [INFO] Results:
>     [INFO]
>     [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
>     
>     Any idea what am I doing wrong?
>     
>     - Steve
>     
>     On 5/9/19 9:59 AM, Christofer Dutz wrote:
>     > Hi Steve.
>     > 
>     > Yes it is. Just go to:
>     > https://github.com/apache/plc4x/tree/feature/code-gen/protocols/s7
>     > 
>     > the protocols/s7 module in the "code-gen" branch. But you have to rename the 
>     > org/apache/plc4x/protocols/protocol.dfdl.xsd to something else (I currently duplicated the file as a workaround)
>     > 
>     > As part of the maven build the testsuite is executed and it should demonstrate the problem.
>     > 
>     > Chris
>     > 
>     > 
>     > Am 09.05.19, 15:48 schrieb "Steve Lawrence" <sl...@apache.org>:
>     > 
>     >     Hmmmm, so with the XML catalog it doesn't even need to look in the jar.
>     >     I don't see an obvious reason why things would fail to open the file://...
>     >     
>     >     Are your changes available in a github repo/branch somewhere? I could
>     >     test it out on my machine and see if I can reproduce.
>     >     
>     >     I think the first step I'd take is to modify DaffodilXMLLoader.scala to
>     >     not catch the IOException and just let it bubble up so we can see the
>     >     actual error. Ultimately, this wants to become an SDE instead of an Assert.
>     >     
>     >     - Steve
>     >     
>     >     On 5/9/19 9:19 AM, Christofer Dutz wrote:
>     >     > Some more information:
>     >     > If I put the external file in the same module it works using this code ..
>     >     > And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.
>     >     > 
>     >     > So if I set the logging as you suggested this output is produced:
>     >     > 
>     >     > 2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
>     >     > 2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
>     >     > importElementNS='None'
>     >     > resolvedNamespaceURI='None'
>     >     > schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
>     >     > resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
>     >     > 2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
>     >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>     >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
>     >     > 2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>     >     > 2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]
>     >     > 
>     >     > org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 
>     >     > 	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     >     > 	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
>     >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
>     >     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
>     >     > 	at scala.Option.getOrElse(Option.scala:121)
>     >     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
>     >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
>     >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
>     >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
>     >     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
>     >     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
>     >     > 	at scala.collection.Iterator.foreach(Iterator.scala:944)
>     >     > 	at scala.collection.Iterator.foreach$(Iterator.scala:944)
>     >     > 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
>     >     > 	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
>     >     > 	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
>     >     > 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
>     >     > 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
>     >     > 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
>     >     > 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
>     >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
>     >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
>     >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
>     >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
>     >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
>     >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
>     >     > 	at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
>     >     > 	at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>     >     > 	at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
>     >     > 	at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
>     >     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     >     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>     >     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
>     >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     >     > 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
>     >     > 	at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
>     >     > 	at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
>     >     > 	at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
>     >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
>     >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
>     >     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
>     >     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
>     >     > 	at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
>     >     > 	at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
>     >     > 	at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
>     >     > 	at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
>     >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
>     >     > 	at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
>     >     > 	at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
>     >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
>     >     > 	at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
>     >     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
>     >     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
>     >     > 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
>     >     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
>     >     > 	at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
>     >     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
>     >     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
>     >     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>     >     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>     >     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>     >     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>     >     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>     >     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>     >     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>     >     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>     >     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>     >     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>     >     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>     >     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>     >     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>     >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>     >     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>     >     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>     >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
>     >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
>     >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
>     >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
>     >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
>     >     > 	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
>     >     > 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
>     >     > 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>     >     > 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
>     >     > 
>     >     > Does that help any further? 
>     >     > 
>     >     > Chris
>     >     > 
>     >     > 
>     >     > 
>     >     > Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:
>     >     > 
>     >     >     Yeah, this looks like a bug. Based on where that exception is thrown, it
>     >     >     does look like it's able to find the file in the jar, but cannot open it
>     >     >     for some reason. Unfortunately, our code to open it looks like this:
>     >     >     
>     >     >       try {
>     >     >         uri.toURL.openStream() // This will work.
>     >     >       } catch {
>     >     >         case _: java.io.IOException => Assert.invariantFailed("found
>     >     >     resource but couldn't open")
>     >     >       }
>     >     >     
>     >     >     So the comment "This will work" is clearly wrong, and we end up masking
>     >     >     the reason why it failed. That definitely needs to be fixed.
>     >     >     
>     >     >     If you bump the log level to LogLevel.Resolver, e.g.:
>     >     >     
>     >     >       Daffodil.setLoggingLevel(LogLevel.Resolver);
>     >     >     
>     >     >     Then it should output to the console a log starting with "Found on
>     >     >     classpath" followed by the URI that import resolved to. That might help
>     >     >     us figure out why it can't open a stream to the file if something looks off.
>     >     >     
>     >     >     - Steve
>     >     >     
>     >     >     
>     >     >     
>     >     >     On 5/9/19 8:04 AM, Christofer Dutz wrote:
>     >     >     > Hi Steve,
>     >     >     > 
>     >     >     > well if that's the case, then I am having trouble doing this.
>     >     >     > 
>     >     >     > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
>     >     >     > If I try to use it I get an error message that daffodil has found something but it unable to open it.
>     >     >     > 
>     >     >     > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
>     >     >     > org.apache.daffodil.exceptions.Abort: 
>     >     >     > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>     >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     >     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>     >     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>     >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     >     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>     >     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
>     >     >     > 
>     >     >     > 
>     >     >     > Chris
>     >     >     > 
>     >     >     > 
>     >     >     > 
>     >     >     > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
>     >     >     > 
>     >     >     >     You should be able to import/include files in jars on the classpath
>     >     >     >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
>     >     >     >     So if foo.jar was on your classpath and contained the following
>     >     >     >     
>     >     >     >       $ jar -jt foo.jar
>     >     >     >       META-INF/MANIFEST.MF
>     >     >     >       com/foo/dfdl/types.dfdl.xsd
>     >     >     >     
>     >     >     >     Your schema could reference the types.dfdl.xsd file with:
>     >     >     >     
>     >     >     >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
>     >     >     >     
>     >     >     >     You don't need to specify  which jar to import from or even that the
>     >     >     >     file comes from a jar. Daffodil will just search for that path in all
>     >     >     >     jars on the classpath.
>     >     >     >     
>     >     >     >     - Steve
>     >     >     >     
>     >     >     >     
>     >     >     >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
>     >     >     >     > Hi all,
>     >     >     >     > 
>     >     >     >     > after solving my last problem, I am stuck with another one … as I mentioned in 
>     >     >     >     > the other thread I have one DFDL schema, which defines all the simple types that 
>     >     >     >     > will be used by any PLC4X schema.
>     >     >     >     > 
>     >     >     >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
>     >     >     >     > 
>     >     >     >     > Now I added a dependency to that jar an now want to reference this in my 
>     >     >     >     > protocol jar.
>     >     >     >     > 
>     >     >     >     > No matter what I try, DFDL always complains about not being able to resolve this.
>     >     >     >     > 
>     >     >     >     > So how can I reference and/or import schemas contained in another jar that’s in 
>     >     >     >     > my classpath?
>     >     >     >     > 
>     >     >     >     > Chris
>     >     >     >     > 
>     >     >     >     
>     >     >     >     
>     >     >     > 
>     >     >     
>     >     >     
>     >     > 
>     >     
>     >     
>     > 
>     
>     
> 


Re: Referencing DFDL schemas in other jars?

Posted by Christofer Dutz <ch...@c-ware.de>.
Aaahh ... wait a minute ... I think I had added some dependencies as surefire wasn't automatically picking up the Junit5 tests.
If you update now, it should execute the tests.

Chris

Am 09.05.19, 16:39 schrieb "Steve Lawrence" <sl...@apache.org>:

    I can't reproduce any failures, but I'm not even sure I'm running the
    testsuite. Here are the steps I ran:
    
      git checkout feature/code-gen
      cd protocols/plc4x && mvn install # needed as a dependency for s7
      cd ../s7/
      rm src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd
      mvn test
    
    I don't get any errors, but it looks like no tests are run:
    
    [INFO] -------------------------------------------------------
    [INFO]  T E S T S
    [INFO] -------------------------------------------------------
    [INFO] Running org.apache.plc4x.protocols.s7.ManualTest
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
    0.003 s - in org.apache.plc4x.protocols.s7.ManualTest
    [INFO] Running org.apache.plc4x.protocols.s7.ProtocolTest
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
    0.001 s - in org.apache.plc4x.protocols.s7.ProtocolTest
    [INFO]
    [INFO] Results:
    [INFO]
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
    
    Any idea what am I doing wrong?
    
    - Steve
    
    On 5/9/19 9:59 AM, Christofer Dutz wrote:
    > Hi Steve.
    > 
    > Yes it is. Just go to:
    > https://github.com/apache/plc4x/tree/feature/code-gen/protocols/s7
    > 
    > the protocols/s7 module in the "code-gen" branch. But you have to rename the 
    > org/apache/plc4x/protocols/protocol.dfdl.xsd to something else (I currently duplicated the file as a workaround)
    > 
    > As part of the maven build the testsuite is executed and it should demonstrate the problem.
    > 
    > Chris
    > 
    > 
    > Am 09.05.19, 15:48 schrieb "Steve Lawrence" <sl...@apache.org>:
    > 
    >     Hmmmm, so with the XML catalog it doesn't even need to look in the jar.
    >     I don't see an obvious reason why things would fail to open the file://...
    >     
    >     Are your changes available in a github repo/branch somewhere? I could
    >     test it out on my machine and see if I can reproduce.
    >     
    >     I think the first step I'd take is to modify DaffodilXMLLoader.scala to
    >     not catch the IOException and just let it bubble up so we can see the
    >     actual error. Ultimately, this wants to become an SDE instead of an Assert.
    >     
    >     - Steve
    >     
    >     On 5/9/19 9:19 AM, Christofer Dutz wrote:
    >     > Some more information:
    >     > If I put the external file in the same module it works using this code ..
    >     > And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.
    >     > 
    >     > So if I set the logging as you suggested this output is produced:
    >     > 
    >     > 2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
    >     > 2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
    >     > importElementNS='None'
    >     > resolvedNamespaceURI='None'
    >     > schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
    >     > resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
    >     > 2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
    >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
    >     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
    >     > 2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
    >     > 2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]
    >     > 
    >     > org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
    >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
    >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
    >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
    >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 
    >     > 	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    >     > 	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
    >     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
    >     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
    >     > 	at scala.Option.getOrElse(Option.scala:121)
    >     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
    >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
    >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
    >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
    >     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
    >     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
    >     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
    >     > 	at scala.collection.Iterator.foreach(Iterator.scala:944)
    >     > 	at scala.collection.Iterator.foreach$(Iterator.scala:944)
    >     > 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
    >     > 	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
    >     > 	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
    >     > 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    >     > 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
    >     > 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
    >     > 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
    >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
    >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
    >     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
    >     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
    >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    >     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
    >     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
    >     > 	at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
    >     > 	at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
    >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    >     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
    >     > 	at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
    >     > 	at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
    >     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
    >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    >     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
    >     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
    >     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    >     > 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
    >     > 	at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
    >     > 	at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
    >     > 	at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
    >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
    >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
    >     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
    >     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
    >     > 	at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
    >     > 	at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
    >     > 	at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
    >     > 	at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
    >     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
    >     > 	at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
    >     > 	at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
    >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
    >     > 	at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
    >     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
    >     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
    >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
    >     > 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
    >     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
    >     > 	at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
    >     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
    >     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
    >     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
    >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
    >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    >     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    >     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    >     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    >     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    >     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    >     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    >     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
    >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
    >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    >     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    >     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    >     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    >     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    >     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    >     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    >     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    >     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
    >     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
    >     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
    >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
    >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
    >     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
    >     > 	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
    >     > 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    >     > 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    >     > 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    >     > 
    >     > Does that help any further? 
    >     > 
    >     > Chris
    >     > 
    >     > 
    >     > 
    >     > Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:
    >     > 
    >     >     Yeah, this looks like a bug. Based on where that exception is thrown, it
    >     >     does look like it's able to find the file in the jar, but cannot open it
    >     >     for some reason. Unfortunately, our code to open it looks like this:
    >     >     
    >     >       try {
    >     >         uri.toURL.openStream() // This will work.
    >     >       } catch {
    >     >         case _: java.io.IOException => Assert.invariantFailed("found
    >     >     resource but couldn't open")
    >     >       }
    >     >     
    >     >     So the comment "This will work" is clearly wrong, and we end up masking
    >     >     the reason why it failed. That definitely needs to be fixed.
    >     >     
    >     >     If you bump the log level to LogLevel.Resolver, e.g.:
    >     >     
    >     >       Daffodil.setLoggingLevel(LogLevel.Resolver);
    >     >     
    >     >     Then it should output to the console a log starting with "Found on
    >     >     classpath" followed by the URI that import resolved to. That might help
    >     >     us figure out why it can't open a stream to the file if something looks off.
    >     >     
    >     >     - Steve
    >     >     
    >     >     
    >     >     
    >     >     On 5/9/19 8:04 AM, Christofer Dutz wrote:
    >     >     > Hi Steve,
    >     >     > 
    >     >     > well if that's the case, then I am having trouble doing this.
    >     >     > 
    >     >     > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
    >     >     > If I try to use it I get an error message that daffodil has found something but it unable to open it.
    >     >     > 
    >     >     > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
    >     >     > org.apache.daffodil.exceptions.Abort: 
    >     >     > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
    >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    >     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
    >     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
    >     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    >     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    >     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
    >     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
    >     >     > 
    >     >     > 
    >     >     > Chris
    >     >     > 
    >     >     > 
    >     >     > 
    >     >     > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
    >     >     > 
    >     >     >     You should be able to import/include files in jars on the classpath
    >     >     >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
    >     >     >     So if foo.jar was on your classpath and contained the following
    >     >     >     
    >     >     >       $ jar -jt foo.jar
    >     >     >       META-INF/MANIFEST.MF
    >     >     >       com/foo/dfdl/types.dfdl.xsd
    >     >     >     
    >     >     >     Your schema could reference the types.dfdl.xsd file with:
    >     >     >     
    >     >     >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
    >     >     >     
    >     >     >     You don't need to specify  which jar to import from or even that the
    >     >     >     file comes from a jar. Daffodil will just search for that path in all
    >     >     >     jars on the classpath.
    >     >     >     
    >     >     >     - Steve
    >     >     >     
    >     >     >     
    >     >     >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
    >     >     >     > Hi all,
    >     >     >     > 
    >     >     >     > after solving my last problem, I am stuck with another one … as I mentioned in 
    >     >     >     > the other thread I have one DFDL schema, which defines all the simple types that 
    >     >     >     > will be used by any PLC4X schema.
    >     >     >     > 
    >     >     >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
    >     >     >     > 
    >     >     >     > Now I added a dependency to that jar an now want to reference this in my 
    >     >     >     > protocol jar.
    >     >     >     > 
    >     >     >     > No matter what I try, DFDL always complains about not being able to resolve this.
    >     >     >     > 
    >     >     >     > So how can I reference and/or import schemas contained in another jar that’s in 
    >     >     >     > my classpath?
    >     >     >     > 
    >     >     >     > Chris
    >     >     >     > 
    >     >     >     
    >     >     >     
    >     >     > 
    >     >     
    >     >     
    >     > 
    >     
    >     
    > 
    
    


Re: Referencing DFDL schemas in other jars?

Posted by Steve Lawrence <sl...@apache.org>.
I can't reproduce any failures, but I'm not even sure I'm running the
testsuite. Here are the steps I ran:

  git checkout feature/code-gen
  cd protocols/plc4x && mvn install # needed as a dependency for s7
  cd ../s7/
  rm src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd
  mvn test

I don't get any errors, but it looks like no tests are run:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.plc4x.protocols.s7.ManualTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
0.003 s - in org.apache.plc4x.protocols.s7.ManualTest
[INFO] Running org.apache.plc4x.protocols.s7.ProtocolTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
0.001 s - in org.apache.plc4x.protocols.s7.ProtocolTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Any idea what am I doing wrong?

- Steve

On 5/9/19 9:59 AM, Christofer Dutz wrote:
> Hi Steve.
> 
> Yes it is. Just go to:
> https://github.com/apache/plc4x/tree/feature/code-gen/protocols/s7
> 
> the protocols/s7 module in the "code-gen" branch. But you have to rename the 
> org/apache/plc4x/protocols/protocol.dfdl.xsd to something else (I currently duplicated the file as a workaround)
> 
> As part of the maven build the testsuite is executed and it should demonstrate the problem.
> 
> Chris
> 
> 
> Am 09.05.19, 15:48 schrieb "Steve Lawrence" <sl...@apache.org>:
> 
>     Hmmmm, so with the XML catalog it doesn't even need to look in the jar.
>     I don't see an obvious reason why things would fail to open the file://...
>     
>     Are your changes available in a github repo/branch somewhere? I could
>     test it out on my machine and see if I can reproduce.
>     
>     I think the first step I'd take is to modify DaffodilXMLLoader.scala to
>     not catch the IOException and just let it bubble up so we can see the
>     actual error. Ultimately, this wants to become an SDE instead of an Assert.
>     
>     - Steve
>     
>     On 5/9/19 9:19 AM, Christofer Dutz wrote:
>     > Some more information:
>     > If I put the external file in the same module it works using this code ..
>     > And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.
>     > 
>     > So if I set the logging as you suggested this output is produced:
>     > 
>     > 2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
>     > 2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
>     > importElementNS='None'
>     > resolvedNamespaceURI='None'
>     > schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
>     > resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
>     > 2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
>     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>     > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
>     > 2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
>     > 2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]
>     > 
>     > org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 
>     > 	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     > 	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
>     > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
>     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
>     > 	at scala.Option.getOrElse(Option.scala:121)
>     > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
>     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
>     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
>     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
>     > 	at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
>     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
>     > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
>     > 	at scala.collection.Iterator.foreach(Iterator.scala:944)
>     > 	at scala.collection.Iterator.foreach$(Iterator.scala:944)
>     > 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
>     > 	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
>     > 	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
>     > 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
>     > 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
>     > 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
>     > 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
>     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
>     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
>     > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
>     > 	at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
>     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
>     > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
>     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
>     > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
>     > 	at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
>     > 	at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
>     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>     > 	at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
>     > 	at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
>     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
>     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
>     > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
>     > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
>     > 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
>     > 	at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
>     > 	at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
>     > 	at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
>     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
>     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
>     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
>     > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
>     > 	at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
>     > 	at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
>     > 	at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
>     > 	at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
>     > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
>     > 	at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
>     > 	at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
>     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
>     > 	at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
>     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
>     > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
>     > 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
>     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
>     > 	at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
>     > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
>     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
>     > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
>     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
>     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>     > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
>     > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>     > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>     > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>     > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>     > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>     > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>     > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>     > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
>     > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
>     > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
>     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
>     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
>     > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
>     > 	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
>     > 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
>     > 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>     > 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
>     > 
>     > Does that help any further? 
>     > 
>     > Chris
>     > 
>     > 
>     > 
>     > Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:
>     > 
>     >     Yeah, this looks like a bug. Based on where that exception is thrown, it
>     >     does look like it's able to find the file in the jar, but cannot open it
>     >     for some reason. Unfortunately, our code to open it looks like this:
>     >     
>     >       try {
>     >         uri.toURL.openStream() // This will work.
>     >       } catch {
>     >         case _: java.io.IOException => Assert.invariantFailed("found
>     >     resource but couldn't open")
>     >       }
>     >     
>     >     So the comment "This will work" is clearly wrong, and we end up masking
>     >     the reason why it failed. That definitely needs to be fixed.
>     >     
>     >     If you bump the log level to LogLevel.Resolver, e.g.:
>     >     
>     >       Daffodil.setLoggingLevel(LogLevel.Resolver);
>     >     
>     >     Then it should output to the console a log starting with "Found on
>     >     classpath" followed by the URI that import resolved to. That might help
>     >     us figure out why it can't open a stream to the file if something looks off.
>     >     
>     >     - Steve
>     >     
>     >     
>     >     
>     >     On 5/9/19 8:04 AM, Christofer Dutz wrote:
>     >     > Hi Steve,
>     >     > 
>     >     > well if that's the case, then I am having trouble doing this.
>     >     > 
>     >     > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
>     >     > If I try to use it I get an error message that daffodil has found something but it unable to open it.
>     >     > 
>     >     > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
>     >     > org.apache.daffodil.exceptions.Abort: 
>     >     > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>     >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>     >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>     >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
>     >     > 
>     >     > 
>     >     > Chris
>     >     > 
>     >     > 
>     >     > 
>     >     > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
>     >     > 
>     >     >     You should be able to import/include files in jars on the classpath
>     >     >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
>     >     >     So if foo.jar was on your classpath and contained the following
>     >     >     
>     >     >       $ jar -jt foo.jar
>     >     >       META-INF/MANIFEST.MF
>     >     >       com/foo/dfdl/types.dfdl.xsd
>     >     >     
>     >     >     Your schema could reference the types.dfdl.xsd file with:
>     >     >     
>     >     >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
>     >     >     
>     >     >     You don't need to specify  which jar to import from or even that the
>     >     >     file comes from a jar. Daffodil will just search for that path in all
>     >     >     jars on the classpath.
>     >     >     
>     >     >     - Steve
>     >     >     
>     >     >     
>     >     >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
>     >     >     > Hi all,
>     >     >     > 
>     >     >     > after solving my last problem, I am stuck with another one … as I mentioned in 
>     >     >     > the other thread I have one DFDL schema, which defines all the simple types that 
>     >     >     > will be used by any PLC4X schema.
>     >     >     > 
>     >     >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
>     >     >     > 
>     >     >     > Now I added a dependency to that jar an now want to reference this in my 
>     >     >     > protocol jar.
>     >     >     > 
>     >     >     > No matter what I try, DFDL always complains about not being able to resolve this.
>     >     >     > 
>     >     >     > So how can I reference and/or import schemas contained in another jar that’s in 
>     >     >     > my classpath?
>     >     >     > 
>     >     >     > Chris
>     >     >     > 
>     >     >     
>     >     >     
>     >     > 
>     >     
>     >     
>     > 
>     
>     
> 


Re: Referencing DFDL schemas in other jars?

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Steve.

Yes it is. Just go to:
https://github.com/apache/plc4x/tree/feature/code-gen/protocols/s7

the protocols/s7 module in the "code-gen" branch. But you have to rename the 
org/apache/plc4x/protocols/protocol.dfdl.xsd to something else (I currently duplicated the file as a workaround)

As part of the maven build the testsuite is executed and it should demonstrate the problem.

Chris


Am 09.05.19, 15:48 schrieb "Steve Lawrence" <sl...@apache.org>:

    Hmmmm, so with the XML catalog it doesn't even need to look in the jar.
    I don't see an obvious reason why things would fail to open the file://...
    
    Are your changes available in a github repo/branch somewhere? I could
    test it out on my machine and see if I can reproduce.
    
    I think the first step I'd take is to modify DaffodilXMLLoader.scala to
    not catch the IOException and just let it bubble up so we can see the
    actual error. Ultimately, this wants to become an SDE instead of an Assert.
    
    - Steve
    
    On 5/9/19 9:19 AM, Christofer Dutz wrote:
    > Some more information:
    > If I put the external file in the same module it works using this code ..
    > And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.
    > 
    > So if I set the logging as you suggested this output is produced:
    > 
    > 2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
    > 2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
    > importElementNS='None'
    > resolvedNamespaceURI='None'
    > schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
    > resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
    > 2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
    > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
    > 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
    > 2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
    > 2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]
    > 
    > org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
    > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
    > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
    > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
    > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 
    > 	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    > 	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    > 	at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
    > 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
    > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
    > 	at scala.Option.getOrElse(Option.scala:121)
    > 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
    > 	at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
    > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
    > 	at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
    > 	at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
    > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
    > 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
    > 	at scala.collection.Iterator.foreach(Iterator.scala:944)
    > 	at scala.collection.Iterator.foreach$(Iterator.scala:944)
    > 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
    > 	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
    > 	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
    > 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    > 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
    > 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
    > 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
    > 	at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
    > 	at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
    > 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
    > 	at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
    > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
    > 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
    > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
    > 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
    > 	at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
    > 	at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
    > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
    > 	at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
    > 	at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
    > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
    > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    > 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
    > 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
    > 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
    > 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
    > 	at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
    > 	at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
    > 	at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
    > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
    > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
    > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
    > 	at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
    > 	at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
    > 	at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
    > 	at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
    > 	at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
    > 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
    > 	at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
    > 	at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
    > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
    > 	at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
    > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
    > 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
    > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
    > 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
    > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
    > 	at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
    > 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
    > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
    > 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
    > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
    > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
    > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
    > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    > 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    > 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    > 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    > 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    > 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    > 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    > 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    > 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    > 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
    > 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
    > 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
    > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
    > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
    > 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
    > 	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
    > 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    > 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    > 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    > 
    > Does that help any further? 
    > 
    > Chris
    > 
    > 
    > 
    > Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:
    > 
    >     Yeah, this looks like a bug. Based on where that exception is thrown, it
    >     does look like it's able to find the file in the jar, but cannot open it
    >     for some reason. Unfortunately, our code to open it looks like this:
    >     
    >       try {
    >         uri.toURL.openStream() // This will work.
    >       } catch {
    >         case _: java.io.IOException => Assert.invariantFailed("found
    >     resource but couldn't open")
    >       }
    >     
    >     So the comment "This will work" is clearly wrong, and we end up masking
    >     the reason why it failed. That definitely needs to be fixed.
    >     
    >     If you bump the log level to LogLevel.Resolver, e.g.:
    >     
    >       Daffodil.setLoggingLevel(LogLevel.Resolver);
    >     
    >     Then it should output to the console a log starting with "Found on
    >     classpath" followed by the URI that import resolved to. That might help
    >     us figure out why it can't open a stream to the file if something looks off.
    >     
    >     - Steve
    >     
    >     
    >     
    >     On 5/9/19 8:04 AM, Christofer Dutz wrote:
    >     > Hi Steve,
    >     > 
    >     > well if that's the case, then I am having trouble doing this.
    >     > 
    >     > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
    >     > If I try to use it I get an error message that daffodil has found something but it unable to open it.
    >     > 
    >     > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
    >     > org.apache.daffodil.exceptions.Abort: 
    >     > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
    >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    >     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
    >     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
    >     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    >     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    >     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
    >     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    >     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
    >     > 
    >     > 
    >     > Chris
    >     > 
    >     > 
    >     > 
    >     > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
    >     > 
    >     >     You should be able to import/include files in jars on the classpath
    >     >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
    >     >     So if foo.jar was on your classpath and contained the following
    >     >     
    >     >       $ jar -jt foo.jar
    >     >       META-INF/MANIFEST.MF
    >     >       com/foo/dfdl/types.dfdl.xsd
    >     >     
    >     >     Your schema could reference the types.dfdl.xsd file with:
    >     >     
    >     >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
    >     >     
    >     >     You don't need to specify  which jar to import from or even that the
    >     >     file comes from a jar. Daffodil will just search for that path in all
    >     >     jars on the classpath.
    >     >     
    >     >     - Steve
    >     >     
    >     >     
    >     >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
    >     >     > Hi all,
    >     >     > 
    >     >     > after solving my last problem, I am stuck with another one … as I mentioned in 
    >     >     > the other thread I have one DFDL schema, which defines all the simple types that 
    >     >     > will be used by any PLC4X schema.
    >     >     > 
    >     >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
    >     >     > 
    >     >     > Now I added a dependency to that jar an now want to reference this in my 
    >     >     > protocol jar.
    >     >     > 
    >     >     > No matter what I try, DFDL always complains about not being able to resolve this.
    >     >     > 
    >     >     > So how can I reference and/or import schemas contained in another jar that’s in 
    >     >     > my classpath?
    >     >     > 
    >     >     > Chris
    >     >     > 
    >     >     
    >     >     
    >     > 
    >     
    >     
    > 
    
    


Re: Referencing DFDL schemas in other jars?

Posted by Steve Lawrence <sl...@apache.org>.
Hmmmm, so with the XML catalog it doesn't even need to look in the jar.
I don't see an obvious reason why things would fail to open the file://...

Are your changes available in a github repo/branch somewhere? I could
test it out on my machine and see if I can reproduce.

I think the first step I'd take is to modify DaffodilXMLLoader.scala to
not catch the IOException and just let it bubble up so we can see the
actual error. Ultimately, this wants to become an SDE instead of an Assert.

- Steve

On 5/9/19 9:19 AM, Christofer Dutz wrote:
> Some more information:
> If I put the external file in the same module it works using this code ..
> And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.
> 
> So if I set the logging as you suggested this output is produced:
> 
> 2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
> 2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
> importElementNS='None'
> resolvedNamespaceURI='None'
> schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
> resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
> 2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
> 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
> 2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
> 2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
> 2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]
> 
> org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
> org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
> org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
> org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
> org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
> org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
> org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 
> 	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> 	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
> 	at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
> 	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
> 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
> 	at scala.Option.getOrElse(Option.scala:121)
> 	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
> 	at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
> 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
> 	at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
> 	at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
> 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
> 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
> 	at scala.collection.Iterator.foreach(Iterator.scala:944)
> 	at scala.collection.Iterator.foreach$(Iterator.scala:944)
> 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
> 	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
> 	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
> 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
> 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
> 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
> 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
> 	at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
> 	at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
> 	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
> 	at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
> 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
> 	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
> 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
> 	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
> 	at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
> 	at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
> 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
> 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
> 	at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
> 	at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
> 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
> 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
> 	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
> 	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
> 	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
> 	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
> 	at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
> 	at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
> 	at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
> 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
> 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
> 	at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
> 	at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
> 	at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
> 	at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
> 	at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
> 	at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
> 	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
> 	at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
> 	at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
> 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
> 	at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
> 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
> 	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
> 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
> 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
> 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
> 	at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
> 	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
> 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
> 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
> 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
> 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
> 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
> 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
> 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
> 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
> 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
> 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
> 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
> 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
> 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
> 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
> 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
> 	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
> 	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
> 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
> 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
> 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
> 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
> 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
> 	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
> 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
> 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
> 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
> 	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
> 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> 
> Does that help any further? 
> 
> Chris
> 
> 
> 
> Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:
> 
>     Yeah, this looks like a bug. Based on where that exception is thrown, it
>     does look like it's able to find the file in the jar, but cannot open it
>     for some reason. Unfortunately, our code to open it looks like this:
>     
>       try {
>         uri.toURL.openStream() // This will work.
>       } catch {
>         case _: java.io.IOException => Assert.invariantFailed("found
>     resource but couldn't open")
>       }
>     
>     So the comment "This will work" is clearly wrong, and we end up masking
>     the reason why it failed. That definitely needs to be fixed.
>     
>     If you bump the log level to LogLevel.Resolver, e.g.:
>     
>       Daffodil.setLoggingLevel(LogLevel.Resolver);
>     
>     Then it should output to the console a log starting with "Found on
>     classpath" followed by the URI that import resolved to. That might help
>     us figure out why it can't open a stream to the file if something looks off.
>     
>     - Steve
>     
>     
>     
>     On 5/9/19 8:04 AM, Christofer Dutz wrote:
>     > Hi Steve,
>     > 
>     > well if that's the case, then I am having trouble doing this.
>     > 
>     > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
>     > If I try to use it I get an error message that daffodil has found something but it unable to open it.
>     > 
>     > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
>     > org.apache.daffodil.exceptions.Abort: 
>     > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
>     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
>     > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
>     > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>     > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
>     > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
>     > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
>     > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
>     > 
>     > 
>     > Chris
>     > 
>     > 
>     > 
>     > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
>     > 
>     >     You should be able to import/include files in jars on the classpath
>     >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
>     >     So if foo.jar was on your classpath and contained the following
>     >     
>     >       $ jar -jt foo.jar
>     >       META-INF/MANIFEST.MF
>     >       com/foo/dfdl/types.dfdl.xsd
>     >     
>     >     Your schema could reference the types.dfdl.xsd file with:
>     >     
>     >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
>     >     
>     >     You don't need to specify  which jar to import from or even that the
>     >     file comes from a jar. Daffodil will just search for that path in all
>     >     jars on the classpath.
>     >     
>     >     - Steve
>     >     
>     >     
>     >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
>     >     > Hi all,
>     >     > 
>     >     > after solving my last problem, I am stuck with another one … as I mentioned in 
>     >     > the other thread I have one DFDL schema, which defines all the simple types that 
>     >     > will be used by any PLC4X schema.
>     >     > 
>     >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
>     >     > 
>     >     > Now I added a dependency to that jar an now want to reference this in my 
>     >     > protocol jar.
>     >     > 
>     >     > No matter what I try, DFDL always complains about not being able to resolve this.
>     >     > 
>     >     > So how can I reference and/or import schemas contained in another jar that’s in 
>     >     > my classpath?
>     >     > 
>     >     > Chris
>     >     > 
>     >     
>     >     
>     > 
>     
>     
> 


Re: Referencing DFDL schemas in other jars?

Posted by Christofer Dutz <ch...@c-ware.de>.
Some more information:
If I put the external file in the same module it works using this code ..
And I am using the daffodil-built-in-catalog.xml to provide the location of the schema.

So if I set the logging as you suggested this output is produced:

2019-05-09 15:14:51:480  org.apache.daffodil.dsom.Import Resolver[Computing resolvedLocation]
2019-05-09 15:14:51:483  org.apache.daffodil.dsom.Import Resolver[
importElementNS='None'
resolvedNamespaceURI='None'
schemaLocationProperty='Some(file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd)'
resolvedSchemaLocation='Some(org.apache.daffodil.api.URISchemaSource@bd8ade61)']
2019-05-09 15:14:51:485  org.apache.daffodil.dsom.DFDLSchemaFile Resolver[Loading file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd.]
2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://www.w3.org/2001/XMLSchema, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
2019-05-09 15:14:51:493  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Unable to resolve.]
2019-05-09 15:14:51:560  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[nsURI = http://plc4x.apache.org/s7, baseURI = file:/var/folders/4m/d8xs244900sd8ypzndkf4_3w0000gn/T/s7Schema3372165014658428820.dfdl.xsd, systemId = null]
2019-05-09 15:14:51:561  org.apache.daffodil.xml.DFDLCatalogResolver Resolver[Found via XML Catalog: file:/Users/christofer.dutz/Projects/Apache/PLC4X/protocols/s7/target/classes/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd.]

org.apache.daffodil.exceptions.Abort: Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)

	at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
	at org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
	at org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument$lzycompute(DFDLSchemaFile.scala:137)
	at org.apache.daffodil.dsom.DFDLSchemaFile.iiXMLSchemaDocument(DFDLSchemaFile.scala:137)
	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$3(Import.scala:66)
	at scala.Option.getOrElse(Option.scala:121)
	at org.apache.daffodil.dsom.Import.$anonfun$mapPair$1(Import.scala:45)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.Import.mapPair(Import.scala:43)
	at org.apache.daffodil.dsom.IIBase.$anonfun$notSeenThisBefore$1(IIBase.scala:140)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.IIBase.notSeenThisBefore(IIBase.scala:139)
	at org.apache.daffodil.dsom.IIBase.$anonfun$iiSchemaFileMaybe$1(IIBase.scala:257)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.IIBase.iiSchemaFileMaybe(IIBase.scala:256)
	at org.apache.daffodil.dsom.IIBase.$anonfun$seenAfter$1(IIBase.scala:165)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.IIBase.seenAfter(IIBase.scala:164)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$getImportsOrIncludes$1(SchemaDocIncludesAndImportsMixin.scala:147)
	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
	at scala.collection.Iterator.foreach(Iterator.scala:944)
	at scala.collection.Iterator.foreach$(Iterator.scala:944)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1432)
	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes(SchemaDocIncludesAndImportsMixin.scala:143)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.getImportsOrIncludes$(SchemaDocIncludesAndImportsMixin.scala:139)
	at org.apache.daffodil.dsom.XMLSchemaDocument.getImportsOrIncludes(SchemaDocument.scala:64)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$ismli_$1(SchemaDocIncludesAndImportsMixin.scala:158)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.ismli_(SchemaDocIncludesAndImportsMixin.scala:157)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap(SchemaDocIncludesAndImportsMixin.scala:155)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.importStatementsMap$(SchemaDocIncludesAndImportsMixin.scala:155)
	at org.apache.daffodil.dsom.XMLSchemaDocument.importStatementsMap(SchemaDocument.scala:64)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.$anonfun$sali_$1(SchemaDocIncludesAndImportsMixin.scala:165)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.sali_(SchemaDocIncludesAndImportsMixin.scala:164)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter(SchemaDocIncludesAndImportsMixin.scala:162)
	at org.apache.daffodil.dsom.SchemaDocIncludesAndImportsMixin.seenAfter$(SchemaDocIncludesAndImportsMixin.scala:162)
	at org.apache.daffodil.dsom.XMLSchemaDocument.seenAfter(SchemaDocument.scala:64)
	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.$anonfun$allSchemaFiles$1(SchemaSetIncludesAndImportsMixins.scala:63)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
	at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles(SchemaSetIncludesAndImportsMixins.scala:61)
	at org.apache.daffodil.dsom.SchemaSetIncludesAndImportsMixin.allSchemaFiles$(SchemaSetIncludesAndImportsMixins.scala:61)
	at org.apache.daffodil.dsom.SchemaSet.allSchemaFiles(SchemaSet.scala:61)
	at org.apache.daffodil.dsom.SchemaSet.$anonfun$isValid$2(SchemaSet.scala:128)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
	at org.apache.daffodil.dsom.SchemaSet.isValid$lzycompute(SchemaSet.scala:127)
	at org.apache.daffodil.dsom.SchemaSet.isValid(SchemaSet.scala:126)
	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:110)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
	at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
	at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
	at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
	at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
	at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:320)
	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:94)
	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:112)
	at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
	at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
	at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
	at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:82)
	at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
	at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
	at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:112)
	at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:759)
	at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:382)
	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:59)
	at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:141)
	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:41)
	at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:24)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$0(HierarchicalTestExecutor.java:115)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:92)
	at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
	at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:79)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Does that help any further? 

Chris



Am 09.05.19, 14:45 schrieb "Steve Lawrence" <sl...@apache.org>:

    Yeah, this looks like a bug. Based on where that exception is thrown, it
    does look like it's able to find the file in the jar, but cannot open it
    for some reason. Unfortunately, our code to open it looks like this:
    
      try {
        uri.toURL.openStream() // This will work.
      } catch {
        case _: java.io.IOException => Assert.invariantFailed("found
    resource but couldn't open")
      }
    
    So the comment "This will work" is clearly wrong, and we end up masking
    the reason why it failed. That definitely needs to be fixed.
    
    If you bump the log level to LogLevel.Resolver, e.g.:
    
      Daffodil.setLoggingLevel(LogLevel.Resolver);
    
    Then it should output to the console a log starting with "Found on
    classpath" followed by the URI that import resolved to. That might help
    us figure out why it can't open a stream to the file if something looks off.
    
    - Steve
    
    
    
    On 5/9/19 8:04 AM, Christofer Dutz wrote:
    > Hi Steve,
    > 
    > well if that's the case, then I am having trouble doing this.
    > 
    > So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
    > If I try to use it I get an error message that daffodil has found something but it unable to open it.
    > 
    > [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
    > org.apache.daffodil.exceptions.Abort: 
    > Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
    > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    > org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
    > org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
    > org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
    > org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
    > org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
    > org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
    > 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
    > 
    > 
    > Chris
    > 
    > 
    > 
    > Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
    > 
    >     You should be able to import/include files in jars on the classpath
    >     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
    >     So if foo.jar was on your classpath and contained the following
    >     
    >       $ jar -jt foo.jar
    >       META-INF/MANIFEST.MF
    >       com/foo/dfdl/types.dfdl.xsd
    >     
    >     Your schema could reference the types.dfdl.xsd file with:
    >     
    >       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
    >     
    >     You don't need to specify  which jar to import from or even that the
    >     file comes from a jar. Daffodil will just search for that path in all
    >     jars on the classpath.
    >     
    >     - Steve
    >     
    >     
    >     On 5/9/19 6:19 AM, Christofer Dutz wrote:
    >     > Hi all,
    >     > 
    >     > after solving my last problem, I am stuck with another one … as I mentioned in 
    >     > the other thread I have one DFDL schema, which defines all the simple types that 
    >     > will be used by any PLC4X schema.
    >     > 
    >     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
    >     > 
    >     > Now I added a dependency to that jar an now want to reference this in my 
    >     > protocol jar.
    >     > 
    >     > No matter what I try, DFDL always complains about not being able to resolve this.
    >     > 
    >     > So how can I reference and/or import schemas contained in another jar that’s in 
    >     > my classpath?
    >     > 
    >     > Chris
    >     > 
    >     
    >     
    > 
    
    


Re: Referencing DFDL schemas in other jars?

Posted by Steve Lawrence <sl...@apache.org>.
Yeah, this looks like a bug. Based on where that exception is thrown, it
does look like it's able to find the file in the jar, but cannot open it
for some reason. Unfortunately, our code to open it looks like this:

  try {
    uri.toURL.openStream() // This will work.
  } catch {
    case _: java.io.IOException => Assert.invariantFailed("found
resource but couldn't open")
  }

So the comment "This will work" is clearly wrong, and we end up masking
the reason why it failed. That definitely needs to be fixed.

If you bump the log level to LogLevel.Resolver, e.g.:

  Daffodil.setLoggingLevel(LogLevel.Resolver);

Then it should output to the console a log starting with "Found on
classpath" followed by the URI that import resolved to. That might help
us figure out why it can't open a stream to the file if something looks off.

- Steve



On 5/9/19 8:04 AM, Christofer Dutz wrote:
> Hi Steve,
> 
> well if that's the case, then I am having trouble doing this.
> 
> So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
> If I try to use it I get an error message that daffodil has found something but it unable to open it.
> 
> [ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
> org.apache.daffodil.exceptions.Abort: 
> Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
> org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
> org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
> org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
> org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
> org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
> org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
> 	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)
> 
> 
> Chris
> 
> 
> 
> Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:
> 
>     You should be able to import/include files in jars on the classpath
>     using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
>     So if foo.jar was on your classpath and contained the following
>     
>       $ jar -jt foo.jar
>       META-INF/MANIFEST.MF
>       com/foo/dfdl/types.dfdl.xsd
>     
>     Your schema could reference the types.dfdl.xsd file with:
>     
>       <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
>     
>     You don't need to specify  which jar to import from or even that the
>     file comes from a jar. Daffodil will just search for that path in all
>     jars on the classpath.
>     
>     - Steve
>     
>     
>     On 5/9/19 6:19 AM, Christofer Dutz wrote:
>     > Hi all,
>     > 
>     > after solving my last problem, I am stuck with another one … as I mentioned in 
>     > the other thread I have one DFDL schema, which defines all the simple types that 
>     > will be used by any PLC4X schema.
>     > 
>     > In order to do so, this is located in a dedicated maven module and a dedicated jar.
>     > 
>     > Now I added a dependency to that jar an now want to reference this in my 
>     > protocol jar.
>     > 
>     > No matter what I try, DFDL always complains about not being able to resolve this.
>     > 
>     > So how can I reference and/or import schemas contained in another jar that’s in 
>     > my classpath?
>     > 
>     > Chris
>     > 
>     
>     
> 


Re: Referencing DFDL schemas in other jars?

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Steve,

well if that's the case, then I am having trouble doing this.

So In this case I have a base schema in "base.jar" and I add a dependency to this in "protocol" module.
If I try to use it I get an error message that daffodil has found something but it unable to open it.

[ERROR] getTestsuiteTests[40]  Time elapsed: 0.013 s  <<< ERROR!
org.apache.daffodil.exceptions.Abort: 
Invariant broken. Unexpected exception type org.apache.daffodil.exceptions.Abort: Invariant broken. found resource but couldn't open
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
org.apache.daffodil.xml.DFDLCatalogResolver.resolveResource(DaffodilXMLLoader.scala:244)
org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
org.apache.daffodil.exceptions.Assert$.invariantFailed(Assert.scala:175)
org.apache.daffodil.dsom.DFDLSchemaFile.$anonfun$iiXMLSchemaDocument$1(DFDLSchemaFile.scala:155)
org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
	at org.apache.plc4x.protocols.AbstractProtocolTest.lambda$getTestsuiteTests$0(AbstractProtocolTest.java:54)


Chris



Am 09.05.19, 13:25 schrieb "Steve Lawrence" <sl...@apache.org>:

    You should be able to import/include files in jars on the classpath
    using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
    So if foo.jar was on your classpath and contained the following
    
      $ jar -jt foo.jar
      META-INF/MANIFEST.MF
      com/foo/dfdl/types.dfdl.xsd
    
    Your schema could reference the types.dfdl.xsd file with:
    
      <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />
    
    You don't need to specify  which jar to import from or even that the
    file comes from a jar. Daffodil will just search for that path in all
    jars on the classpath.
    
    - Steve
    
    
    On 5/9/19 6:19 AM, Christofer Dutz wrote:
    > Hi all,
    > 
    > after solving my last problem, I am stuck with another one … as I mentioned in 
    > the other thread I have one DFDL schema, which defines all the simple types that 
    > will be used by any PLC4X schema.
    > 
    > In order to do so, this is located in a dedicated maven module and a dedicated jar.
    > 
    > Now I added a dependency to that jar an now want to reference this in my 
    > protocol jar.
    > 
    > No matter what I try, DFDL always complains about not being able to resolve this.
    > 
    > So how can I reference and/or import schemas contained in another jar that’s in 
    > my classpath?
    > 
    > Chris
    > 
    
    


Re: Referencing DFDL schemas in other jars?

Posted by Steve Lawrence <sl...@apache.org>.
You should be able to import/include files in jars on the classpath
using the full path inside the jar, i.e. what "jar -jt foo.jar" outputs.
So if foo.jar was on your classpath and contained the following

  $ jar -jt foo.jar
  META-INF/MANIFEST.MF
  com/foo/dfdl/types.dfdl.xsd

Your schema could reference the types.dfdl.xsd file with:

  <xs:include schemaLocation="com/foo/dfdl/types.dfdl.xsd" />

You don't need to specify  which jar to import from or even that the
file comes from a jar. Daffodil will just search for that path in all
jars on the classpath.

- Steve


On 5/9/19 6:19 AM, Christofer Dutz wrote:
> Hi all,
> 
> after solving my last problem, I am stuck with another one … as I mentioned in 
> the other thread I have one DFDL schema, which defines all the simple types that 
> will be used by any PLC4X schema.
> 
> In order to do so, this is located in a dedicated maven module and a dedicated jar.
> 
> Now I added a dependency to that jar an now want to reference this in my 
> protocol jar.
> 
> No matter what I try, DFDL always complains about not being able to resolve this.
> 
> So how can I reference and/or import schemas contained in another jar that’s in 
> my classpath?
> 
> Chris
>