Scala 2.10.0 generates a class-not-found error for scala.reflect.ClassManifest

5,634 views
Skip to first unread message

glsil...@pssd.com

unread,
Jan 29, 2013, 3:13:27 PM1/29/13
to scala...@googlegroups.com
I created a maven project using the camel-scala-archetype archetype. Running mvn exec:java works fine out-of-the box, but when I change the scala version to 2.10.0 in the pom.xml file, I get the following error:

Caused by: java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
at com.dsi.mytest.MyRouteMain$.main(MyRouteMain.scala:31)
at com.dsi.mytest.MyRouteMain.main(MyRouteMain.scala)
... 6 more
Caused by: java.lang.ClassNotFoundException: scala.reflect.ClassManifest
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 java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 8 more

I haven't found anything on other forums or searching through the various Google results on this error that is helpful in resolving it. Does anyone have a solution? 

Eugene Burmako

unread,
Jan 29, 2013, 3:25:52 PM1/29/13
to glsil...@pssd.com, scala-user
Could you please show full stack trace? Also it'd be helpful if you published the pom.xml file, namely the dependency section.


--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

glsil...@pssd.com

unread,
Jan 29, 2013, 4:09:29 PM1/29/13
to scala...@googlegroups.com, glsil...@pssd.com
Yes, here is the pom.xml (the dependencies and build sections):
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<camel.version>2.10.0</camel.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-scala</artifactId>
<version>${camel.version}</version>
</dependency>

<!-- scala -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.0</version>
</dependency>

<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>

<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>${camel.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>

<plugins>

<!-- the Maven compiler plugin will compile Java source files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

<!-- the Maven Scala plugin will compile Scala source files -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- configure the eclipse plugin to generate eclipse project descriptors 
for a Scala project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<projectnatures>
<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
</projectnatures>
<buildcommands>
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
</buildcommands>
<classpathContainers>
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
</classpathContainers>
</configuration>
</plugin>

<!-- allows the route to be run via 'mvn exec:java' -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.dsi.mytest.MyRouteMain</mainClass>
</configuration>
</plugin>
</plugins>
</build>

 

And here is the full stack trace:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project mytest: An exception occured while executing the Java class. null: InvocationTargetException: scala/reflect/ClassManifest: scala.reflect.ClassManifest -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project mytest: An exception occured while executing the Java class. null
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. null
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:352)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
at com.dsi.mytest.MyRouteMain$.main(MyRouteMain.scala:31)
at com.dsi.mytest.MyRouteMain.main(MyRouteMain.scala)
... 6 more
Caused by: java.lang.ClassNotFoundException: scala.reflect.ClassManifest
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 java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 8 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[                      Thread-1] MainSupport$HangupInterceptor  INFO  Received hang up - stopping the main instance.
[                      Thread-1] MainSupport                    INFO  Apache Camel 2.10.0 stopping
[                      Thread-1] MainSupport$HangupInterceptor  WARN  Error during stopping the main instance.
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)[:1.6.0_26]
at java.util.ArrayList.get(ArrayList.java:322)[:1.6.0_26]
at org.apache.camel.main.Main.doStop(Main.java:114)[camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.support.ServiceSupport.stop(ServiceSupport.java:91)[camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.main.MainSupport$HangupInterceptor.run(MainSupport.java:80)[camel-core-2.10.0.jar:2.10.0]

Eugene Burmako

unread,
Jan 30, 2013, 3:59:02 AM1/30/13
to glsil...@pssd.com, scala-user
Could you please expand this part of the stack trace?


Caused by: java.lang.ClassNotFoundException: scala.reflect.ClassManifest
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 java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 8 more

Looks like one of your dependencies is incompatible with 2.10, but I can't yet see which one exactly from the stack trace.

Sonnenschein

unread,
Jan 30, 2013, 4:04:18 AM1/30/13
to scala...@googlegroups.com
This is probably because you have some dependencies compiled against Scala 2.9.x.
Peter

glsil...@pssd.com

unread,
Jan 30, 2013, 2:46:04 PM1/30/13
to scala...@googlegroups.com
How can I expand the stack trace. I'm just running mvn exec:java. Running it with -e or -X option doesn't expand the trace any. Is there some other command or option I can use?

Clint Gilbert

unread,
Jan 30, 2013, 3:08:57 PM1/30/13
to scala...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is almost certainly the culprit. I'd run

mvn dependency:tree

To see what's getting pulled in transitively. Something in there
somewhere depends on Scala 2.9.x.

I'd also check the build output carefully. Recent(ish) versions of
the Scala Maven plugin will warn if there are dependencies on more
than one version of Scala.

On 01/30/2013 04:04 AM, Sonnenschein wrote:
> This is probably because you have some dependencies compiled
> against Scala 2.9.x. Peter
>
> -- You received this message because you are subscribed to the
> Google Groups "scala-user" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
> scala-user+...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
>
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlEJfdkACgkQ5IyIbnMUeTseWACggqiAUMcylkRDSOXh0TwfVvyP
b2YAn3bgVR1buHcwmUNM9MKSXubDesmf
=zWwd
-----END PGP SIGNATURE-----

Lanny Ripple

unread,
Jan 30, 2013, 3:47:24 PM1/30/13
to scala...@googlegroups.com, glsil...@pssd.com
scala-reflect is packaged as its own jar.

Include org.scala-lang:scala-reflect:2.10.0 in your dependencies.

Eugene Burmako

unread,
Jan 30, 2013, 3:58:26 PM1/30/13
to Lanny Ripple, scala-user, glsil...@pssd.com
ClassTag (the replacement for ClassManifest) resides in scala-library.jar, so there's no need to depend on scala-reflect.jar unless you're using the newly introduced reflection framework.

Having someone requiring a classfile for scala.reflect.ClassManifest is a clear sign of that someone being compiled against Scala 2.9. In Scala 2.10 ClassManifest is an alias for ClassTag and, as such, doesn't have an underlying classfile.

glsil...@pssd.com

unread,
Jan 30, 2013, 4:00:24 PM1/30/13
to scala...@googlegroups.com, glsil...@pssd.com
scala-reflect jar doesn't include a scala.relect.ClassManifest class. The documentation for scala.reflec.ClassManifest says it is deprecated, since v 2.10.0. So I guess org.apache.camel.scala.dsl.builder.RouteBuilderSupport is incompatible with scala v 2.10.0. That means you can't write Camel routes using the Scala Camel DSL if you want to include the most recent Scala release. Not good, guys!

Eugene Burmako

unread,
Jan 30, 2013, 4:13:00 PM1/30/13
to glsil...@pssd.com, scala-user
Looks like camel-scala isn't going to work with the new release of Scala for quite a while: http://camel.465427.n5.nabble.com/Scala-DSL-with-Scala-2-10-td5724331.html.

Simon Ochsenreither

unread,
Jan 30, 2013, 4:15:59 PM1/30/13
to scala...@googlegroups.com, glsil...@pssd.com
Starting from version 2.11 Camel Scala DSL is compiled against Scala 2.10.
Support for Scala 2.9 is deprecated and will be removed starting from the Camel 2.12 and 3.0.
http://camel.apache.org/scala-dsl.html

Eugene Burmako

unread,
Jan 30, 2013, 4:18:11 PM1/30/13
to glsil...@pssd.com, scala-user
Oh wait I was too quick and misunderstood what's going on. It looks like the upcoming release of camel-scala 2.11 will be compiled against scala 2.10: https://issues.apache.org/jira/browse/CAMEL-6011.
Reply all
Reply to author
Forward
0 new messages