Invalid Credentials error even when the credentials are valid
Hello Team,
We are running an application which creates WIs in RTC, but sometimes even though the login credentials added in the code are correct, we get an error message stating "Invalid credentials - CRJAZ0124E The user name or password is invalid." But application runs properly when we run it again without making any changes.
Please find below the code snippet for your kind reference.
public ITeamRepository login(final String username, final String password, String url)
throws TeamRepositoryException {
logger.info("Entered Login method");
IProgressMonitor monitor = new SysoutProgressMonitor();
logger.info("going to TeamPlatform.startup()");
TeamPlatform.startup();
logger.info("TeamPlatform.startup() has started");
ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(url);
logger.info("setting registerLoginHandler");
repository.registerLoginHandler(new ITeamRepository.ILoginHandler() {
public ILoginInfo challenge(ITeamRepository repository) {
logger.info("succesfully setting registerLoginHandler");
return new ILoginInfo() {
public String getUserId() {
logger.info("Username in RTCLogin class"+username);
return username;
}
public String getPassword() {
logger.info("Getting inside getPassword() "+password);
return password;
}
};
}
});
monitor.subTask("Contacting " + repository.getRepositoryURI() + "...");
repository.login(monitor);
monitor.subTask("Connection successfull!!");
return repository;
}
}
The builds shows that the code is entering a continuous loop at ILoginInfo challenge method.
Could you please help us in finding the root cause for this issue?
Please do let us know if you need any further information.
Thanks a lot in advance.
Accepted answer
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation shows example code that has always worked for me.
Comments
The important part here is:
ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
You would also likely want to surround the login with a tray/catch for TeamRepositoryException, if you want to retry. The call itself tries three times.
One other thing I have seen is:
Do not package everything in one JAR. have your own JAR and keep the Plain Java Client Libraries and other JAR's you use in folders in the classpath.
1 vote