Call Java Class - having class path issues

by Community Manager on ‎08-09-2011 02:06 PM

Question

I am currently using HP Service Test to call a Java class in a .JAR file. I have placed this .JAR file in the directory with my test solution. When I add a step to Call Java Class I can select and run the file just fine, but I'm having a problem where I cannot move my test solution to a different directory without getting a java.lang.NoClassDefFoundError when I run my test.

 

As near as I can tell, it's trying to call the specific path for the .JAR when I add it (I.E. something like c:\temp\{test directory}, even though I may have moved it to c:\users\{user name}\workspace\{test directory}). How can I change this so that it always looks in the same directory as the test solution for this .JAR file?

Answer

Hello, You are right, the path of the .jar file is indeed preserved within the test as it is translated to code. This path cannot be modified, and there's no way to add jar paths relatively to the test path.

 

But still, one workaround I can think of is to include this jar in what we call InternalJavaClasspath:

You can define a new path to that jar of yours within InternalJavaClasspath.dat located under {hp_service_test_installation_folder}\dat And then you must put this jar in a subfolder under the installation folder.

The common location is: bin/java - you can create a folder here called MySpecialJars and the respective line in the dat file will be: bin/java/MySpecialJars/MySpecialJar01.jar

Comments
by vivek_gupta36 on ‎04-14-2014 04:26 AM

I have been trying to access WebLogic’s JMS queue through UFT – Service Test tool. Following parameters I have passed as a part of JMS configuration

1)      Classpath = C:\Program Files (x86)\HP\Unified Functional Testing\bin\java\JMS\javax.jms.jar

2)      JNDI initial context factory = weblogic.jndi.WLInitialContextFactory

3)      JNDI provider URL = t3://XX.XXX.X.XXX:XXX

4)      JMS connection factory = XXXXXXXXXXX

 

When I try to retrieve a message from JMS queue, I am getting following error “Failed to initialize the JMS session. The initial context factory is missing or wrong”.

 

 Request you to get me a clear picture on the below mentioned points.

1)      Which all JAR files I need to import/include in my “Classpath” and their locations respectively.

2)       Proper format for JNDI provider URL(whether to start with tcp or t3 followed by IP address & port number)

 

Thanks in Advance!

Search
Showing results for 
Search instead for 
Do you mean 
Follow Us


HP Blog

HP Software Solutions Blog

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation