buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grotzke <>
Subject ClassNotFoundException with scala code: com.proj.module.SomeTest$$anonfun$1
Date Mon, 10 Aug 2009 14:36:54 GMT

we're just getting an exception when we use anonymous functions in

java.lang.NoClassDefFoundError: org/proj/module1/model/EmailMessageAttachmentsTest$$anonfun$filterByType$1
        at org.proj.module1.model.EmailMessageAttachmentsTest.filterByType(EmailMessageAttachmentsTest.scala:32)
        at org.proj.module1.model.EmailMessageAttachmentsTest.testExtractAttachmentsFrom_zipFile_containing_folders(EmailMessageAttachmentsTest.scala:66)
Caused by: java.lang.ClassNotFoundException: org.proj.module1.model.EmailMessageAttachmentsTest$$anonfun$filterByType$1
        at Method)
        at java.lang.ClassLoader.loadClass(
        at sun.misc.Launcher$AppClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClassInternal(

In line 32 there's an anonymous function passed to the filter method:
  val attachments: List[SourceDocument] = ...

When the filter function is written with a while loop this does not
  def filterByType(attachments: List[SourceDocument]):
List[SourceDocument] = {
    var result = List[SourceDocument]()
    val elements = attachments.elements
    while(elements.hasNext) {
      val a =
      println("Have mimeType: " + a.mimeType)
      if ( a.mimeType.equals("") ) {
        result = a :: result

It seems that this problem does only occur with our own types, and
perhaps only with types that reference types defined in another
submodule (build module in this case), that's referenced in the
buildfile via compile.with(projects("module2")). (I'm currently trying
to narrow this down)

What's definitely no problem is like this:

  def testAnonymousFunctionWithJustStrings {
    val attachments = List("foo", "bar")
    val filtered = attachments.filter(_.equals("foo"))
    assertEquals(filtered.size, 1)

This issue took already half of my day now, and I'm not sure if it's
somehow related to buildr or if it's just scala.

FWIW, I wanted to ask if somebody already experienced similar.

Btw: this does happen with and without fsc...

Thanx && cheers,

View raw message