It's all about the answers!

Ask a question

Intermittent Authentication Errors with Java applications


Anthony Di Loreto (1632) | asked Nov 11 '10, 12:37 p.m.
Hi, the problem I'm encountering has happened in 7.1.1.x and 7.1.2.

Basically, I'm getting authentication errors intermittently with the same user account when executing:
project.getBuilds();


It happens once out of every 5-10 times. I am making the call from a custom Ant task while in the middle of a Build Forge job.o

The only other "interesting" thing I do is have multiple processes on the same client machine executing this code independently. So it's quite possible that two or more may try to authenticate at the same time or be in some potential race condition? I'm not sure if Build Forge creates unique connections or they are shared somehow if you're on the same client.

The systems in question (client and server) are stable wrt. communications.

Here's the exception stack trace I always see (the top being my own exception wrapper):

org.blah.bs.BuildServerException: An exception occurred while getting the list of builds from project 'project'.

at org.blah.bf.BuildForgeFactory.getCompletedBuilds(BuildForgeFactory.java:159)
at org.blah.bf.BuildForgeNotify.execute(BuildForgeNotify.java:398)
at org.blah.ant.BuildResultsNotifyTask.execute(BuildResultsNotifyTask.java:94)
... 16 more
Caused by: com.buildforge.services.common.api.APIException: API: Authentication Error.
at com.buildforge.services.client.api.APIClientConnection.call(APIClientConnection.java:663)
at com.buildforge.services.client.dbo.Build.findByProjectUuid(Build.java:224)
at com.buildforge.services.client.dbo.Project.getBuilds(Project.java:300)
at org.blah.bf.BuildForgeFactory.getCompletedBuilds(BuildForgeFactory.java:151)
... 18 more


Any help is appreciated,

Anthony

One answer



permanent link
Steven Vaughan (22111) | answered Nov 12 '10, 8:26 a.m.
JAZZ DEVELOPER
What seems to be going on (especially with the multi-process/thread hint)
is normal operation of the authentication and licensing controls for the
7.1 line of code. When a user logs in (ui, api, wherever), they obtain
a session and a license. If that user logs in a second time (new browser
logs into ui, other process/thread reuses the same credentials to re-auth
via api, etc), the original session is destroyed in the process of creating
the session for the new authentication.

From a business perspective, this is done so that a single floating license
doesn't enable infinite simultaneous logins, relegating 2+ licenses
or user accounts to a purely audit-centric function.

That said, you MAY share sessions between programmatic clients by
utilizing (from the 2nd caller and behond) the APIClientConnection.authToken(String token)
call >instead< of using authUser(String user, String pass). Again,
this is only after an initial connection has been made. Recall that
APIClientConnection's authUser methods return a String to you.
That String is the unique authentication token for that session. If
you wish to share sessions, make that data available in a thread-safe
manner (for multi-thread) or in an IPC fashion (for multi-process).
Subsequent streams of execution that want to re-use the session
may use that token in the authToken call. Do be aware that
>EVERY< request for a particular session is completely serialized.
If there is an existing request/response already in-flight between
Client 1 and the Server, Client N will block if it makes a request
into the Server as well (until Client 1's response is complete).

-steve

Hi, the problem I'm encountering has happened in 7.1.1.x and 7.1.2.

Basically, I'm getting authentication errors intermittently with the same user account when executing:
project.getBuilds();


It happens once out of every 5-10 times. I am making the call from a custom Ant task while in the middle of a Build Forge job.o

The only other "interesting" thing I do is have multiple processes on the same client machine executing this code independently. So it's quite possible that two or more may try to authenticate at the same time or be in some potential race condition? I'm not sure if Build Forge creates unique connections or they are shared somehow if you're on the same client.

The systems in question (client and server) are stable wrt. communications.

Here's the exception stack trace I always see (the top being my own exception wrapper):

org.blah.bs.BuildServerException: An exception occurred while getting the list of builds from project 'project'.

at org.blah.bf.BuildForgeFactory.getCompletedBuilds(BuildForgeFactory.java:159)
at org.blah.bf.BuildForgeNotify.execute(BuildForgeNotify.java:398)
at org.blah.ant.BuildResultsNotifyTask.execute(BuildResultsNotifyTask.java:94)
... 16 more
Caused by: com.buildforge.services.common.api.APIException: API: Authentication Error.
at com.buildforge.services.client.api.APIClientConnection.call(APIClientConnection.java:663)
at com.buildforge.services.client.dbo.Build.findByProjectUuid(Build.java:224)
at com.buildforge.services.client.dbo.Project.getBuilds(Project.java:300)
at org.blah.bf.BuildForgeFactory.getCompletedBuilds(BuildForgeFactory.java:151)
... 18 more


Any help is appreciated,

Anthony

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.