3

I was trying to create a Junit Testing framework within an existing RFT framework. The JUnit set up works fine to the point where we don't have to instantiate any framework classes.Whenever we are trying to access framework classes it throws the below exception. I did look for similar issues online but couldn't get a solution.Please suggest a solution if any body has faced a similar issue. RFT version is 8.1,JUnit version is 4

java.lang.NoClassDefFoundError: com.ibm.rational.test.lt.arm.IArmable
 at java.lang.ClassLoader.defineClass(ClassLoader.java:265)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:521)
 at java.net.URLClassLoader.access$300(URLClassLoader.java:66)
 at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:985)
Sameera
  • 31
  • 2

2 Answers2

1

I figured it out:

You have to add the jar "com.ibm.rational.test.lt.rftarm_8.2.1.v20120105_1832.jar" to your Java Build Path. Mine was located in C:/Program Files/IBM/IMShared/plugins/. It came with RFT, but appears to not have been included in the Build Path by default.

Yamikuronue
  • 746
  • 8
  • 37
0

This looks like a classpath error. If you are invoking JUnit from ANT, Maven, or some similar build tool then make sure you have the appropriate JAR files in the classpath. Remember, some JARS in turn have their own dependencies. Unless all those dependencies are in the classpath you will get the java.lang.NoClassDefFoundError.

If you are trying to run from the GUI client, it might be a little more difficult. Essentially, you will have to add all the dependencies to the jvm's -classpath option.

Berin Loritsch
  • 11,400
  • 4
  • 30
  • 57
  • I have the same issue; the classpath should be fine, given I can run the actual RFT tests. Is there a separate classpath for running as a JUnit test? – Yamikuronue Mar 26 '12 at 14:38
  • Unless the RFT you compiled against is different than what you are running against, NoClassDefFoundError is the symptom of a classpath problem. Not knowing RFT specifically, but knowing common issues with JUnit it does depend on how the JUnit tests are invoked. There's no automatic Jar loading like there is with DLL dependencies in .NET. If you are running JUnit using the GUI loader, you have to make sure the classpath also includes all the dependencies. Etc. – Berin Loritsch Mar 26 '12 at 16:01
  • It looks like RFT uses a certain jar only in jUnit context and not within normal script operations. See my answer for details – Yamikuronue Mar 26 '12 at 18:00