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

APT NullPointer when generating query with JPA and Collections common base class #3

Closed
timowest opened this issue Oct 3, 2011 · 2 comments

Comments

@timowest
Copy link
Member

@timowest timowest commented Oct 3, 2011

When using the APT-JPA generator in my setup, I get the following exception:

[javac] Note: Running QuerydslAnnotationProcessor
[javac] Note: Serializing Entity types
[javac] Note: Generating apttest.plainschema.QA for [apttest.plainschema.A]
[javac] Note: Generating apttest.QAValueObject for []
[javac] Note: Serializing Embeddable types
[javac] Note: Generating apttest.plainschema.QC for [apttest.plainschema.C]
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.NullPointerException
[javac] at com.mysema.query.codegen.TypeMappings.getQueryType(TypeMappings.java:106)
[javac] at com.mysema.query.codegen.TypeMappings.getPathType(TypeMappings.java:102)
[javac] at com.mysema.query.codegen.TypeMappings.getPathType(TypeMappings.java:98)
[javac] at com.mysema.query.codegen.EntitySerializer.introSuper(EntitySerializer.java:400)
[javac] at com.mysema.query.codegen.EntitySerializer.intro(EntitySerializer.java:232)
[javac] at com.mysema.query.codegen.EntitySerializer.serialize(EntitySerializer.java:542)
[javac] at com.mysema.query.apt.Processor.serialize(Processor.java:681)
[javac] at com.mysema.query.apt.Processor.serializeTypes(Processor.java:190)
[javac] at com.mysema.query.apt.Processor.process(Processor.java:139)
[javac] at com.mysema.query.apt.QuerydslAnnotationProcessor.process(QuerydslAnnotationProcessor.java:51)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:735)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:664)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:809)
[javac] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1061)
[javac] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:796)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:388)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:308)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:299)
[javac] at com.sun.tools.javac.Main.compile(Main.java:82)
[javac] at com.sun.tools.javac.Main.main(Main.java:67)

Another Exception is hidden in the example, which can be caused by annotating AValueObject with @QuerySupertype:

[javac] Note: Running QuerydslAnnotationProcessor
[javac] Note: Serializing Supertypes
[javac] Note: Generating apttest.QAValueObject for [apttest.AValueObject]
[javac] Note: Serializing Entity types
[javac] Note: Generating apttest.plainschema.QA for [apttest.plainschema.A]
[javac] Note: Serializing Embeddable types
[javac] Note: Generating apttest.plainschema.QC for [apttest.plainschema.C]
[javac] Note: Generating apttest.plainschema.QB for [apttest.plainschema.B]
[javac] Note: Running JPAAnnotationProcessor
[javac] Note: Serializing Supertypes
[javac] Note: Generating apttest.QAEntity for [apttest.AEntity]
[javac] error: Attempt to reopen a file for path /home/subes/Dokumente/Entwicklung/invesdwin/inv-finanzdaten-workspace/querydsltc/gen/apttest/QAValueObject.java
[javac] Note: Serializing Entity types
[javac] Note: Generating apttest.jpaschema.QA for [apttest.jpaschema.A]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntity for [apttest.jpareal.sub.AbschlussberichtEntity]
[javac] Note: Generating apttest.jpareal.QUnternehmenEntity for [apttest.jpareal.UnternehmenEntity]
[javac] Note: Serializing Embeddable types
[javac] Note: Generating apttest.jpaschema.QB for [apttest.jpaschema.B]
[javac] Note: Generating apttest.jpaschema.QC for [apttest.jpaschema.C]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityCashFlowPeriode for [apttest.jpareal.sub.AbschlussberichtEntityCashFlowPeriode]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityIncome for [apttest.jpareal.sub.AbschlussberichtEntityIncome]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityBalanceAktiva for [apttest.jpareal.sub.AbschlussberichtEntityBalanceAktiva]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityBalance for [apttest.jpareal.sub.AbschlussberichtEntityBalance]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityBalancePassiva for [apttest.jpareal.sub.AbschlussberichtEntityBalancePassiva]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityCashFlow for [apttest.jpareal.sub.AbschlussberichtEntityCashFlow]
[javac] Note: Running QuerydslAnnotationProcessor
[javac] Note: Running JPAAnnotationProcessor
[javac] 1 error

See attachment for the example eclipse project which reproduces the problem. Run the ant target "generate" to reproduce the issue.

This is a serious problem which hinders me from integrating querydsl into my platform. Thanks for your help!

@timowest
Copy link
Member Author

@timowest timowest commented Oct 3, 2011

Could you try upgrading to 2.2.0-beta4 and reproduce the problem? I could not yet reproduce the problem in a Querydsl test in SVN trunk.
gsubes (gsubes) wrote on 2011-05-22: #3

I am using 2.2.0-beta4 in my platform, though provided the sample with a prior version. So the problem also occurs with 2.2.0-beta4. Is there a way to download the SVN snapshots via maven so I can test those?
Timo Westkämper (timo-westkamper) wrote on 2011-05-24: #4

I am currently on holidays, but Vesa might be able to look into this.
gsubes (gsubes) wrote on 2011-05-25: #5

Ok, the integration of QueryDSL is on hold for me until this blocker is resolved.
Vesa Marttila (ponzao) on 2011-05-25
Changed in querydsl:
importance: Undecided → Critical
gsubes (gsubes) wrote on 2011-06-03: #6

In the meantime my data model got refactored and thus I don't have levels of @Embedded higher than 1 anymore. Thus I have integrated 2.2.0-beta4 into the platform. Anyway I am still interested in fixing this bug and am willing to test this with 2.2.0-beta5. Is there an estimate when that will be available?
Timo Westkämper (timo-westkamper) wrote on 2011-07-04: #7

2.2.0.beta5 is out now, I also made some improvements to the current SVN trunk. Could you test this with SVN trunk?
Timo Westkämper (timo-westkamper) wrote on 2011-07-04: #8

I couldn't yet reproduce the first issue in a Querydsl test, but I've been able to reproduce the second one.
Timo Westkämper (timo-westkamper) wrote on 2011-07-04: #9

Maybe it would be easiest to just avoid the mixed annotations. Just use the Querydsl annotations for types which are not covered by the JPA annotation processor.

Is there only one module in your real application or are the sources split?
Changed in querydsl:
status: New → In Progress
Timo Westkämper (timo-westkamper) wrote on 2011-07-04: #10

Now I was able to reproduce always the first issue and got that fixed. I also just realized that my advice in the previous comment doesn't work.

I will try to find a fix for this.
Timo Westkämper (timo-westkamper) wrote on 2011-07-05: #11

I believe a valid fix for this scenario would be to use the following APT options in one of the processors :

  • querydsl.excludedPackages
  • querydsl.excludedClasses

Unfortunately it is really difficult to fix this otherwise since the APT throws an Exception already when requesting a file handle to a source file which has been created via another APT processor.
gsubes (gsubes) wrote on 2011-07-05: #12

A Workaround might be, to run the APT processors in seperate tasks? Atleast this is what solved my problem when I was using the Hibernate Metamodel Generator APT Processor together with the querydsl APT processors. The Hibernate processor did not want to generate the Entity_ files for every entity there was. Seperating them resolved the issue. Currently I am running the querydsl processors seperately in my platform aswell. Maybe you can verify this in the testcase. I am currently unable to do that.
Timo Westkämper (timo-westkamper) wrote on 2011-07-05: #13

Yes, this works as well.
Ross Judson (rossjudson) wrote on 2011-07-22: #14

I've looked through the code and the NPE appears to be at line 479 in Processor.hasKnownAnnotation. Unless there's something mysterious going on, the configuration.getSupertypeSerializer() test should actually be configuration.getSupertypeAnnotation(). It looks like it's testing for null on a different annotation than the one it actually tries to go and get.
Timo Westkämper (timo-westkamper) wrote on 2011-07-25: #15

Fixed the NPE issue in SVN trunk. Could you verify that it works now?
Timo Westkämper (timo-westkamper) wrote on 2011-08-03: #16

Could you try again with the latest SNAPSHOT version from SVN trunk? I made some other improvements to APT processing.
Timo Westkämper (timo-westkamper) wrote on 2011-08-08: #17

Querydsl has now moved to GitHub : https://github.com/mysema/querydsl
Ross Judson (rossjudson) wrote on 2011-08-08: Re: [Bug 786195] Re: APT NullPointer when generating query with JPA and Collections common base class #18

Should be able to try again tomorrow.

On Wed, Aug 3, 2011 at 6:19 AM, Timo Westkämper
timo.westkamper@mysema.com wrote:
[...]

Read more...
Timo Westkämper (timo-westkamper) wrote on 2011-09-13: #19

Have you been able to verify that this works now?
Ross Judson (rossjudson) wrote on 2011-09-18: Re: [Bug 786195] APT NullPointer when generating query with JPA and Collections common base class #20

I have not yet; I am traveling in China, and my ability to do work varies quite a bit depending on where I am. I will try again shortly to see if it's fixed with the latest. Thanks for your attention on this matter.

RJ

@timowest
Copy link
Member Author

@timowest timowest commented Nov 19, 2011

Released in 2.2.5

@timowest timowest closed this Nov 19, 2011
timowest pushed a commit that referenced this issue Jun 20, 2014
Add CGLIB dependency for the JPA module test
Shredder121 pushed a commit that referenced this issue Mar 4, 2015
Only build on Oracle JDK 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant