Using Google Caliper with Scala - scala

I am trying to use Caliper with Scala(2.10) in Eclipse Juno(4.2). For the start I've set up a benchmark that simply iterates a foreachloop over an array.
import com.google.caliper.Param
import com.google.caliper.SimpleBenchmark
class Benchmark extends SimpleBenchmark {
#Param(Array("10", "100", "1000", "10000"))
val length: Int = 0
var array: Array[Int] = _
override def setUp() {
array = new Array(length)
}
def timeForeach(reps: Int) = {
var result = 0
array.foreach {
result += _
}
result
}
When I start the benchmark with:
object myRunner {
def main(args: Array[String]) {
Runner.main(classOf[Benchmark], args)
}
}
I get these exceptions that I dont understand
0% Scenario{vm=java, trial=0, benchmark=Foreach, length=10} Failed to execute java -cp C:\Users\bob\workspace\myBenchmark\bin;C:\Users\bob\workspace\caliper\caliper\target>\classes;C:\Users\bob\workspace\caliper\caliper\target\test-classes;C:\Users\bob\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\bob\.m2\repository\com\google\code\gson\gson\1.7.1\gson-1.7.1.jar;C:\Users\bob\.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar;C:\Users\bob\.m2\repository\com\google\code\java-allocation-instrumenter\java-allocation-instrumenter\2.0\java-allocation-instrumenter-2.0.jar;C:\Users\bob\.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-analysis\3.3.1\asm-analysis-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-commons\3.3.1\asm-commons-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-tree\3.3.1\asm-tree-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-util\3.3.1\asm-util-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-xml\3.3.1\asm-xml-3.3.1.jar;C:\Users\bob\.m2\repository\junit\junit\3.8.2\junit-3.8.2.jar com.google.caliper.InProcessRunner --warmupMillis 3000 --runMillis 1000 --measurementType TIME --marker //ZxJ/ -Dbenchmark=Foreach -Dlength=10 org.example.Benchmark
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function1
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.caliper.ScenarioSelection.getClassByName(ScenarioSelection.java:154)
at com.google.caliper.ScenarioSelection.prepareSuite(ScenarioSelection.java:123)
at com.google.caliper.ScenarioSelection.select(ScenarioSelection.java:83)
at com.google.caliper.InProcessRunner.run(InProcessRunner.java:38)
at com.google.caliper.InProcessRunner.main(InProcessRunner.java:103)
Caused by: java.lang.ClassNotFoundException: scala.Function1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
An exception was thrown from the benchmark code.
com.google.caliper.ConfigurationException: Failed to execute java -cp C:\Users\bob\workspace\myBenchmark\bin;C:\Users\bob\workspace\caliper\caliper\target\classes;C:\Users\bob\workspace\caliper\caliper\target\test-classes;C:\Users\bob\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\bob\.m2\repository\com\google\code\gson\gson\1.7.1\gson-1.7.1.jar;C:\Users\bob\.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar;C:\Users\bob\.m2\repository\com\google\code\java-allocation-instrumenter\java-allocation-instrumenter\2.0\java-allocation-instrumenter-2.0.jar;C:\Users\bob\.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-analysis\3.3.1\asm-analysis-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-commons\3.3.1\asm-commons-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-tree\3.3.1\asm-tree-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-util\3.3.1\asm-util-3.3.1.jar;C:\Users\bob\.m2\repository\asm\asm-xml\3.3.1\asm-xml-3.3.1.jar;C:\Users\bob\.m2\repository\junit\junit\3.8.2\junit-3.8.2.jar com.google.caliper.InProcessRunner --warmupMillis 3000 --runMillis 1000 --measurementType TIME --marker //ZxJ/ -Dbenchmark=Foreach -Dlength=10 org.example.Benchmark
at com.google.caliper.Runner.measure(Runner.java:309)
at com.google.caliper.Runner.runScenario(Runner.java:229)
at com.google.caliper.Runner.runOutOfProcess(Runner.java:378)
at com.google.caliper.Runner.run(Runner.java:97)
at com.google.caliper.Runner.main(Runner.java:423)
at com.google.caliper.Runner.main(Runner.java:436)
at org.example.myRunner$.main(myRunner.scala:7)
at org.example.myRunner.main(myRunner.scala)
I think I have some issues with the classpath but i am not sure.
I hope someone can help me :)
thanks in advance
Davram Bashere

It looks very much as though Caliper is running a new JVM and doesn't know that it needs to include the Scala libraries on the classpath.
This question describes how to run a Scala app with the java command on the command line. It should be a good starting point to solving this problem.

Even if you are editing scala sources in Eclipse you may still use sbt to run your code. Sbt is a great tool for managing your projects classpath in addition to providing a plugin system for providing the kinds of features like running Caliper benchmarks. I recently worked on a project where I needed just that and factored it out into an published sbt plugin. This may be of some help for you as well.

Thanks for your help. The problem was as expected the stupid classpath. I have downloaded the caliper project from googlecode and added the scala dependency. Now I've build my own jar-with-dependencies and it works quite fine.
Thanks for the answeres anyway :-)

Related

java.lang.NoClassDefFoundError while compile simple program scala

I have a issue with my really simple project in Scala:
Error:scalac: Error: Could not initialize class com.sun.jna.platform.win32.WinBase$FILETIME
java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.platform.win32.WinBase$FILETIME
at sbt.internal.io.WinMilli$.toNative(Milli.scala:310)
at sbt.internal.io.WinMilli$.toNative(Milli.scala:259)
at sbt.internal.io.MilliNative.setModifiedTime(Milli.scala:68)
at sbt.internal.io.Milli$.setModifiedTime(Milli.scala:354)
at sbt.io.IO$.setModifiedTimeOrFalse(IO.scala:1234)
at sbt.io.IO$.next$1(IO.scala:309)
at sbt.io.IO$.extract(IO.scala:317)
at sbt.io.IO$.$anonfun$unzipStream$1(IO.scala:281)
at sbt.io.Using.apply(Using.scala:22)
at sbt.io.IO$.unzipStream(IO.scala:281)
at sbt.io.IO$.$anonfun$unzip$1(IO.scala:264)
at sbt.io.Using.apply(Using.scala:22)
at sbt.io.IO$.unzip(IO.scala:264)
at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$3(AnalyzingCompiler.scala:338)
at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:126)
at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:122)
at scala.collection.immutable.List.foldLeft(List.scala:89)
at scala.collection.TraversableOnce.$div$colon(TraversableOnce.scala:154)
at scala.collection.TraversableOnce.$div$colon$(TraversableOnce.scala:154)
at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:108)
at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2(AnalyzingCompiler.scala:337)
at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2$adapted(AnalyzingCompiler.scala:335)
at sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
at sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
at sbt.internal.inc.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:335)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$.org$jetbrains$jps$incremental$scala$local$CompilerFactoryImpl$$getOrCompileInterfaceJar(CompilerFactoryImpl.scala:123)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.$anonfun$getScalac$1(CompilerFactoryImpl.scala:55)
at scala.Option.map(Option.scala:163)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.getScalac(CompilerFactoryImpl.scala:47)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.createCompiler(CompilerFactoryImpl.scala:25)
at org.jetbrains.jps.incremental.scala.local.CachingFactory.$anonfun$createCompiler$3(CachingFactory.scala:24)
at org.jetbrains.jps.incremental.scala.local.Cache.$anonfun$getOrUpdate$2(Cache.scala:20)
at scala.Option.getOrElse(Option.scala:138)
at org.jetbrains.jps.incremental.scala.local.Cache.getOrUpdate(Cache.scala:19)
at org.jetbrains.jps.incremental.scala.local.CachingFactory.createCompiler(CachingFactory.scala:24)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:34)
at org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:117)
at org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:109)
at org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:95)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:53)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Here you can find code:
object Task1 {
def main(args: Array[String]) {
val dayOfWeeks = List("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
for (e <- dayOfWeeks) println(e + ";")
}
}
Do you have any idea? I tried to uninstall the plugin and rebuild the project but nothing. I installed plugin property and will try with first project in Scala but I faced this error code.
I found the solution after many trials and errors. You need to run the development environment (in my case Intellij) as an administrator. After that you need to re-create or rebuild the project and everything should be fine.

Why the error is displayed as java.lang.ClassNotFoundException: for the following groovy code?

class First {
public First() {
super()
// TODO Auto-generated constructor stub
}
static void main(String s)
{
print('Hii');
}
}
After running the code in eclipse using Groovy Console option the following exception is being shown.
java.lang.ClassNotFoundException: groovy.ui.Console
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
Nothing wrong with the code. Groovy Console dependencies are not included by default with Groovy 2.5+ You can use Groovy 2.4 which bundles groovy-all or run as Java Application since you have a class with a main method.

Strange exception using Jersey with embedded Jetty

I have created an embedded Jetty application which utilizes Jersey in order to implement several RESTful services. I am using some standard code as described here in Stack Overflow as well as other websites:
public static void main(String[] args)
{
Server server = new Server(8080);
ServletContextHandler ctx = new ServletContextHandler(
ServletContextHandler.SESSIONS);
ctx.setContextPath("/");
ServletHolder holder = ctx.addServlet(
"org.glassfish.jersey.servlet.ServletContainer.class", "/*");
holder.setInitOrder(0);
holder.setInitParameter("jersey.config.server.provider.classnames",
RestfulClass.class.getCanonicalName());
server.setHandler(ctx);
try
{
server.start();
server.join();
}
catch(Exception exe)
{
exe.printStackTrace();
}
}
I've used all the recommended jar files, and several other jar files that the various blogs and sites failed to mention. When running the Jetty application, I get the following exception:
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
<several lines omitted for brevty>
Caused by: javax.servlet.UnavailableException: org.glassfish.jersey.servlet.ServletContainer.class
at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:102)
at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:874)
... 11 more
It is the "UnavailableException" that I do not understand. The ServletContainer class is actually in one of the Jar files (in jersey-container-servlet-core.jar, to be precise), but for some reason it is identified as "unavailable". This is causing a class that is actually in a referenced Jar file to be "not found"!
Can anyone tell me what is causing this UnavailableException and (more importantly) how I can prevent it from being thrown?
Someone please advise...
ServletHolder holder = ctx.addServlet(
"org.glassfish.jersey.servlet.ServletContainer.class", "/*");
You are using a String for the class name. When doing this, you don't use the .class suffix. That at only when you want to get the actual Class object. You have two options
Remove the .class from the String
ServletHolder holder = ctx.addServlet(
"org.glassfish.jersey.servlet.ServletContainer", "/*");
Remove the "" (double quotes) and just use the Class object1.
ServletHolder holder = ctx.addServlet(
org.glassfish.jersey.servlet.ServletContainer.class, "/*");
1 - See addServlet(Class, String)

Running Scala tests in Intellij

I am trying to run Scala tests (specs2) in Intellij Coummunity Edition 13.1.3. I am getting the following error:
Connected to the target VM, address: '127.0.0.1:57980', transport: 'socket'
'Start' method is not found in MyNotifierRunner null
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Disconnected from the target VM, address: '127.0.0.1:57980', transport: 'socket'
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:123)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:69)
Caused by: java.lang.NoSuchMethodError: org.specs2.matcher.MatchResult$.matchResultAsResult()Lorg/specs2/execute/AsResult;
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply$mcV$sp(ReportsDemographicsComponentTest.scala:14)
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
at org.specs2.mutable.SideEffectingCreationPaths$$anonfun$executeBlock$1.apply$mcV$sp(FragmentsBuilder.scala:292)
at org.specs2.mutable.SideEffectingCreationPaths$class.replay(FragmentsBuilder.scala:264)
at org.specs2.mutable.Specification.replay(Specification.scala:12)
at org.specs2.mutable.FragmentsBuilder$class.fragments(FragmentsBuilder.scala:27)
at org.specs2.mutable.Specification.fragments(Specification.scala:12)
at org.specs2.mutable.SpecificationLike$class.is(Specification.scala:14)
at org.specs2.mutable.Specification.is(Specification.scala:12)
at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
at org.specs2.specification.SpecificationStructure$class.map(BaseSpecification.scala:44)
at org.specs2.mutable.Specification.map(Specification.scala:12)
at org.specs2.specification.SpecificationStructure$class.content(BaseSpecification.scala:56)
at org.specs2.mutable.Specification.content$lzycompute(Specification.scala:12)
at org.specs2.mutable.Specification.content(Specification.scala:12)
at org.specs2.runner.ClassRunner$$anonfun$apply$1$$anonfun$apply$2.apply(ClassRunner.scala:54)
at org.specs2.runner.ClassRunner$$anonfun$apply$1$$anonfun$apply$2.apply(ClassRunner.scala:54)
at org.specs2.control.Exceptions$class.tryo(Exceptions.scala:32)
at org.specs2.control.Exceptions$.tryo(Exceptions.scala:109)
at org.specs2.runner.ClassRunner$$anonfun$apply$1.apply(ClassRunner.scala:54)
at org.specs2.runner.ClassRunner$$anonfun$apply$1.apply(ClassRunner.scala:53)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
at org.specs2.runner.ClassRunner.apply(ClassRunner.scala:53)
at org.specs2.runner.ClassRunner.start(ClassRunner.scala:31)
at org.specs2.runner.ClassRunner.main(ClassRunner.scala:24)
at org.specs2.runner.NotifierRunner.main(NotifierRunner.scala:24)
... 6 more
Process finished with exit code 1
Here is piece of code runnig in sbt, but failing in Intellij:
class ReportsDemographicsComponentTest extends Specification with ReportsComponents {
"ReportsDemographicsComponent" should {
s"return empty list of $DeviceStatistics for an inexistent deliveryId" in DBUnitTestsUtils(2) {
accountId => implicit session =>
val service = new ReportsDemographicsService(accountId)
val res = service.deviceStatistics(-1)
res.size mustEqual 0
}
}
I have tried restarting Intellij, sbt, cleaning project, but to nu success. When running tests from the sbt command line, everything is OK.
In my case closing Idea and regenerating the projec setup by issuing
sbt gen-idea
Note:
You have to put this line into project/plugins.sbt to have the command:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

Getting exception in initializing log4j files

When trying to initialize hibernate from configuration file, I get NullPointerException ..
Root cause is shown as
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
I have all the logging related jars and properties files in class path.
My hibernate initialization code is :
private static final SessionFactory sessionFactory;
private static final ThreadLocal<Session> hibernateSession=new ThreadLocal<Session>();
static{
try{
sessionFactory=new Configuration().configure("llhs_hibernate.cfg.xml").buildSessionFactory();
System.out.println("done");
}catch (HibernateException he){
he.printStackTrace();
throw new ExceptionInInitializerError(he);
}catch (Exception e){
e.printStackTrace();
throw new ExceptionInInitializerError(e);
}
Simple java classes does not complain about log related error, for example following java class does not complain ..It properly initializes and writes to logs folder
public class MetadataService implements Serializable {
private static final Logger logger = LogManager.getLogger(MetadataService.class);
private static final long serialVersionUID = 1L;
public MetaData getMetaData(){
logger.info("Info");
try {
//some code here
} catch (Exception e1) {
logger.error("Error");
}
return metaData;
}
Since it works for stand alone Java class and not for class doing hibernate initialization --I am more perplexed ..Any pointer? Detailed trace
java.lang.ExceptionInInitializerError
at com.llhs.persistence.impl.db.hibernate.utils.HibernateUtils.<clinit>(HibernateUtils.java:17)
at com.llhs.persistence.impl.hibernate.HibernateDbImplTest.addStudentDetails(HibernateDbImplTest.java:61)
at com.llhs.persistence.impl.hibernate.HibernateDbImplTest.testAddFindStudentDetails(HibernateDbImplTest.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException(Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:126)
... 26 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 30 more
Caused by: java.lang.NullPointerException
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
... 31 more
There is alignment issue while posting trace, sorry abt that, not able to correct that one..
Finally, I was able to solve this. As later guessed it turned out to be an eclipse configuration. In eclipse 3.7, code name indigo, the way libs were being added to the classpath caused this issue ..
First way:
Debug Configurations->classpath->bootstarp entries, if Add libs added by selecting "Add Jars" options, THIS DOES NOT Work.
Correct WAY:
Define a classpath variable from window->preferences->java->buildpath->classpath variable, say HIBERNATE_LIBS and point it ti libs folder
Now, got to Debug Configurations->classpath->bootstarp entries, select "Advanced option" and add the class path variable. This FIXED the issue.
I guess this is specific to 3.7, as I upgraded the eclipse version and started getting this issue, First way still works in eclipse 3.2