0

我们正在使用:

• Drools 5.0.x 附带的 Drools 执行服务器 • Drools Guvnor 5.2 配置了活动目录

执行服务器和 guvnor 运行在同一个 Tomcat 上,使用同一个端口。

使用执行服务器,您可以为配置文件中的每个包设置一个侦听器。我有两个这样的文件,from-file-system.properties 指向手动部署drools 二进制包的本地目录。这工作正常。

但我尝试使用指向 5.3 Guvnor 上的包二进制文件的 with-guvnor.properties。这是文件:

name=ndipiazza
newInstance=true
# Absolute path of the directory containing pc.drl: placeholder replaced by Ant.
url=http://localhost:9109/drools-guvnor/rest/packages/NDD_Test/binary
poll=10

我收到以下错误:

RuleAgent(ndipiazza) INFO (Mon Jun 18 18:11:32 EDT 2012): Configuring package provider : URLScanner monitoring URLs:  http://localhost:9109/drools-guvnor/rest/packages/NDD_Test/binary
RuleAgent(ndipiazza) WARNING (Mon Jun 18 18:11:34 EDT 2012): Was an error contacting http://localhost:9109/drools-guvnor/rest/packages/NDD_Test/binary. Reponse header: {null=[HTTP/1.1 401 Unauthorized]

某种授权错误很可能与 Guvnor 5.2 中的活动目录配置有关。这曾经对我们使用早期版本的 Guvnor 很好。

我该如何解决这个问题?

4

1 回答 1

2

所以我们今天隔离了这个问题。当具有任何类型的身份验证时,Drools Server 5.0.x 不支持 URL 端点。

我报告了一个错误:https ://issues.jboss.org/browse/JBRULES-3554

如果没有这些更改,这将不起作用。

流口水核心的org/drools/agent/HttpClientImpl.java

这两种方法需要添加身份验证(由 START 和 END NDD 标记),并且显然使用您的用户名/密码切换。

public LastUpdatedPing checkLastUpdated(URL url) throws IOException {
        URLConnection con = url.openConnection();
        HttpURLConnection httpCon = (HttpURLConnection) con;
        try {
// **** START NDD ***** 
            BASE64Encoder enc = new sun.misc.BASE64Encoder();
            String userpassword = "ad-user" + ":" + "ad-password";
            String encodedAuthorization = enc.encode( userpassword.getBytes() );
            httpCon.setRequestProperty("Authorization", "Basic "+
                  encodedAuthorization);
            // **** END NDD *****             



            httpCon.setRequestMethod( "HEAD" );            


            String lm = httpCon.getHeaderField( "lastModified" );
            LastUpdatedPing ping = new LastUpdatedPing();

            ping.responseMessage = httpCon.getHeaderFields().toString();

            if ( lm != null ) {
                ping.lastUpdated = Long.parseLong( lm );
            } else {
                long httpLM = httpCon.getLastModified();
                if ( httpLM > 0 ) {
                    ping.lastUpdated = httpLM;
                }
            }

            return ping;
        } finally {
            httpCon.disconnect();
        }

    }

    public Package fetchPackage(URL url) throws IOException,
                                        ClassNotFoundException {
        URLConnection con = url.openConnection();
        HttpURLConnection httpCon = (HttpURLConnection) con;
        try {

            // **** START NDD ***** 
            BASE64Encoder enc = new sun.misc.BASE64Encoder();
            String userpassword = "ad-user" + ":" + "ad-password";
            String encodedAuthorization = enc.encode( userpassword.getBytes() );
            httpCon.setRequestProperty("Authorization", "Basic "+
                  encodedAuthorization);
            // **** END NDD *****             




            httpCon.setRequestMethod( "GET" );

            Object o = DroolsStreamUtils.streamIn( httpCon.getInputStream() );

            if ( o instanceof KnowledgePackageImp ) {
                return ((KnowledgePackageImp) o).pkg;
            } else {
                return (Package) o;
            }
        } finally {
            httpCon.disconnect();
        }
    }

谜团已揭开。

于 2012-06-23T00:36:09.287 回答