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

NullPointerException #70

Closed
denouche opened this Issue Jan 14, 2016 · 11 comments

Comments

Projects
None yet
2 participants
@denouche

denouche commented Jan 14, 2016

Hi,

I encounter the following error while generating mappers:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NullPointerException
    at fr.xebia.extras.selma.codegen.CustomMapperWrapper.collectCustomMethods(CustomMapperWrapper.java:200)
    at fr.xebia.extras.selma.codegen.CustomMapperWrapper.collectCustomMappers(CustomMapperWrapper.java:173)
    at fr.xebia.extras.selma.codegen.CustomMapperWrapper.<init>(CustomMapperWrapper.java:64)
    at fr.xebia.extras.selma.codegen.MapperWrapper.<init>(MapperWrapper.java:93)
    at fr.xebia.extras.selma.codegen.MapperClassGenerator.<init>(MapperClassGenerator.java:60)
    at fr.xebia.extras.selma.codegen.MapperProcessor.generateMappingClassses(MapperProcessor.java:89)
    at fr.xebia.extras.selma.codegen.MapperProcessor.process(MapperProcessor.java:74)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)

It happens in v0.13 and v0.14-SNAPSHOT (last master).

Trying to debug it I can see that this line:

final TypeElement element = context.elements.getTypeElement(customMapper.replace(".class", ""));

located in the private void collectCustomMappers() method is null.

I really don't know what to do to solve my problem, please help !

Thank you

@slemesle

This comment has been minimized.

Show comment
Hide comment
@slemesle

slemesle Jan 14, 2016

Hi could you tell me more like what is the value of the customMapper local variable when you get a null element ?

Also can you provide a sample code to reproduce the error ?
Elements.getTypeElement does not find the targeted class for some reason is it existing in the classpath at build time, is it in a separate jar ?

As you can see I just need more to fix this issue.

slemesle commented Jan 14, 2016

Hi could you tell me more like what is the value of the customMapper local variable when you get a null element ?

Also can you provide a sample code to reproduce the error ?
Elements.getTypeElement does not find the targeted class for some reason is it existing in the classpath at build time, is it in a separate jar ?

As you can see I just need more to fix this issue.

@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche Jan 15, 2016

The local variable customMapper contains com.company.move.customeraccount.mapper.classification.CustomerClassificationNaturalPersonListMapper.class

The class is in the classpath since it is contained in the same project.

I'm trying to extract you some code to reproduce it.

Thank you!

denouche commented Jan 15, 2016

The local variable customMapper contains com.company.move.customeraccount.mapper.classification.CustomerClassificationNaturalPersonListMapper.class

The class is in the classpath since it is contained in the same project.

I'm trying to extract you some code to reproduce it.

Thank you!

@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche Jan 15, 2016

https://github.com/denouche/selma-bug

I cleaned the code to let the minimum source code.
But I let the hierarchy of the code, in case the problem come from this.

You just need to run mvn clean compile to see this:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ test ---
[INFO] Deleting /home/denouche/workspace/selma-bug/target
[INFO] Deleting /home/denouche/workspace/selma-bug/src/main/generated-sources (includes = [], excludes = [])
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/denouche/workspace/selma-bug/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 11 source files to /home/denouche/workspace/selma-bug/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.429 s
[INFO] Finished at: 2016-01-15T10:41:42+01:00
[INFO] Final Memory: 16M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project test: Fatal error compiling: java.lang.NullPointerException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Do not hesitate if you need more informations.

Thank you

denouche commented Jan 15, 2016

https://github.com/denouche/selma-bug

I cleaned the code to let the minimum source code.
But I let the hierarchy of the code, in case the problem come from this.

You just need to run mvn clean compile to see this:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ test ---
[INFO] Deleting /home/denouche/workspace/selma-bug/target
[INFO] Deleting /home/denouche/workspace/selma-bug/src/main/generated-sources (includes = [], excludes = [])
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/denouche/workspace/selma-bug/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 11 source files to /home/denouche/workspace/selma-bug/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.429 s
[INFO] Finished at: 2016-01-15T10:41:42+01:00
[INFO] Final Memory: 16M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project test: Fatal error compiling: java.lang.NullPointerException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Do not hesitate if you need more informations.

Thank you

@slemesle

This comment has been minimized.

Show comment
Hide comment
@slemesle

slemesle Jan 15, 2016

Ok it sounds like a jdk bug so, what is your jdk release and could you test it with a newer one ?

slemesle commented Jan 15, 2016

Ok it sounds like a jdk bug so, what is your jdk release and could you test it with a newer one ?

@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche Jan 15, 2016

$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

I will test with a new one.

Thanks

denouche commented Jan 15, 2016

$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

I will test with a new one.

Thanks

@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche Jan 15, 2016

same problem with OpenJDK 1.7.0_79.
I will try with latest 1.8
(but my application need to run JDK 7, and 1.7.0_79 is apparently the last 1.7 update)

denouche commented Jan 15, 2016

same problem with OpenJDK 1.7.0_79.
I will try with latest 1.8
(but my application need to run JDK 7, and 1.7.0_79 is apparently the last 1.7 update)

@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche Jan 15, 2016

Same problem with Oracle 1.8.0_65 version ...

denouche commented Jan 15, 2016

Same problem with Oracle 1.8.0_65 version ...

@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche Jan 15, 2016

I simplified the code on branch simplified
https://github.com/denouche/selma-bug/tree/simplified
The bug still occurs.
Thank you in advance for your help.

denouche commented Jan 15, 2016

I simplified the code on branch simplified
https://github.com/denouche/selma-bug/tree/simplified
The bug still occurs.
Thank you in advance for your help.

@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche Jan 15, 2016

I've got it :)
Making a pull request

denouche commented Jan 15, 2016

I've got it :)
Making a pull request

denouche added a commit to denouche/selma that referenced this issue Jan 15, 2016

\xebia-france#70: Fix do replace all the .class even in package hiera…
…rchy

Fix the regex to replace only the .class at the end of the line.
closes xebia-france#70

denouche added a commit to denouche/selma that referenced this issue Jan 15, 2016

denouche added a commit to denouche/selma that referenced this issue Jan 15, 2016

xebia-france#70: do not replace the .class in the package names.
Fix the regex to replace only the .class at the end of the line.
closes xebia-france#70
@denouche

This comment has been minimized.

Show comment
Hide comment
@denouche

denouche commented Jan 15, 2016

#71

@slemesle

This comment has been minimized.

Show comment
Hide comment
@slemesle

slemesle Jan 15, 2016

Thanks a lot for the work and for using Selma.
I'll add an integration test for this bug

slemesle commented Jan 15, 2016

Thanks a lot for the work and for using Selma.
I'll add an integration test for this bug

@slemesle slemesle closed this in #71 Jan 15, 2016

slemesle added a commit that referenced this issue Jan 15, 2016

Merge pull request #71 from denouche/master
 #70: do not replace the .class in the package names.

@slemesle slemesle added the bug label Mar 17, 2016

@slemesle slemesle added this to the 0.14 milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment