0 Replies Latest reply on Sep 1, 2012 3:48 PM by maxant

    JBoss Scala Module, and NoClassDefFoundError when using parallel collections


      I created a JBoss Module (JBoss 7.1.1.Final) for Scala by creating a folder /modules/org/scala/main, put the scala-library.jar for Scala 2.9.2 in there, together with module.xml containing:

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="org.scala">
      <resource-root path="scala-library.jar"/>

      Then in my webapp, I added /WebContent/WEB-INF/jboss-deployment-structure.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <module name="org.scala" />

      Almost all of Scala works - and the nice thing is that I don't have to add the scala-library.jar to EVERY webapp.

      But, very strangely, when I try and call the following def, I get an error:

      def reserveOffer(event: EventOffer, tarifs: Seq[Tarif]) = {
      val reservations = tarifs.par.map{ t =>
      (t.bookingSystem) match {
      case Some(a) => a.reserveOffer(event, t)
      case _ => throw new
      "Unknown adapter " +

      The error is:

      Caused by: java.lang.NoClassDefFoundError: Could not initialize class scala.collection.parallel.package$
      at scala
      .collection.parallel.Combiner$class.$init$(Combiner.scala:37) [scala-library.jar:]
      at scala
      .collection.parallel.mutable.ResizableParArrayCombiner$$anon$1.<init>(ResizableParArrayCombiner.scala:96) [scala-library.jar:]
      at scala
      .collection.parallel.mutable.ResizableParArrayCombiner$.apply(ResizableParArrayCombiner.scala:96) [scala-library.jar:]
      at scala
      .collection.parallel.mutable.ResizableParArrayCombiner$.apply(ResizableParArrayCombiner.scala:98) [scala-library.jar:]
      at scala
      .collection.parallel.mutable.ParSeq$.newCombiner(ParSeq.scala:58) [scala-library.jar:]
      at scala
      .collection.mutable.SeqLike$class.parCombiner(SeqLike.scala:27) [scala-library.jar:]
      at scala
      .collection.mutable.ListBuffer.parCombiner(ListBuffer.scala:44) [scala-library.jar:]
      at scala
      .collection.Parallelizable$class.par(Parallelizable.scala:40) [scala-library.jar:]
      at scala
      .collection.mutable.ListBuffer.par(ListBuffer.scala:44) [scala-library.jar:]
      at ch
      .maxant.scalabook.services.EventService.reserveOffer(EventService.scala:190) [classes:]

      Line 190 of EventService is:

          val reservations = tarifs.par.map{ t =>

      I.e. the method call to create the parallel sequence is causing the exception.

      If I don't use the JBoss module, and I stick the scala-library.jar into WEB-INF/lib, then I don't have this problem.

      I suspect its related to the classloading in modules, but I have no idea where to fix it, or if it is a bug in JBoss Modules?

      The question is: can anyone give me any solution, or is this a known problem?