2

My GWT compiler started failing with a NoSuchMethodError. It started happening when I updated a method parameter from an Long to a long. I shouldn't need to but I tried switching it back and I'm still having the same error. My java eclipse runtime compiler doesn't see the line as an error, and everything is running fine in dev mode.

Caused by: java.lang.NoSuchMethodError: com.dscicorp.ribeye.shared.dto.Data.put(Ljava/lang/String;Ljava/lang/Long)Ljava/lang/String;

So it seems like it's treating long's and Long's as different types. Here's what the actual method looks like:

public String put(String key, long value) {
    return put(key, Long.toString(value));
}

I'm not sure if this has something to do with it but in the error message it's outputting the line slightly differently than what's in my code. It replaced the long variable "val" with "Long.valueOf(val)".

this.this$01.reportOptions.put("noteTypes", Long.valueOf(val))

I tried adding both long and Long versions to see if it got past this problem, and it did but it errored similarly in another place. Is this a GWT bug or could I have something possibly configured wrong?

Here's the full compiler log:

gwtc:
 [java] Compiling module com.dscicorp.ribeye.RibEye
 [java]    Computing all possible rebind results for 'com.dscicorp.ribeye.client.generated.ReflectiveFactory'
 [java]       Rebinding com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]          Invoking generator com.dscicorp.ribeye.generator.FactoryGenerator
 [java]             Generating source for com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]       Rebinding com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]          Invoking generator com.dscicorp.ribeye.generator.FactoryGenerator
 [java]             Generating source for com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]       Rebinding com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]          Invoking generator com.dscicorp.ribeye.generator.FactoryGenerator
 [java]             Generating source for com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]       Rebinding com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]          Invoking generator com.dscicorp.ribeye.generator.FactoryGenerator
 [java]             Generating source for com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]       Rebinding com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]          Invoking generator com.dscicorp.ribeye.generator.FactoryGenerator
 [java]             Generating source for com.dscicorp.ribeye.client.generated.ReflectiveFactory
 [java]    [ERROR] An internal compiler exception occurred
 [java] com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
 [java]     at com.google.gwt.dev.jjs.ast.JVisitor.translateException(JVisitor.java:121)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:296)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
 [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:128)
 [java]     at com.google.gwt.dev.jjs.ast.JExpressionStatement.traverse(JExpressionStatement.java:42)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:95)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:351)
 [java]     at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
 [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:149)
 [java]     at com.google.gwt.dev.jjs.ast.JIfStatement.traverse(JIfStatement.java:53)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:95)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:351)
 [java]     at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
 [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:149)
 [java]     at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:145)
 [java]     at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
 [java]     at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:600)
 [java]     at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:569)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
 [java]     at com.google.gwt.dev.jjs.impl.UnifyAst.mainLoop(UnifyAst.java:1505)
 [java]     at com.google.gwt.dev.jjs.impl.UnifyAst.exec(UnifyAst.java:870)
 [java]     at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.unifyJavaAst(JavaToJavaScriptCompiler.java:1305)
 [java]     at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.constructJavaAst(JavaToJavaScriptCompiler.java:1038)
 [java]     at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.precompile(JavaToJavaScriptCompiler.java:954)
 [java]     at com.google.gwt.dev.jjs.MonolithicJavaToJavaScriptCompiler.precompile(MonolithicJavaToJavaScriptCompiler.java:303)
 [java]     at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:38)
 [java]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:286)
 [java]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
 [java]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
 [java]     at com.google.gwt.dev.Compiler.run(Compiler.java:206)
 [java]     at com.google.gwt.dev.Compiler.run(Compiler.java:158)
 [java]     at com.google.gwt.dev.Compiler$1.run(Compiler.java:120)
 [java]     at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
 [java]     at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
 [java]     at com.google.gwt.dev.Compiler.main(Compiler.java:127)
 [java] Caused by: java.lang.NoSuchMethodError: com.dscicorp.ribeye.shared.dto.Data.put(Ljava/lang/String;Ljava/lang/Long;)Ljava/lang/String;
 [java]     at com.google.gwt.dev.jjs.impl.UnifyAst.translate(UnifyAst.java:1715)
 [java]     at com.google.gwt.dev.jjs.impl.UnifyAst.access$1100(UnifyAst.java:134)
 [java]     at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.visit(UnifyAst.java:416)
 [java]     at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:245)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
 [java]     at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
 [java]     ... 42 more
 [java]       [ERROR] at MasterWorkLogSearchReportPage.java(281): this.this$01.reportOptions.put("noteTypes", Long.valueOf(val))
 [java]          com.google.gwt.dev.jjs.ast.JMethodCall
 [java]       [ERROR] at MasterWorkLogSearchReportPage.java(281): this.this$01.reportOptions.put("noteTypes", Long.valueOf(val))
 [java]          com.google.gwt.dev.jjs.ast.JExpressionStatement
 [java]       [ERROR] at MasterWorkLogSearchReportPage.java(280): {
 [java]   this.this$01.reportOptions.put("noteTypes", Long.valueOf(val));
 [java] }
 [java]          com.google.gwt.dev.jjs.ast.JBlock
 [java]       [ERROR] at MasterWorkLogSearchReportPage.java(280): if (val > 0) {
 [java]   this.this$01.reportOptions.put("noteTypes", Long.valueOf(val));
 [java] } else {
 [java]   this.this$01.reportOptions.remove("noteTypes");
 [java] }
 [java]          com.google.gwt.dev.jjs.ast.JIfStatement
 [java]       [ERROR] at MasterWorkLogSearchReportPage.java(277): {
 [java]   long val = this.this$01.getNoteTypesValue();
 [java]   if (val > 0) {
 [java]     this.this$01.reportOptions.put("noteTypes", Long.valueOf(val));
 [java]   } else {
 [java]     this.this$01.reportOptions.remove("noteTypes");
 [java]   }
 [java] }
 [java]          com.google.gwt.dev.jjs.ast.JBlock
 [java]       [ERROR] at MasterWorkLogSearchReportPage.java(277): {
 [java]   long val = this.this$01.getNoteTypesValue();
 [java]   if (val > 0) {
 [java]     this.this$01.reportOptions.put("noteTypes", Long.valueOf(val));
 [java]   } else {
 [java]     this.this$01.reportOptions.remove("noteTypes");
 [java]   }
 [java] }
 [java]          com.google.gwt.dev.jjs.ast.JMethodBody
 [java]       [ERROR] at MasterWorkLogSearchReportPage.java(277): public void execute();
 [java] 
 [java]          com.google.gwt.dev.jjs.ast.JMethod
Zip184
  • 1,792
  • 2
  • 21
  • 34
  • NoSuchMethodError is not a GWT compiler exception, but a Java runtime exception. Can you share the full compiler log, and see if cleaning your workspace helps? Also, make sure you are compiling with `-strict` turned on so that it fails on the first error, rather than letting it snowball into other downstream errors. – Colin Alworth Mar 13 '16 at 18:21
  • Thanks I posted it. Now it's erroring on a long vs. Long method but it's the same deal. Still can't find the put(String, Long) method of that same "Data" class. – Zip184 Mar 13 '16 at 18:35
  • @Zip184 Can you post what `Data#put()` looks like? – Baz Mar 13 '16 at 18:53
  • It's pretty simple. Just a convenience method. public String put(String key, long value) { return put(key, Long.toString(value)); } – Zip184 Mar 13 '16 at 18:54
  • @Zip184 Right, and now please post the code where you call this method. The whole block containing the call ideally. – Baz Mar 13 '16 at 18:56
  • long val = getNoteTypesValue(); if (val > 0) { reportOptions.put("noteTypes", val); } else { reportOptions.remove("noteTypes"); } – Zip184 Mar 13 '16 at 19:01
  • 1
    If the error message is changing, then you must be changing something in your code, or else you have some stale unitCache or the like that should be cleaned from your workspace - this error is different from the error that used to be there. That said, the new stack trace seems correct - if your method is `public String put(String key, int value)`, then no, you can't pass in a `Long`. If your question is just missing the full picture... then provide the full picture. – Colin Alworth Mar 13 '16 at 19:13
  • The change I made was that I added both Integer and int versions of the method to try and get around this error, then the long version started having the same issue. So the output is from that scenario. So it's all valid java. I guess I'll update my question to match the output. – Zip184 Mar 13 '16 at 19:40
  • 1
    I tried clearing out my gwt-unitCache files but it didn't fix it. Then this morning I tried creating a new workspace and importing the same code and that fixed my problem. – Zip184 Mar 14 '16 at 12:27
  • Sorry new "project" not workspace – Zip184 Mar 14 '16 at 12:48

1 Answers1

1

I fixed the problem by creating a new Eclipse project and importing the same code. This was probably some type of caching issue, but cleaning out my gwt-unitCache directory did not fix it.

Zip184
  • 1,792
  • 2
  • 21
  • 34