It's all about the answers!

Ask a question

ERROR: JDWP Unable to get JNI 1.2 environment. Caused by ITeamBuildClient.queryItems ?

Eric Sorensen (1111) | asked Aug 07 '15, 6:20 p.m.
This is a common bug across Java in general, apparently. There are many workarounds, none of which have worked for me - which makes me think it's a problem with the Plain Java Client Library itself.

I basically followed the tutorial on
Using IntelliJ 14.1.4, RTC Server 5.0.2 (Both the client jars and server, I checked)
Throws an error on
 IItemQueryPage queryPage = buildClient.queryItems(query, new Object[] { definition.getItemId() },
                IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, myProgressMonitor);
The problem occurs with OR without debugging.
Some string literals changed for safety.

public class Main {
    static final String USER = "ABCD";
static IProgressMonitor myProgressMonitor;
static final String SITE = "";
static final String pass = "1234";
public static void main(String[] args) {

try {

ITeamRepository repo = Login(pass);
if (repo == null) throw new Exception("Could not login");
ITeamBuildClient buildClient = (ITeamBuildClient)repo.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition definition = buildClient.getBuildDefinition("", myProgressMonitor);

getWIs(buildClient, definition);

} catch(Exception ex) {System.err.println(ex.getMessage());} finally {
public static ITeamRepository Login(final String pass) {

ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(SITE);
repo.registerLoginHandler(new ILoginHandler2() {
public ILoginInfo2 challenge(ITeamRepository repo) {
return new UsernameAndPasswordLoginInfo(USER, pass);
try {

return repo;
} catch (TeamRepositoryException e) {
return null;

public static void getWIs(ITeamBuildClient buildClient, IBuildDefinition definition) throws TeamRepositoryException {
IBaseBuildResultQueryModel.IBuildResultQueryModel buildResultQueryModel = IBaseBuildResultQueryModel.IBuildResultQueryModel.ROOT;
IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel);
IPredicate predicate = (buildResultQueryModel.buildDefinition()._eq(query.newItemHandleArg()))._and(


IItemQueryPage queryPage = buildClient.queryItems(query, new Object[] { definition.getItemId() },
IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, myProgressMonitor);
while (queryPage.hasNext()) {
queryPage = (IItemQueryPage) buildClient.fetchPage(queryPage.getToken(), queryPage.getNextStartPosition(), 1, myProgressMonitor);


Be the first one to answer this question!

Register or 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.