Akka - verify installation - scala

I have installed Akka and need to verify whether the installation is successful. I simply used
akka -version
but this gave an error. What would be the reason? Does akka not supporting -version?
This is the error it is reporting
Starting Akka...
Running Akka 2.2.4
Exception in thread "main" java.lang.ClassNotFoundException: -version
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:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at akka.kernel.Main$$anonfun$1.apply(Main.scala:82)
at akka.kernel.Main$$anonfun$1.apply(Main.scala:82)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at akka.kernel.Main$.main(Main.scala:82)
at akka.kernel.Main.main(Main.scala)

Akka doesn't support the -version command. One way to find out if your installation works is running a simple boot class, as Akka suggests:
> akka
No boot classes specified
Usage: bin/akka org.somewhere.BootClass

Related

Mapreduce using Scala Error: java.lang.ClassNotFoundException: scala.Predef$

I tried to implement a simple mapreduce job through scala. However, when I run the package using the command,
hadoop jar hadoop.jar mapreduce.MaxTemperature hdfs://sandbox/user/ajay/input hdfs://sandbox/user/ajay/output
I get the error,
16/09/06 16:06:12 INFO mapreduce.Job: Task Id : attempt_1473177830264_0002_m_000001_2, Status : FAILED Error: java.lang.ClassNotFoundException: scala.Predef$
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at mapreduce.MaxTemperatureMapper.map(MaxTemperatureMapper.scala:17)
at mapreduce.MaxTemperatureMapper.map(MaxTemperatureMapper.scala:9)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
Even though I've added the scala-library to my class path, I get the above error.
hadoop version: Hadoop 2.7.1.2.3.0.0-255
scala version: 2.11.8
java version 1.7.0_85
Any suggestion is appreciated.
Apart from adding the scala library to the client's classpath, it has to be added to all nodes where the task gets executed. This can be achieved using the ToolRunner hadoop jar scala-2.11/hadoop_2.11-0.1.0.jar mapreduce.WordCount -libjars /usr/lib/scala-2.11.8/lib/scala-library.jar

Creating EPStatement in Esper by using Eclipse

I have the maven plug in installed on my Eclipse and added Esper jar to my library.
I tried to ran a simple example with Esper but I failed on the following code:
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
String expression = "select avg(price) from org.myapp.event.OrderEvent.win:time(30 sec)";
EPStatement statement = epService.getEPAdministrator().createEPL(expression);
And I got exception at createEPL(expression):
Exception in thread "main" java.lang.NoClassDefFoundError: org/antlr/v4/runtime/tree/Tree
at com.espertech.esper.core.service.EPAdministratorHelper.<clinit> (EPAdministratorHelper.java:43)
at com.espertech.esper.core.service.EPAdministratorImpl.createEPLStmt(EPAdministratorImpl.java:116)
at com.espertech.esper.core.service.EPAdministratorImpl.createEPL(EPAdministratorImpl.java:66)
at Main.main(Main.java:57)
Caused by: java.lang.ClassNotFoundException: org.antlr.v4.runtime.tree.Tree
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 4 more
It seems like that esper failed to find org/antlr/v4/runtime but I am pretty sure that this package is in the library.
Did I miss anything to run the code?
The jar file that is not in your classpath is antlr-runtime-4.1.jar, a required Esper dependency.

ClassNotFoundException when running integration tests with SBT when a library tries to access a class from another one

We have a complex Scala project using many different libraries from the Scala / Java world. We use lift-json for generating Json output from our data source. Sometimes, we need to cache some part of it to memcached. We use spymemcached for this. In some cases, we cache sequences of lift-json JObject in Memcached directly, without using any other abstraction over it.
This works great:
In production
When running integration tests from out IDE (IntelliJ)
On our staging environment
However, when running our integration tests using sbt it:test, We get the following exception from Spymemcached:
2013-03-07 13:26:04.393 WARN net.spy.memcached.transcoders.SerializingTranscoder: Caught CNFE decoding 4074 bytes of data
java.lang.ClassNotFoundException: net.liftweb.json.JsonAST$JObject
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 java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:622)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at scala.collection.immutable.$colon$colon.readObject(List.scala:404)
at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1872)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at net.spy.memcached.transcoders.BaseSerializingTranscoder.deserialize(BaseSerializingTranscoder.java:100)
at net.spy.memcached.transcoders.SerializingTranscoder.decode(SerializingTranscoder.java:66)
at net.spy.memcached.transcoders.TranscodeService$1.call(TranscodeService.java:42)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at net.spy.memcached.transcoders.TranscodeService$Task.run(TranscodeService.java:89)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Our tests are still running, so this is a low-priority bug. But we want to have our tests run in a environment as close as possible to production (where this actually works). I would like spymemcached to know about the existence of lift-json every time.
This looks like a classpath issue, but I have a hard-time finding exactly how to find this issue.

NoClassDefFoundError => ClassPath$JavaContext when using play start

I've made a little Scala, Play2.0.2 application.
It works fine when i use play run command, but when i use play start or play clean compile stage + target/start, when trying to do a MongoDB insertion with Casbah/Salat, i get the following stack:
[info] application - Can't create user
java.lang.NoClassDefFoundError: scala/tools/nsc/util/ClassPath$JavaContext
at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.scalaSigFromAttribute(ScalaSig.scala:35) ~[scalap-2.9.1.jar:na]
at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.parse(ScalaSig.scala:38) ~[scalap-2.9.1.jar:na]
at com.novus.salat.util.ScalaSigUtil$$anonfun$parseScalaSig0$2.apply(ScalaSigUtil.scala:73) ~[salat-util_2.9.1-0.0.8-SNAPSHOT.jar:0.0.8-SNAPSHOT]
at com.novus.salat.util.ScalaSigUtil$$anonfun$parseScalaSig0$2.apply(ScalaSigUtil.scala:73) ~[salat-util_2.9.1-0.0.8-SNAPSHOT.jar:0.0.8-SNAPSHOT]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
at com.novus.salat.util.ScalaSigUtil$.parseScalaSig0(ScalaSigUtil.scala:73) ~[salat-util_2.9.1-0.0.8-SNAPSHOT.jar:0.0.8-SNAPSHOT]
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.util.ClassPath$JavaContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_01]
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_01]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_01]
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_01]
at java.lang.ClassLoader.loadClass(ClassLoader.java:423) ~[na:1.7.0_01]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.7.0_01]
Any idea?
It seems the Scala compiler is needed by Scalap so i added the dependency:
"org.scala-lang" % "scala-compiler" % "2.9.1"
And it works fine.
Which leads me to another question:
Why do i need Scala compiler at runtime? (Play2/Salat with Scalap dependency)
The problem could also occur if you miss the Async support configuration when using Spring MVC in the context.xml

Error when run scala jar

When I run a scala jar, it throws the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: scala/ScalaObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
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)
at com.ebay.twitch.Main.main(Main.scala)
Caused by: java.lang.ClassNotFoundException: scala.ScalaObject
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)
... 13 more
But I check my jar that the scala-lang.jar is in the lib folder, so it should be in classpath. But why here it can not find it?
Jeff Zhang
Please read question classpath-including-jar-within-a-jar.
Sorry, I make a stupid mistake. Actually I run scala in hadoop, and call "hadoop -jar" rather than "hadoop jar", such a stupid mistake.