Skip to main content

NullPointerException When Trying to Start Test Suite

5 replies [Last post]
laguz
Offline
Joined: 2008-03-29
Points: 0

Hi everybody,

I am working on a test suite for jsr321 and I decided to use jtharness. For some reasons I would like to use junit-style test cases. Unfortunately I get a very weird NullPointerException when I try to start my tests:

Exception in thread "Harness:Worker" java.lang.NullPointerException
at com.sun.javatest.junit.JUnitTestRunner.setClassLoader(JUnitTestRunner.java:88)
at com.sun.javatest.junit.JUnitTestSuite.createTestRunner(JUnitTestSuite.java:53)
at com.sun.javatest.Harness.runTests(Harness.java:697)
at com.sun.javatest.Harness.access$000(Harness.java:44)
at com.sun.javatest.Harness$1.run(Harness.java:566)

Does anybody know something about that?

I could solve this problem by extending the JUnitTestSuite and overriding the method getClassLoader with the following code:

@Override
public ClassLoader getClassLoader() {
ClassLoader loader = super.getClassLoader();

return loader != null ? loader : this.getClass().getClassLoader();
}

That way I was able to solve the problem but shouldn't there always be a classloader available?

Regards,
laguz

Message was edited by: laguz

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bkurotsu
Offline
Joined: 2004-12-13
Points: 0

That is strange. What platform and JVM are you running on?

Everything else works fine if you use your workaround?

laguz
Offline
Joined: 2008-03-29
Points: 0

In the first place I'd like to thank you for your answer...

Concerning your questions:
I run a linux machine (ubuntu 8.04). I have installed Java 1.6.0_06 and JT Harness 4.1.4 MR1 b17.

I am not sure if everything else works fine. I cannot set the classpath for the tests from within jt harness. I must start it with the classpath which is need by the test classes. I assume that this behavior is not quite right but I am not sure. However, I could cope with this error much more easier.

Thanks!
laguz

Message was edited by: laguz

Message was edited by: laguz

bkurotsu
Offline
Joined: 2004-12-13
Points: 0

I will have to test it on Linux to see if there is a problem there. Our standard testing uses Java 5, since that is the minimal level that we allow for the harness.

For classpath, I'm not sure what you meant, but did you set the classpath value in your .jtt file? This is the intended method for specifying the location for the test class files.

Brian

laguz
Offline
Joined: 2008-03-29
Points: 0

I did test it with Java 5 and Java 6. The problem remains the same. :-(

Regarding the classpath ...
What I meant is the configuration of the classpath during the configuration interview.
But I did try to configure the classpath using the jtt file as well. Under these circumstances I got a different problem. The configured classpath does not seem to be used. Maybe I do it the wrong way.
In my jtt file it looks like this:
[i]classpath = ./bin/;./lib/first.jar;./lib/second.jar[/i]
Is the syntax correct?

regards,
laguz

bkurotsu
Offline
Joined: 2004-12-13
Points: 0

Ah! Sorry for the delay.

No, your classpath is wrong. Items must be whitespace separated. I suggest reading the Architect's Guide for all the background info.

Available on this page:
https://jtharness.dev.java.net/jt_docs.html