GWT Compile Error
I've been compiling my application all day absolutely fine however it's suddenly started to fail. As you can see from below, it's a NullPointException
but I have no idea about what is wrong. Has anyone dealt with this before, or can offer any help or guidance?
[INFO] [enunciate:assemble {execution: default}]
[INFO] initializing enunciate.
[INFO] invoking enunciate:generate step...
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[INFO] invoking enunciate:compile step...
[INFO] [gwt] Compiling module com.project.myProject
[INFO] [gwt] Validating newly compiled units
[INFO] [gwt] [ERROR] Unexpected
[INFO] [gwt] java.lang.NullPointerException
[INFO] [gwt] at com.google.gwt.dev.javac.JdtCompiler$FindTypesInCud.visit(JdtCompiler.java:179)
[INFO] [gwt] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1253)
[INFO] [gwt] at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:478)
[INFO] [gwt] at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:576)
[INFO] [gwt] at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.traverse(ConstructorDeclaration.java:505)
[INFO] [gwt] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1239)
[INFO] [gwt] at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:687)
[INFO] [gwt] at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:158)
[INFO] [gwt] at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
[INFO] [gwt] at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:467)
[INFO] [gwt] at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:142)
[INFO] [gwt] at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:281)
[INFO] [gwt] at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:182)
[INFO] [gwt] at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:280)
[INFO] [gwt] at com.google.gwt.dev.Precompile.precompile(Precompile.java:502)
[INFO] [gwt] at com.google.gwt.dev.Precompile.precompile(Precompile.java:414)
[INFO] [gwt] at com.google.gwt.dev.Compiler.run(Compiler.java:201)
[INFO] [gwt] at com.google.gwt.dev.Compiler$1.run(Compiler.java:152)
[INFO] [gwt] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:87)
[INFO] [gwt] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:81)
[INFO] [gwt] at com.google.gwt.de开发者_Python百科v.Compiler.main(Compiler.java:159)
Firstly, if updating GWT doesn't work, revert your code to a known-working version if you can.
I have seen this error message from the compiler when trying to compile buggy sources, containing mistakes along the lines of invoking a method on a variable of a user-defined type of which no instance is ever constructed (in the compilation unit)...
I am certain that the following problem can produce the error you're seeing, I just reproduced it to make sure. Of course that doesn't mean this is your problem, but it might give you something to look for.
Compiler fails with NullPointerException:
MyDumbClass foo;
foo.doSomething();
No problems:
MyDumbClass foo = new MyDumbClass();
foo.doSomething();
I think ... and I am totally guessing ... this has to do with the fact that GWT only outputs javascript for the stuff you actually call, therefore it has to build a call graph starting from the entry point and leave everything else out of the output ... it may be that in that algorithm it throws out MyDumbClass, or MyDumbClass's nested type.
Have you updated to a newer GWT version and not updated the dependent jars?
Enunciate, by default, depends on the GWT 1.5.2 jars. But if you want to update to a newer version of Enunciate, you may need to update your dependencies to the newer version:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.0.0</version>
</dependency>
精彩评论