regression on code generation

334 views
Skip to first unread message

Rob Sargent

unread,
Dec 7, 2020, 2:08:52 PM12/7/20
to jooq...@googlegroups.com

I'm sure this is entirely a hole of my own digging, but I'm stuck, un-sure which part is broken.

I started to move to java 15 but the code generation step failed.  However if I revert to java 11 I get the same error as follows:

Dec 07, 2020 11:55:58 AM org.jooq.tools.JooqLogger warn
WARNING: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 6235; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":primaryKeyTypes}'. One of '{"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":generatedAnnotationDate, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":constructorPropertiesAnnotation, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":constructorPropertiesAnnotationOnPojos, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":constructorPropertiesAnnotationOnRecords, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":pojosAsJavaRecordClasses, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":pojosAsScalaCaseClasses, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":pojosAsKotlinDataClasses, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":jpaVersion, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":globalDomainReferences, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":commentsOnEmbeddables, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":generatedSerialVersionUID, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":maxMembersPerInitialiser, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":newline, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":indentation}' is expected.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/rob/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-impl/2.3.0.1/2e979dabb3e5e74a0686115075956391a14dece8/jaxb-impl-2.3.0.1.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Dec 07, 2020 11:55:59 AM org.jooq.tools.JooqLogger error
SEVERE: Cannot read /home/rob/gits/gitlab/sgs4/jooq/build/tmp/generateJooq/config.xml. Error : Error generating code for catalog
org.jooq.codegen.GeneratorException: Error generating code for catalog
    at org.jooq.codegen.JavaGenerator.generate(JavaGenerator.java:441)
    at org.jooq.codegen.GenerationTool.run0(GenerationTool.java:879)
    at org.jooq.codegen.GenerationTool.run(GenerationTool.java:233)
    at org.jooq.codegen.GenerationTool.generate(GenerationTool.java:228)
    at org.jooq.codegen.GenerationTool.main(GenerationTool.java:200)
Caused by: java.lang.NullPointerException
    at org.jooq.codegen.JavaWriter.beforeClose(JavaWriter.java:227)
    at org.jooq.codegen.GeneratorWriter.close(GeneratorWriter.java:339)
    at org.jooq.codegen.JavaGenerator.closeJavaWriter(JavaGenerator.java:8566)
    at org.jooq.codegen.JavaGenerator.generateCatalog(JavaGenerator.java:6253)
    at org.jooq.codegen.JavaGenerator.generate(JavaGenerator.java:531)
    at org.jooq.codegen.JavaGenerator.generate(JavaGenerator.java:436)
    ... 4 more

and I'm not sure which warning is, shall we say, understated.  Is it the 'invalid content' or the 'Illegal reflective access'.  I have attacted the generated config.xml as well as my extension of JavaGenerator.

Also, I don't explicitly involve com.sun.xml.bind/jaxb-impl/2.3.0.1 and am wondering how to get round that.





config.xml
JxonAnnotationGenerator.java
TimestampConverter.java

Lukas Eder

unread,
Dec 7, 2020, 5:22:41 PM12/7/20
to jOOQ User Group
Hi Rob,

I'll be happy to help you, but I think I'll need to get some help on how to reproduce this. When reporting bugs, we usually ask people to report them in the form of an "MCVE" (minimal, complete, verifiable example). We have a template for that:

For example, I don't see how you set up your class path, if you're using Gradle, or Maven, or something else, and how you're doing that, what versions of jOOQ, code generator, and other third parties are involved, etc.

I think both are just warnings. Look for the source of the NPE, instead. But perhaps I'm mistaken - being able to reproduce this would help.
 

  Is it the 'invalid content'

We evolve the XSD (and thus code generation config) as backwards compatibly as possible. If schema validation is turned on, then new code generation features that may not have been recognised by old versions of the code generator will not pass by its validation. Maven doesn't care, but if you're loading the XML file externally, validation is turned on by default. So, there may be a wrong version of jOOQ on your classpath somewhere, but that may be irrelevant to why code generation fails.

or the 'Illegal reflective access'. 

That's just a "bug" in a transitive dependency. jOOQ pulls in JAXB for historic reasons, and they haven't fixed this yet.

See also:

Thanks,
Lukas

Rob Sargent

unread,
Dec 7, 2020, 5:30:29 PM12/7/20
to jooq...@googlegroups.com

Thank you for your patience.  I don't know that I'm reporting a bug (or suspicion of one). Let me try to re-phrase:

Is the config.xml in the first message well formed (at least well formed enough that the warnings can be ignored)?

Is the "illegal reflection" safe to ignore or preferably correctable?


With these answered I can go back to digging and should I find or suspect a bug I will do my best to make a MCVE.  But as this may be strictly related to gradle I'm not sure how that will turn out when translated to a pom.

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5D8rziEKSyx8WPXH-vRuWhA-KMn5mXpSg%2BYyQ7aOiwqg%40mail.gmail.com.

Lukas Eder

unread,
Dec 7, 2020, 6:02:57 PM12/7/20
to jOOQ User Group
On Mon, Dec 7, 2020 at 11:30 PM Rob Sargent <robjs...@gmail.com> wrote:

Thank you for your patience.  I don't know that I'm reporting a bug (or suspicion of one). Let me try to re-phrase:


I see, makes sense. 

Is the config.xml in the first message well formed (at least well formed enough that the warnings can be ignored)?

You mean valid? Well-formedness is easy to check.

It's probably valid, if it was valid before... Do check if namespaces are correct, and if the correct versions of jOOQ are used.
 

Is the "illegal reflection" safe to ignore or preferably correctable?


It is always safe to ignore for now. It just means that some library is trying to access JDK internals that it shouldn't access (but everyone did it for the past 25 years). Future JDK versions (16 or 17 I think) will start preventing such access by default, but as far as I know, it will still be possible to make it work for quite a while.
 

With these answered I can go back to digging and should I find or suspect a bug I will do my best to make a MCVE.  But as this may be strictly related to gradle I'm not sure how that will turn out when translated to a pom.


A gradle MCVE template is overdue! I might create one, soon. The examples by Etienne Studer might work too, though:

Thanks,
Lukas

Rob Sargent

unread,
Dec 7, 2020, 6:19:03 PM12/7/20
to jooq...@googlegroups.com

Thanks again.

What I find most confusing is the

SEVERE: Cannot read /home/rob/gits/gitlab/sgs4/jooq/build/tmp/generateJooq/config.xml. Error : Error generating code for catalog
org.jooq.codegen.GeneratorException: Error generating code for catalog

after having reported those warning about that very same file.  I have to take it that "cannot read" is more "cannot parse"?

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.

Rob Sargent

unread,
Dec 7, 2020, 7:43:37 PM12/7/20
to jooq...@googlegroups.com

I see from the jooq source that the error message is supposed to report which catalog it's having trouble with.  I presume its an empty string at the point of the error (or we would get "null" a the name of the catalog).

SEVERE: Cannot read /home/rob/gits/gitlab/sgs4/jooq/build/tmp/generateJooq/config.xml. Error : Error generating code for catalog <missing catalogue name>
org.jooq.codegen.GeneratorException: Error generating code for catalog
<missing catalogue name>

    at org.jooq.codegen.JavaGenerator.generate(JavaGenerator.java:441)
    at org.jooq.codegen.GenerationTool.run0(GenerationTool.java:879)
    at org.jooq.codegen.GenerationTool.run(GenerationTool.java:233)
    at org.jooq.codegen.GenerationTool.generate(GenerationTool.java:228)
    at org.jooq.codegen.GenerationTool.main(GenerationTool.java:200)


On 12/7/20 4:02 PM, Lukas Eder wrote:
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.

Lukas Eder

unread,
Dec 8, 2020, 3:11:13 AM12/8/20
to jOOQ User Group
The "Cannot read" error stems from a catch-all exception handler. That could be changed to "Error in file: ". I will change that right away.

Checking your XML file, why are you using catalog configuration? Catalogs are supported in SQL Server, only. You're using PostgreSQL... Could that be it?

Lukas Eder

unread,
Dec 8, 2020, 8:42:14 AM12/8/20
to jOOQ User Group
Thanks a lot for your MCVE, Rob:
https://github.com/jOOQ/jOOQ-mcve/pull/8

I could reproduce the NPE immediately and fixed it already for 3.15.0 and 3.14.5:

Best Regards,
Lukas

Reply all
Reply to author
Forward
0 new messages