Just to let you know: this was a really bad - homegrown - thing. Nothing with buildr and nothing with scala.
Sorry for disturbing,
cheers,
Martin
PS: For those that are really interested: There was a teardown method
that - in simple words - deleted everything (recursively) from
getClass.getResource(".")
%$&#?!&
On Mon, 2009-08-10 at 16:36 +0200, Martin Grotzke wrote:
> Hi,
>
> we're just getting an exception when we use anonymous functions in
> scala:
>
> 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 java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>
> In line 32 there's an anonymous function passed to the filter method:
> val attachments: List[SourceDocument] = ...
> attachments.filter(_.mimeType.equals("image/png")).
>
> When the filter function is written with a while loop this does not
> happen:
> def filterByType(attachments: List[SourceDocument]):
> List[SourceDocument] = {
> var result = List[SourceDocument]()
> val elements = attachments.elements
> while(elements.hasNext) {
> val a = elements.next
> println("Have mimeType: " + a.mimeType)
> if ( a.mimeType.equals("") ) {
> result = a :: result
> }
> }
> 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 s.th. like this:
>
> @Test
> 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 s.th. similar.
>
> Btw: this does happen with and without fsc...
>
> Thanx && cheers,
> Martin
>
signature.asc
Description: This is a digitally signed message part
