Leda + scala 2.10.0-M4/M5: How to rebuild/compile?

Hi,

When trying to rebuild my project with scala version 2.10.0-M4 or -M5 I get the following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/internal/Trees at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
 at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
 at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
 at java.lang.Class.getDeclaredMethods0(Native Method)
 at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
 at java.lang.Class.getMethod0(Class.java:2670)
 at java.lang.Class.getMethod(Class.java:1603)
 at org.jetbrains.plugins.scala.compiler.rt.ClassRunner.main(ClassRunner.java:45)
Caused by: java.lang.ClassNotFoundException: scala.reflect.internal.Trees
 at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
 ... 29 more



Is this related to this issue?:
http://www.assembla.com/spaces/scala-ide/support/tickets/1000425-error-while-editing-source-code---error-during-askoption

I can recompile with sbt-idea with no problems but would like to able to rebuild with IDEA. When rebuilding with scala 2.10.0-M3 it works.

Any idea what is/I do wrong?

Thanks,
Marc
3 comments
Comment actions Permalink

When you know it, it's simple:

Make sure the following jar's are included in the library  used by the IDEA compiler (fsc/ordinary):

scala-compiler.jar
scala-library.jar
scala-reflect.jar

I was missing the scala-reflect.jar (apparently needed since the big reflection refactoring in scala_2.10.0-M4)

For other newbies :)
- File > Project Structure > Libraries
- Click the scala library that Intellij uses to compile scala, ie scala-2.10.0-M5
- Click "+" in the bottom of the rigth window to "Attach Files or Directories" and locate "scala-reflect.jar" in your file system (mine was here: /Users/marcgrue/.sbt/boot/scala-2.10.0-M5/lib/scala-reflect.jar)
- Click Ok. Now Build > Rebuild Project should work

Cheers,
Marc

0
Comment actions Permalink

For me the problem goes on... but I am using maven to build the application.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <artifactId>life</artifactId>
        <groupId>br.com.requisito</groupId>
        <version>0.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>life.domain</artifactId>
    <version>${parent.version}</version>

    <dependencies>
        <dependency>
            <groupId>br.com.requisito</groupId>
            <artifactId>life.core</artifactId>
            <version>0.2</version>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.reflections</groupId>
            <artifactId>reflections</artifactId>
            <version>0.9.8</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.gemini.blueprint</groupId>
            <artifactId>gemini-blueprint-core</artifactId>
            <version>1.0.0.RELEASE</version>
        </dependency>

        <!-- SCALA RUNTIME -->

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-compiler</artifactId>
            <version>${scala.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-reflect</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <!-- PERSISTENCE -->

        <dependency>
            <groupId>org.hibernate.java-persistence</groupId>
            <artifactId>jpa-api</artifactId>
            <version>2.0-cr-1</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.0.1.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.0.1.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.167</version>
        </dependency>

        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jandex</artifactId>
            <version>1.0.3.Final</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml</groupId>
            <artifactId>classmate</artifactId>
            <version>0.5.4</version>
        </dependency>

        <!-- TESTING -->

        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.version}</artifactId>
            <version>1.9-2.10.0-M5-B2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/scala</sourceDirectory>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.15.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>${scala.version}</scalaVersion>
                </configuration>
            </plugin>

<!--             <plugin> -->
<!--                 <groupId>org.apache.maven.plugins</groupId> -->
<!--                 <artifactId>maven-dependency-plugin</artifactId> -->
<!--                 <version>2.4</version> -->
<!--                 <dependencies> -->

<!--                 </dependencies> -->
<!--                 <executions> -->
<!--                     <execution> -->
<!--                         <id>compile-dependency-copy</id> -->
<!--                         <phase>package</phase> -->
<!--                         <goals> -->
<!--                             <goal>copy-dependencies</goal> -->
<!--                         </goals> -->
<!--                     </execution> -->
<!--                 </executions> -->
<!--                 <configuration> -->
<!--                     <outputDirectory>${project.build.directory}/libs/</outputDirectory> -->
<!--                 </configuration> -->
<!--             </plugin> -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>false</downloadSources>
                    <buildcommands>
                        <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
                    </buildcommands>
                    <additionalProjectnatures>
                        <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
                    </additionalProjectnatures>
                    <classpathContainers>
                        <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
                        <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
                    </classpathContainers>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


The problem:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/tools/nsc/io/Streamable$Bytes at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
 at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
 at java.lang.Class.getDeclaredMethods0(Native Method)
 at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
 at java.lang.Class.getMethod0(Class.java:2685)
 at java.lang.Class.getMethod(Class.java:1620)
 at org.jetbrains.plugins.scala.compiler.rt.ClassRunner.main(ClassRunner.java:45)
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.io.Streamable$Bytes
 at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
 ... 17 more

0
Comment actions Permalink

Please try the newest Scala plugin build (0.7.58).

0

Please sign in to leave a comment.