HTTP 401 Unauthorized when using KIE API on Workbench M2 repository
by Patel, Ronak (Autonomy)
I'm having trouble authenticating to access the Workbench Maven repository through the KIE API (kie-ci). My code is the following and fails on the second line with an exception that says something like module not found. I see the more specific 401 error in the local Maven repository in the resolver-status.properties file.
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.newKieContainer(ks.newReleaseId("com.hp.pa.sample", "realestate", "LATEST"));
I've tried putting in my settings.xml file both suggestions in https://bugzilla.redhat.com/show_bug.cgi?id=1059584#c4 (also saw the preemptive one in https://bugzilla.redhat.com/show_bug.cgi?id=1037556 and other threads/forums and bug reports), but I continue to get the same error.
I did some further investigation using Fiddler and I see that the credentials are not being included in the HTTP request the code sends for resources in the Workbench Maven repository. I was expecting the basic authentication header to be in here. The HTTP request always looks like this (server name changed for security reasons):
GET http://kiewbserver:8080/kie-drools-wb/maven2/com/hp/pa/sample/realestate/... HTTP/1.1
Host: kiewbserver:8080
Pragma: no-cache
Cache-Control: no-cache, no-store
Accept-Encoding: gzip
Connection: keep-alive
Connection: keep-alive
Accept: */*
User-Agent: Aether
And the response is a typical HTTP/1.1 401 Unauthorized with the standard JBoss error page as the body. Using the composer feature in Fiddler, if I issue this same request with the basic authentication header included, it works, returning an HTTP 200 response with the requested file.
If I remove the authentication requirement from the Maven repository using the workaround described in bug 1059584 (referenced above), all my code works fine.
I followed the procedure to create a user for the Workbench on JBoss AS that is demonstrated in the start of this video: http://www.youtube.com/watch?v=vj3MNmiUnvY. That's the user whose credentials I've tried putting in my settings.xml. Is there anything else that needs to be done on the server side?
Any other ideas on what I may have missed or how to debug this further?
Thank you,
Ronak Patel
Software Designer
HP Autonomy