KIE Workbench集成与401响应 [英] KIE Workbench Integration Responds with 401
问题描述
我试图将我的KIE Workbench 6.1.FINAL部署与使用Drools 6.1.FINAL的简单应用程序集成。我使用以下代码:
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
错误来自得到 InputStream
的行。我可以用 http:// localhost:8088 / workbench
用用户名和密码admin登录到我的工作台,我可以下载.jar文件通过在我的Web浏览器中跟随 http:// localhost:8088 / workbench / maven2 / com / sep / test / myProject / 1.0 / myProject-1.0.jar
我还可以使用以下 curl
命令检索.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
但是,我无法使用 wget
提取.jar。
However, I haven't been able to fetch the .jar using wget
.
如何通过身份验证?这只是一个原型;有没有办法关闭下载此.jar文件的身份验证?
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?
推荐答案
UrlResource中有一个已修复的错误。请参见 https://issues.jboss.org/browse/DROOLS-693
There is a bug in UrlResource which has been fixed. See https://issues.jboss.org/browse/DROOLS-693
这是另一种解决方案: http://stackoverflow.com/a/28230876/ 418730
Here is an alternative solution: http://stackoverflow.com/a/28230876/418730
这篇关于KIE Workbench集成与401响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!