Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash during conversion of AIXM #102

Open
pyssling opened this issue Nov 21, 2020 · 5 comments
Open

Crash during conversion of AIXM #102

pyssling opened this issue Nov 21, 2020 · 5 comments

Comments

@pyssling
Copy link

Hi,

I previously used xsd2thrift for converting XSDs but decided it's time to move to schema2proto . I'm working with large complicated XSDs generated by Sparx Systems Enterprise Architect - in this case the AIXM for aeronautical data - the XSDs are available here:

http://aixm.aero/document/aixm-511-xml-schema-xsd

I'm using the one with local copies of all dependencies. I can convert some of the dependencies - but once I start with the larger ones things crash pretty immediately on the following exception:

[main] INFO no.entur.schema2proto.generateproto.Schema2Proto - Starting to parse aixm-5.1.1/AIXM_DataTypes.xsd
[main] ERROR no.entur.schema2proto.generateproto.Schema2Proto - Error processing proto files: null
java.lang.NullPointerException
        at no.entur.schema2proto.generateproto.SchemaParser.navigateSubTypes(SchemaParser.java:388)
        at no.entur.schema2proto.generateproto.SchemaParser.processGroupAsSequence(SchemaParser.java:993)
        at no.entur.schema2proto.generateproto.SchemaParser.processGroup(SchemaParser.java:922)
        at no.entur.schema2proto.generateproto.SchemaParser.processComplexType(SchemaParser.java:696)
        at no.entur.schema2proto.generateproto.SchemaParser.lambda$processSchemaSet$2(SchemaParser.java:191)
        at java.base/java.util.TreeMap.forEach(TreeMap.java:1002)
        at no.entur.schema2proto.generateproto.SchemaParser.processSchemaSet(SchemaParser.java:191)
        at no.entur.schema2proto.generateproto.SchemaParser.parse(SchemaParser.java:137)
        at no.entur.schema2proto.generateproto.Schema2Proto.parseAndSerialize(Schema2Proto.java:107)
        at no.entur.schema2proto.generateproto.Schema2Proto.<init>(Schema2Proto.java:92)
        at no.entur.schema2proto.generateproto.Schema2Proto.main(Schema2Proto.java:125)

All help much appreciated!

@pyssling
Copy link
Author

pyssling commented Nov 21, 2020

Ok - spent some time debugging this - it appears that at

        at no.entur.schema2proto.generateproto.SchemaParser.navigateSubTypes(SchemaParser.java:388)

I have a substitutable of type ListSimpleTypeImpl which extends SimpleTypeImpl which when the method asComplexType() is called returns a null - which when isAbstract() is called throws the NullPointerException . I guess there should be a check on whether asComplexType() returns null.

@pyssling
Copy link
Author

I patched over this bug - but not necessarily in a good way - and quickly hit upon a few more bugs. If someone who is familiar with how this works has time to download these schemas and fix enough bugs/missing features to get this working that would be very much appreciated. I've looked at the source code - but I'm afraid it's quite a starting stretch to get into this.

@pyssling
Copy link
Author

pyssling commented Dec 4, 2020

@seime Thanks for the help.

I'm getting a lot further now, here are the options I'm passing in:

--outputDirectory out aixm-5.1.1/AIXM_Features.xsd

Then it crashes on:

Exception in thread "main" java.lang.StackOverflowError
	at java.base/java.util.HashMap.hash(HashMap.java:339)
	at java.base/java.util.HashMap.get(HashMap.java:552)
	at no.entur.schema2proto.generateproto.ProtoSerializer.hasRecursiveImports(ProtoSerializer.java:720)
	at no.entur.schema2proto.generateproto.ProtoSerializer.hasRecursiveImports(ProtoSerializer.java:725)
	at no.entur.schema2proto.generateproto.ProtoSerializer.hasRecursiveImports(ProtoSerializer.java:725)
	at no.entur.schema2proto.generateproto.ProtoSerializer.hasRecursiveImports(ProtoSerializer.java:725)
	at no.entur.schema2proto.generateproto.ProtoSerializer.hasRecursiveImports(ProtoSerializer.java:725)
....

So endless recursion it seems.

I also get one warning which I think is just bad schema design:

[main] WARN no.entur.schema2proto.generateproto.ProtoSerializer - Cannot uppercase message secondDefiningParameterType to SecondDefiningParameterType as type already exist! Renaming ignored

I think this is something I can patch around in the original schema.

Stort tack!

@salimfadhleyhtp
Copy link

salimfadhleyhtp commented Jul 15, 2021

I'm seeing a similar error:

java -jar /tmp/schema2proto/schema2proto-lib/target/schema2proto-lib-1.40-SNAPSHOT.jar  "/xsds/BOALF_DataPush_Response_XSD.xsd" --outputDirectory="/proto"
[main] INFO no.entur.schema2proto.generateproto.Schema2Proto - Starting to parse /xsds/BOALF_DataPush_Response_XSD.xsd
[main] INFO no.entur.schema2proto.generateproto.ProtoSerializer - Writing proto files to /proto
[main] ERROR no.entur.schema2proto.generateproto.Schema2Proto - Error processing proto files: null
java.lang.NullPointerException
        at no.entur.schema2proto.generateproto.ProtoSerializer.lambda$moveReusedLocalTypesToGlobal$32(ProtoSerializer.java:1252)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
        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.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
        at no.entur.schema2proto.generateproto.ProtoSerializer.moveReusedLocalTypesToGlobal(ProtoSerializer.java:1252)
        at no.entur.schema2proto.generateproto.ProtoSerializer.serialize(ProtoSerializer.java:137)
        at no.entur.schema2proto.generateproto.Schema2Proto.parseAndSerialize(Schema2Proto.java:114)
        at no.entur.schema2proto.generateproto.Schema2Proto.<init>(Schema2Proto.java:94)
        at no.entur.schema2proto.generateproto.Schema2Proto.main(Schema2Proto.java:127)

This is one of the XSDs I am trying to convert:

https://gist.github.com/salimfadhleyhtp/30fe50025f439637a05f979da39df004

@salimfadhleyhtp
Copy link

@pyssling I think this error is caused when the targetNamespace field is not set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants