It's all about the answers!

Ask a question

Invalid Credentials error even when the credentials are valid


Divya _ (254) | asked Nov 21 '23, 4:42 a.m.

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


permanent link
Ralph Schoon (63.5k33646) | answered Nov 21 '23, 11:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation shows example code that has always worked for me.

It is unclear why the login should sometimes not work. Maybe there is some kind of connection issue from the EWM server to LDAP or the license server.

Divya _ selected this answer as the correct answer

Comments
1
Ralph Schoon commented Nov 22 '23, 3:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The important part here is:

ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);

teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);

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.

Your answer


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.