Google Groups

[2.1-RC1] java.lang.NoClassDefFoundError running in dev mode (prod mode fine) using Jackson


Humphrey Sheil Dec 2, 2012 5:50 AM
Posted in group: play-framework

Hi

We've upgraded one of our Java applications to 2.1-RC1. We've been mostly successful apart from one issue:

When running in dev mode, classes that live under the app/ folder are no longer found by / available to the Jackson class loader at runtime, resulting in a java.lang.NoClassDefFoundError (see a sample stacktrace below). In this particular use case, the controller has a static block that is executed when the class is first initialised - this static block reads some data from Mongo and attempts to de-serialise it into regular POJOs using Jackson. We're using Jackson 2.0.4 - the POJOs themselves use the @JsonProperty and @JsonTypeInfo annotations imported from com.fasterxml.jackson.annotation.*.

This error does not occur when running in production mode. We're not currently explicitly referencing any classes living under the app/ folder as dependencies of our application in Build.scala - just the javaCore module.

Any tips / pointers appreciated (at the moment I'm planning to dig into any classloader changes made between 2.0.x and 2.1-RC1 as well as any Play <-> Jackson changes in 2.1).

We also found and fixed a few minor config things around getting the jenkins CI server to build our project using sbt 0.12.0 that we'll document and publish.

Humphrey


! @6cg0b89hh - Internal server error, for (GET) [/intelligence] ->

play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class controllers.IntelligenceController]]
        at play.api.Application$class.handleError(Application.scala:279) ~[play_2.10.jar:2.1-RC1]
        at play.api.DefaultApplication.handleError(Application.scala:373) [play_2.10.jar:2.1-RC1]
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:112) [play_2.10.jar:2.1-RC1]
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:108) [play_2.10.jar:2.1-RC1]
        at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:110) [play_2.10.jar:2.1-RC1]
        at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:110) [play_2.10.jar:2.1-RC1]
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class controllers.IntelligenceController
        at play.libs.F$Promise$6.apply(F.java:377) ~[play_2.10.jar:2.1-RC1]
        at scala.concurrent.Future$$anonfun$map$1.liftedTree2$1(Future.scala:253) ~[scala-library.jar:na]
        at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:251) ~[scala-library.jar:na]
        at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:249) ~[scala-library.jar:na]
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:29) ~[scala-library.jar:na]
        at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.liftedTree1$1(BatchingExecutor.scala:67) ~[akka-actor_2.10.0-RC1.jar:na]