问题描述
我的工作Drools的,我的下面code
导入一个org.drools.RuleBase;
进口org.drools.agent.RuleAgent;
进口org.drools.definition.type.FactType;公共类MortgageApplicationTest {
/ **
* @参数ARGS
*抛出:IllegalAccessException
*抛出:InstantiationException
* /
公共静态无效的主要(字串[] args)抛出InstantiationException,IllegalAccessException { 规则代理剂= RuleAgent.newRuleAgent(/ mortgageapproval.properties);
规则库RB = agent.getRuleBase(); FactType的appType = rb.getFactType(mortgages.LoanApplication);
FactType incomeType = rb.getFactType(mortgages.IncomeSource); 对象应用程序= appType.newInstance();
对象收入= incomeType.newInstance(); appType.set(应用程序,量,25000);
appType.set(应用程序,定金,1500);
appType.set(应用程序,lengthYears,20); incomeType.set(收入,型,工作);
incomeType.set(收入量,65000);
。rb.newStatelessSession()执行(新的对象[] {应用,收入}); 的System.out.println(应用);
}}
以下是我mortgageapproval.properties文件
<$p$p><$c$c>url=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST的userName =管理员
密码=管理员
这整个code设置抛出以下401错误
规则代理(默认)INFO(周二04月26日11时03分25秒IST 2011):用的newInstance = true的配置,secondsToRefresh = -1
规则代理(默认)INFO(周二04月26日11时03分25秒IST 2011):配置包提供商:URLScanner监测网址:HTTP://本地主机:8080 / Drools的-的Guvnor / org.drools.guvnor.Guvnor /包/贷款/最新
规则代理(默认)异常(周二04月26日11时03分25秒IST 2011):服务器返回的HTTP响应code:401网址:HTTP://本地主机:8080 / Drools的-的Guvnor / org.drools.guvnor.Guvnor /包/贷款/最新。堆栈跟踪应该遵循。
java.io.IOException异常:服务器返回的HTTP响应code:401网址:HTTP://本地主机:8080 / Drools的-的Guvnor / org.drools.guvnor.Guvnor /包/贷款/最新
在sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1403)
在org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:50)
在org.drools.agent.URLScanner.readPackage(URLScanner.java:148)
在org.drools.agent.URLScanner.getChangeSet(URLScanner.java:120)
在org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:96)
在org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:410)
在org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:362)
在org.drools.agent.RuleAgent.configure(RuleAgent.java:347)
在org.drools.agent.RuleAgent.init(RuleAgent.java:247)
在org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:187)
在org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:147)
在org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:256)
在com.notidiots.MortgageApplicationTest.main(MortgageApplicationTest.java:19)
异常的线程主显示java.lang.NullPointerException
....我只在tomcat的component.xml文件是如下:
给予认证 &LT;角色角色名称=经理桂/&GT;
&lt;使用者的用户名=雄猫密码=雄猫角色=经理桂/&GT;&LT;角色角色名称=管理/&GT;
&lt;使用者的用户名=admin的密码=管理员角色=管理员/&GT;
在我的Drools'component.xml文件下面一行显示我没有给任何身份验证
&LT;! - 身份验证。当你点击应用程序,它可以绕过登录屏幕。每个人都是客人 - &GT;&LT;安全:身份验证 - 法=#{} nilAuthenticator.authenticate/&GT;
请帮我,因为不会有太多的Drools开发商有没有...我没有得到所需的帮助....
在此先感谢
您会得到响应一个404错误,当它试图获取您已经在 URL配置文件
设置: <$c$c>http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST$c$c>
执行抵押贷款包,你就指着存在特定的文件?
I am working on drools and my following code
import org.drools.RuleBase;
import org.drools.agent.RuleAgent;
import org.drools.definition.type.FactType;
public class MortgageApplicationTest {
/**
* @param args
* @throws IllegalAccessException
* @throws InstantiationException
*/
public static void main(String[] args) throws InstantiationException, IllegalAccessException {
RuleAgent agent = RuleAgent.newRuleAgent("/mortgageapproval.properties");
RuleBase rb = agent.getRuleBase();
FactType appType = rb.getFactType("mortgages.LoanApplication");
FactType incomeType = rb.getFactType("mortgages.IncomeSource");
Object application = appType.newInstance();
Object income = incomeType.newInstance();
appType.set(application, "amount", 25000);
appType.set(application, "deposit", 1500);
appType.set(application, "lengthYears", 20);
incomeType.set(income, "type", "Job");
incomeType.set(income, "amount", 65000);
rb.newStatelessSession().execute(new Object[] {application, income});
System.out.println(application);
}
}
Following is my mortgageapproval.properties file
url=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
userName=admin
password=admin
This whole code setup Is throwing following 401 error
RuleAgent(default) INFO (Tue Apr 26 11:03:25 IST 2011): Configuring with newInstance=true, secondsToRefresh=-1
RuleAgent(default) INFO (Tue Apr 26 11:03:25 IST 2011): Configuring package provider : URLScanner monitoring URLs: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
RuleAgent(default) EXCEPTION (Tue Apr 26 11:03:25 IST 2011): Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST. Stack trace should follow.
java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1403)
at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:50)
at org.drools.agent.URLScanner.readPackage(URLScanner.java:148)
at org.drools.agent.URLScanner.getChangeSet(URLScanner.java:120)
at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:96)
at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:410)
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:362)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:347)
at org.drools.agent.RuleAgent.init(RuleAgent.java:247)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:187)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:147)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:256)
at com.notidiots.MortgageApplicationTest.main(MortgageApplicationTest.java:19)
Exception in thread "main" java.lang.NullPointerException
.... I have given authentication only at tomcat's component.xml file which is as follows
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin"/>
In my drools' component.xml following line shows I have not given any authentication
<!-- NO authentication. This will bypass the login screen when you hit the app. Everyone is "guest" -->
<security:identity authenticate-method="#{nilAuthenticator.authenticate}"/>
Please help me out since there are not many drools developer are there... I am not getting required help....
thanks in advance
You're getting a 404 error in response when it's trying to fetch the file that you've configured in the url
setting: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
Do the mortgages package and the specific file you're pointing to exist?
这篇关于401例外在Java code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!