Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

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

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 https://jazz.net/library/article/1229.
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 = "https://contonso.com/jazz";
static final String pass = "1234";
public static void main(String[] args) {
org.apache.log4j.BasicConfigurator.configure();
TeamPlatform.startup();

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("my.build.id", myProgressMonitor);

getWIs(buildClient, definition);

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

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

return repo;
} catch (TeamRepositoryException e) {
e.printStackTrace();
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(
buildResultQueryModel.personalBuild()._isFalse())._and(
buildResultQueryModel.buildState()._eq(BuildState.COMPLETED.name()));

query.filter(predicate);
query.orderByDsc(buildResultQueryModel.buildStartTime());

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);
System.out.println(queryPage.toString());
}


}
}

0 votes


Be the first one to answer this question!

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

Question asked: Aug 07 '15, 6:20 p.m.

Question was seen: 4,371 times

Last updated: Aug 07 '15, 6:20 p.m.

Confirmation Cancel Confirm