Connect to a Jazz-Service from another program
![](http://jazz.net/_images/myphoto/408ac7e677f29588ac815b4eea3dd4df.jpg)
Hi,
I would like to access the Jazz-Repository from outside, means from another program. Currently I want to connect to the "JazzTalk" service, using an own jUnit-Test (just for testing purposes). I created a Java-Project (not Plugin-Project!) and used the JazzLoginTestCase.java as a skeleton. The unit-tests fails with a runtime exception: "No Server Container Descriptors were found on the classpath. Please check that the Jetty bundles are included in your launch or packaging."
package ca.ucalgary.jazzconnect.test;
import junit.framework.*;
import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.repository.client.TeamPlatform;
import com.ibm.team.repository.common.TeamRepositoryException;
public class JazzLoginTestCase extends TestCase {
private ITeamRepository repo;
protected void setUp() throws Exception {
super.setUp();
if (!TeamPlatform.isStarted())
TeamPlatform.startup();
repo = login();
}
@SuppressWarnings("deprecation")
protected void tearDown() throws Exception {
repo.logout(null);
assertFalse(repo.loggedIn());
repo = null;
super.tearDown();
}
//********************************************************************************
// own test-code
//********************************************************************************
public void testLogin() {
// replace with a real test case in the future...
assertTrue(true);
}
//********************************************************************************
/**
* The URI scheme <code>"local:"</code> creates a Jazz server on the same
* thread as the client. Use <code>http://localhost:9080/jazz</code> for
* remote mode testing.
*/
private static final String REPOSITORY_URI = "local:";
private ITeamRepository login() throws TeamRepositoryException {
ITeamRepository repository = TeamPlatform.getTeamRepositoryService()
.getUnmanagedRepository(REPOSITORY_URI);
assertFalse(repository.loggedIn());
repository.registerLoginHandler(new ITeamRepository.ILoginHandler() {
public ILoginInfo challenge(ITeamRepository repo) {
return new ILoginInfo() {
public String getUserId() {
return "ADMIN";
}
public String getPassword() {
return "ADMIN";
}
};
}
});
repository.login(null);
assertTrue(repository.loggedIn());
return repository;
}
}
I added the following Referenced Libraries:
com.ibm.team.repository.common
com.ibm.team.repository.client
org.eclipse.core.runtime
junit
org.eclipse.equinox.common
org.eclipse.equinox.registry
log4j
org.eclipse.osgi
commons-logging
org.eclipse.core.jobs
com.ibm.team.repository.common.remoteaccess
I use the following VM arguments:
-Dcom.ibm.team.core.tests.repo=local -Dcom.ibm.team.repository.db.jdbc.location=${target_home}/../../server/jazztalk/repositoryDB
-Djetty.http.port=8080
-Djetty.https.port=8443
-Dserver.port=8080
What is the problem and how can I solve it?
Thanks in advance
Kai
I would like to access the Jazz-Repository from outside, means from another program. Currently I want to connect to the "JazzTalk" service, using an own jUnit-Test (just for testing purposes). I created a Java-Project (not Plugin-Project!) and used the JazzLoginTestCase.java as a skeleton. The unit-tests fails with a runtime exception: "No Server Container Descriptors were found on the classpath. Please check that the Jetty bundles are included in your launch or packaging."
package ca.ucalgary.jazzconnect.test;
import junit.framework.*;
import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.repository.client.TeamPlatform;
import com.ibm.team.repository.common.TeamRepositoryException;
public class JazzLoginTestCase extends TestCase {
private ITeamRepository repo;
protected void setUp() throws Exception {
super.setUp();
if (!TeamPlatform.isStarted())
TeamPlatform.startup();
repo = login();
}
@SuppressWarnings("deprecation")
protected void tearDown() throws Exception {
repo.logout(null);
assertFalse(repo.loggedIn());
repo = null;
super.tearDown();
}
//********************************************************************************
// own test-code
//********************************************************************************
public void testLogin() {
// replace with a real test case in the future...
assertTrue(true);
}
//********************************************************************************
/**
* The URI scheme <code>"local:"</code> creates a Jazz server on the same
* thread as the client. Use <code>http://localhost:9080/jazz</code> for
* remote mode testing.
*/
private static final String REPOSITORY_URI = "local:";
private ITeamRepository login() throws TeamRepositoryException {
ITeamRepository repository = TeamPlatform.getTeamRepositoryService()
.getUnmanagedRepository(REPOSITORY_URI);
assertFalse(repository.loggedIn());
repository.registerLoginHandler(new ITeamRepository.ILoginHandler() {
public ILoginInfo challenge(ITeamRepository repo) {
return new ILoginInfo() {
public String getUserId() {
return "ADMIN";
}
public String getPassword() {
return "ADMIN";
}
};
}
});
repository.login(null);
assertTrue(repository.loggedIn());
return repository;
}
}
I added the following Referenced Libraries:
com.ibm.team.repository.common
com.ibm.team.repository.client
org.eclipse.core.runtime
junit
org.eclipse.equinox.common
org.eclipse.equinox.registry
log4j
org.eclipse.osgi
commons-logging
org.eclipse.core.jobs
com.ibm.team.repository.common.remoteaccess
I use the following VM arguments:
-Dcom.ibm.team.core.tests.repo=local -Dcom.ibm.team.repository.db.jdbc.location=${target_home}/../../server/jazztalk/repositoryDB
-Djetty.http.port=8080
-Djetty.https.port=8443
-Dserver.port=8080
What is the problem and how can I solve it?
Thanks in advance
Kai
One answer
![](http://jazz.net/_images/myphoto/408ac7e677f29588ac815b4eea3dd4df.jpg)
kainehring wrote:
Hi Kai,
Here are some ideas that will hopefully get you unstuck.
First, you should be accessing the service through its client library.
So I think you will want code like this:
IJazzTalkClientLibrary clientLibrary = (IJazzTalkClientLibrary)
repo.getClientLibrary(IJazzTalkClientLibrary.class);
Message[] messages = clientLibrary.getAllMessages(monitor);
(See the code in the com.example.jazztalk.rcp.ui plugin that uses the
JazzTalk client library)
This also means that you will have to reference the JazzTalk common and
client plugins along with the others you list (and possibly even more).
Also, I don't think using the repository URL "local:" makes sense for
what you are doing. You should start the server as a separate process
and then use a repository URL like "http://localhost:9080/jazz" to
connect to it.
--
Chris Daly
Jazz Component Development Team
Hi,
I would like to access the Jazz-Repository from outside, means from
another program. Currently I want to connect to the
"JazzTalk" service, using an own jUnit-Test (just for
testing purposes). I created a Java-Project (not Plugin-Project!) and
used the JazzLoginTestCase.java as a skeleton. The unit-tests fails
with a runtime exception: "No Server Container Descriptors were
found on the classpath. Please check that the Jetty bundles are
included in your launch or packaging."
package ca.ucalgary.jazzconnect.test;
import junit.framework.*;
import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.repository.client.TeamPlatform;
import com.ibm.team.repository.common.TeamRepositoryException;
public class JazzLoginTestCase extends TestCase {
private ITeamRepository repo;
protected void setUp() throws Exception {
super.setUp();
if (!TeamPlatform.isStarted())
TeamPlatform.startup();
repo = login();
}
@SuppressWarnings("deprecation")
protected void tearDown() throws Exception {
repo.logout(null);
assertFalse(repo.loggedIn());
repo = null;
super.tearDown();
}
//********************************************************************************
// own test-code
//********************************************************************************
public void testLogin() {
// replace with a real test case in the future...
assertTrue(true);
}
//********************************************************************************
/**
* The URI scheme <code>"local:"</code> creates
a Jazz server on the same
* thread as the client. Use
code>http://localhost:9080/jazz</code> for
* remote mode testing.
*/
private static final String REPOSITORY_URI = "local:";
private ITeamRepository login() throws TeamRepositoryException {
ITeamRepository repository =
TeamPlatform.getTeamRepositoryService()
.getUnmanagedRepository(REPOSITORY_URI);
assertFalse(repository.loggedIn());
repository.registerLoginHandler(new ITeamRepository.ILoginHandler()
{
public ILoginInfo challenge(ITeamRepository repo) {
return new ILoginInfo() {
public String getUserId() {
return "ADMIN";
}
public String getPassword() {
return "ADMIN";
}
};
}
});
repository.login(null);
assertTrue(repository.loggedIn());
return repository;
}
}
I added the following Referenced Libraries:
com.ibm.team.repository.common
com.ibm.team.repository.client
org.eclipse.core.runtime
junit
org.eclipse.equinox.common
org.eclipse.equinox.registry
log4j
org.eclipse.osgi
commons-logging
org.eclipse.core.jobs
com.ibm.team.repository.common.remoteaccess
I use the following VM arguments:
-Dcom.ibm.team.core.tests.repo=local
-Dcom.ibm.team.repository.db.jdbc.location=${target_home}/../../server/jazztalk/repositoryDB
-Djetty.http.port=8080
-Djetty.https.port=8443
-Dserver.port=8080
What is the problem and how can I solve it?
Thanks in advance
Kai
Hi Kai,
Here are some ideas that will hopefully get you unstuck.
First, you should be accessing the service through its client library.
So I think you will want code like this:
IJazzTalkClientLibrary clientLibrary = (IJazzTalkClientLibrary)
repo.getClientLibrary(IJazzTalkClientLibrary.class);
Message[] messages = clientLibrary.getAllMessages(monitor);
(See the code in the com.example.jazztalk.rcp.ui plugin that uses the
JazzTalk client library)
This also means that you will have to reference the JazzTalk common and
client plugins along with the others you list (and possibly even more).
Also, I don't think using the repository URL "local:" makes sense for
what you are doing. You should start the server as a separate process
and then use a repository URL like "http://localhost:9080/jazz" to
connect to it.
--
Chris Daly
Jazz Component Development Team