0

I am trying to build a website with playframework and Java, and the current play version is 2.8.15.

I got a NoSuchMethodError runtime error (when responding to a simple request) but cannot tell where the error is located from the stack trace. I failed to find any related documents on the Internet. Any one can give a hint?

Update

It looks like the error was not caused by the code, but putting a JAR into /lib folder. Does play have special requirements of the unmanaged dependencies?
  Unexpected exception
    NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V

  No source available, here is the exception stack trace:
    ->java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
  com.google.inject.Key.ensureRetainedAtRuntime(Key.java:349)
  com.google.inject.Key.strategyFor(Key.java:325)
  com.google.inject.Key.get(Key.java:232)
  play.api.inject.guice.GuiceKey$.apply(GuiceInjectorBuilder.scala:416)
  play.api.inject.guice.GuiceableModuleConversions$$anon$4.$anonfun$configure$2(GuiceInjectorBuilder.scala:376)
  play.api.inject.guice.GuiceableModuleConversions$$anon$4.$anonfun$configure$2$adapted(GuiceInjectorBuilder.scala:374)
  scala.collection.immutable.List.foreach(List.scala:333)
  play.api.inject.guice.GuiceableModuleConversions$$anon$4.configure(GuiceInjectorBuilder.scala:374)
  com.google.inject.AbstractModule.configure(AbstractModule.java:61)
  com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:347)
  com.google.inject.spi.Elements.getElements(Elements.java:104)
  com.google.inject.util.Modules$OverrideModule.configure(Modules.java:214)
  com.google.inject.AbstractModule.configure(AbstractModule.java:61)
  com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:347)
  com.google.inject.spi.Elements.getElements(Elements.java:104)
  com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:137)
  com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:105)
  com.google.inject.Guice.createInjector(Guice.java:87)
  com.google.inject.Guice.createInjector(Guice.java:78)
  play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:200)
  play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:155)
  play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
  play.core.server.DevServerStart$$anon$1.$anonfun$reload$2(DevServerStart.scala:193)
  play.utils.Threads$.withContextClassLoader(Threads.scala:22)
leetom
  • 723
  • 1
  • 6
  • 27
  • This would typically mean that the appoporiate library was missing from your project, see here: [java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument](https://stackoverflow.com/questions/42206440/java-lang-nosuchmethoderror-com-google-common-base-preconditions-checkargument) Please edit your question to include your dependencies/libraries and their version numbers or check yourself that they are all compatible (use the latest?) – sorifiend Apr 07 '22 at 05:03
  • @sorifiend Thank you, I am using Play framework and it comes with `guice` and other dependencies. The code used to work fine, but after I added some controllers and jobs, it won't work and don't give any clue where the error comes from. – leetom Apr 07 '22 at 05:50
  • I am not sure what you mean by "controllers and jobs", but I suggest rolling back the changes until you get a working version, then re-add the new bits one at a time to isolate what broke it. It may very well just be a mismatch between two library versions, see here for more info: https://stackoverflow.com/questions/35186/how-do-i-fix-a-nosuchmethoderror – sorifiend Apr 07 '22 at 05:53
  • Another good way to diagnose this is to create a new very simple stand-alone project with the same framework and see if that works, and then compare the dependencies to your own project. – sorifiend Apr 07 '22 at 05:54
  • @sorifiend I have already commented all the new code, and the error is still there. That's why I feel so frustrated with this framework. I might have to start over with a new empty project, or just give up with this framework. – leetom Apr 07 '22 at 06:17

0 Answers0