Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

RTC Java API with Maven

 Hello,

I am trying to develop an application that makes use of the Java API. So far so good.
Unfortunately, the libraries that I need to include have to be added through Maven.

There are over 100 .jar files in the libraries, therefore making it very inefficient to add each one of them to my private Maven repository.

Because of that, I tried to repack all the jars into single.jar file. I uploaded the single.jar to my private Maven repo and everything seemed to work properly. But when I tried to run the code, a problem occured

Exception in thread "main" java.lang.ExceptionInInitializerError at com.ibm.team.repository.client.internal.TeamRepository.<init>(TeamRepository.java:427) at com.ibm.team.repository.client.internal.TeamRepositoryService.internalGetTeamRepository(TeamRepositoryService.java:338) at com.ibm.team.repository.client.internal.TeamRepositoryService.getTeamRepository(TeamRepositoryService.java:168) at com.ibm.myapp.MyApp.main(MyApp.java:386)
Caused by: java.lang.IllegalArgumentException: The type name Contributor and the namespace URI com.ibm.team.repository do not resolve to an IItemType. at com.ibm.team.repository.common.internal.querypath.AbstractQueryPathModel$Implementation.getItemType(AbstractQueryPathModel.java:192) at com.ibm.team.repository.common.query.IQuery$Factory.newInstance(IQuery.java:93) at com.ibm.team.repository.client.internal.ContributorManager.createAllContributorsQuery(ContributorManager.java:72) at com.ibm.team.repository.client.internal.ContributorManager.<clinit>(ContributorManager.java:60)

in the following line of code
ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository("https://...");

What is interesting here, is the fact that when exactly the same code is run from the plain java project where dependencies are not included through Maven but simply jars are put in the classpath, the code works as desired.

Therefore I would like to ask if any of you had used Java API libraries with Maven or experiences similar problems?



ANSWER:

I eventually solved the problem in a way very similar to the accepted answer. Unfortunately I had to upload all the required jars separately to the private maven repository (Nexus in my case). Since then I haven't experienced any difficulties (all the jars can be added with arbitrary artifactId, groupId, and version, however it is very useful to preserve the versions in case of an update).
Unfortunately this solution has quite large drawback - when RTC on which I work has been updated to version 5, API libraries changed and I had to upload new jar versions once again.
However I bet that better solution does not exist if you want to stay with simple java and stay away from workarounds like executing ant in maven etc.

0 votes

Comments

In the "me too" category, I was trying the same thing with gradle but eventually gave up.  It doesn't seem like this would be such a challenge but looks like it is.


Accepted answer

Permanent link
You might find it inefficient, but I find it necessary. Don't whinge, the WebSphere Process Server libraries for 6.0.2 contained 172 or so jars!

I add them all into my local maven repo mgr (Archiva, in my case) and I create a consolidation pom.xml that lists all jars, so I only have to include one dependency.

In that manner, all code looks and feels as if it's been run with the normal platform libraries from within eclipse, even though it's from maven.

The approach I take, is that I have a copy.bat file that copies all of the necessary jar files to a flat structure, and from there I have an install.bat or deploy.bat (to a remote repo). Why do I copy? So I can take them with me to another project. That way I only have to bear the pain once.

Piotr Nadczuk selected this answer as the correct answer

0 votes


One other answer

Permanent link
I know the pain, you can bet it.

I've solved in two ways with different clients, but it depends on how much flexibility you have.

1) Using RunAnt: run an ant inside a maven. Simply but not always accepted.
2) configure maven to access a file system path using system scope for repository

0 votes

Comments

I steer away from ant run unless you have no other option (IBM RAM integration).

As for system paths, only if you can always control locations, which is not always possible.

Yes, using the consolidation Pom approach needs to be redone per version but it only needs to be done once and it has the added advantage of it works! :-)

I might have been lucky, as I was the one providing the solution and they got what I gave them. :-)

1 vote

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 411
× 169
× 45

Question asked: Feb 03 '15, 5:49 a.m.

Question was seen: 6,473 times

Last updated: Apr 21 '15, 11:51 a.m.

Confirmation Cancel Confirm