get clientLibrary from plain java (Hello Jazz tutorial)
I have successfully followed the "Hello Jazz tutorial" located at https://jazz.net/library/article/118. 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 https://jazz.net/forum/questions/648/client-library-not-found-during-the-service-call 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.
|
Accepted answer
looks like you need to insure the
Martin Dam Pedersen selected this answer as the correct answer
|
3 other answers
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) { if(IMemService==null) IMemService=(IMemoryClient)getRepository(url).getClientLibrary(IMemoryClient.class); if(IMemService==null) System.out.println("parm client get library failed"); return IMemService; } |
yes, I should have noted that I created a jar file to hold my client library class as well..
|
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
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
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: https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation for what its worth.
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.