It's all about the answers!

Ask a question

get clientLibrary from plain java (Hello Jazz tutorial)

Martin Dam Pedersen (1352814) | asked Nov 20 '12, 7:42 a.m.
edited Nov 20 '12, 7:43 a.m.
 I have successfully followed the "Hello Jazz tutorial" located at The example uses a JUnit test class to test the service call, and it runs just fine without any errors.

My problem is that it doesn't work when i try to call the service from a plain java class. My test class looks like the the JUnit test class, the main difference is that it doesn't extend TestCase. 
The problem is that the repo.getClientLibrary clause returns null.

I have read the thread but that didn't help me.

Can anyone please help me in understanding what i am doing wrong ?
Isn't possible to call a ClientLibrary from a plain java class ?

Here is the test code. 
package com.example.hellojazz.client.tests;
import com.example.hellojazz.client.IHelloJazzClientLibrary;
public class SimpleTest {
private ITeamRepository repo;

public static void main(String[] args) throws TeamRepositoryException{
SimpleTest test = new SimpleTest();
private void helloJazz() throws TeamRepositoryException {
if (!TeamPlatform.isStarted())
repo = login();
IHelloJazzClientLibrary library = (IHelloJazzClientLibrary) repo.getClientLibrary(IHelloJazzClientLibrary.class);
String result = library.sayHello();
System.out.println("resultat = "+result);
* The URI scheme <code>"local:"</code> creates a Jazz server on the same
* thread as the client.
private static final String REPOSITORY_URI = "https://localhost:7443/jazz";
private ITeamRepository login() throws TeamRepositoryException {
ITeamRepository repository = TeamPlatform.getTeamRepositoryService()
repository.registerLoginHandler(new ITeamRepository.ILoginHandler() {
public ILoginInfo challenge(ITeamRepository repo) {
return new ILoginInfo() {
public String getUserId() {
return "TestJazzAdmin1";
public String getPassword() {
return "TestJazzAdmin1";
return repository;

Ralph Schoon commented Nov 20 '12, 11:28 a.m.

Martin, I haven't used the code above. I would assume the library would at least need to be in the classpath. My automation usually does not create a new client library. So I can't say if there is a registration process that needs to be added. I started here: for what its worth.

Martin Dam Pedersen commented Nov 20 '12, 5:24 p.m.

I am quite sure that IHelloJazzClientLibrary.class is in my classpath. When running the JUnit test I have no problems getting an instance of IHelloJazzClientLibrary, and no problem calling sayHello. But when I try to get an instance from a plain java application it doesn't work. 

The call repo.getClientLibrary(IHelloJazzClientLibrary.class)
returns null when called from a plain java application. But it returns an instance of HelloJazzClientLibrary when called from JUnit test program.

Has anyone succeeded in calling a custom clientLibrary from a plain java app.?
What am i missing here, some kind of registration as Ralph mentions ? 

I am quite familiar with the client library, and have made lots of automation classes that works just fine. This is just another approach that i would like to give a try. For some of my automation this would be very useful.

Accepted answer

permanent link
sam detweiler (12.5k6195201) | answered Nov 20 '12, 12:05 p.m.
looks like you need to insure the
IHelloJazzClientLibrary.class is in the classpath

it is pre-compiled in the zip file here\com.example.hellojazz-plugins-source\com.example.hellojazz.service\bin\com\example\hellojazz\service\internal
Martin Dam Pedersen selected this answer as the correct answer

3 other answers

permanent link
sam detweiler (12.5k6195201) | answered Nov 20 '12, 6:19 p.m.
I have a plain java client app that calls thru a client library without problem.

here is my call to my client library
    // TODO Auto-generated method stub
      private static IMemoryClient IMemService=null;
      private static IMemoryClient getMemoryService(String url)
              System.out.println("parm client get library failed");   
          return IMemService;

permanent link
sam detweiler (12.5k6195201) | answered Nov 21 '12, 6:58 a.m.
yes, I should have noted that I created a jar file to hold my client library class as well..

permanent link
Martin Dam Pedersen (1352814) | answered Nov 21 '12, 2:13 a.m.
Finally I managed to get it working. 

The problem was indeed the classpath. 
In my first eclipse launcher(the one that didn't work) I added the projects com.example.hellojazz.common and com.example.hellojazz.client on my classpath, but that didn't work. 

Then i exported com.example.hellojazz.client and com.example.hellojazz.common to jar files and added them to my classpath in the launcher instead of the projects, and then it worked like a charm. 

could anyone explain to me why the first attempt didn't work ?  I would expect it to work similar to the second attempt, but it didn't.

Thank you for your help.

Your answer

Register or to post your answer.