问题
I'm trying to integrate my KIE Workbench 6.1.FINAL deployment with a simple application using Drools 6.1.FINAL. I use the following code:
String url = "http://localhost:8088/workbench/maven2/com/sep/test/myProject/1.0/myProject-1.0.jar";
KieServices ks = KieServices.Factory.get();
UrlResource urlResource = (UrlResource) ks.getResources().newUrlResource(url);
urlResource.setBasicAuthentication("enabled");
urlResource.setUsername("admin");
urlResource.setPassword("admin");
try {
InputStream is = urlResource.getInputStream();
KieModule kModule = ks.getRepository().addKieModule(ks.getResources().newInputStreamResource(is));
kieContainer = ks.newKieContainer(kModule.getReleaseId());
kieContainer.newStatelessKieSession();
scanner = ks.newKieScanner(kieContainer);
} catch(Exception e) {
System.out.println("Exception thrown while constructing InputStream");
System.out.println(e.getMessage());
}
Every time I run this code, I see the following output:
Exception thrown while building InputStream
Server returned HTTP response code: 401 for URL: http://localhost:8088/workbench/maven2/com/sep/test/myProject/1.0/myProject-1.0.jar
I verified that the error is coming from the line getting the InputStream
. I am able to log in to my workbench at http://localhost:8088/workbench
with the username and password "admin" and I am able to download the .jar file by following http://localhost:8088/workbench/maven2/com/sep/test/myProject/1.0/myProject-1.0.jar
in my web browser. I can also retrieve the .jar using the following curl
command:
curl --user admin:admin http://localhost:8088/workbench/maven2/com/sep/test/myProject/1.0/myProject-1.0.jar
However, I haven't been able to fetch the .jar using wget
.
How can I get past the authentication? This is only a prototype; is there a way to turn off authentication for downloading this .jar file?
回答1:
There is a bug in UrlResource which has been fixed. See https://issues.jboss.org/browse/DROOLS-693
Here is an alternative solution: https://stackoverflow.com/a/28230876/418730
回答2:
it's ok with 6.2.0.Final and DO NOT use
KieModule module = ks.getRepository().addKieModule(urlResource);
it also return 401
来源:https://stackoverflow.com/questions/27487996/kie-workbench-integration-responds-with-401