Herşey ilk adımlarla başlar...

Tuesday, November 23, 2010

JBoss Drools - Guvnor - 401 Error

11/23/2010 Posted by Nurettin Onur YAKIT , , , , , , No comments
I have been mentioned about JBoss Drools in my previous post. (JBoss Drools Step By Step)

If you got Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor exception then you have to do this :

Create a change-set.xml file and fill with the code below.

<?xml version="1.0" encoding="UTF-8"?>

<change-set xmlns='http://drools.org/drools-5.0/change-set'


    xs:schemaLocation='http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd' >


<!--resource source='classpath:spring/payment_rules.drl' type='DRL' /-->

<resource source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/com.sample/LATEST.drl' 

type='DRL' basicAuthentication="enabled" username="admin" password="admin" />



Then use this Java Code to access knowledgeBase :

private static KnowledgeBase readKnowledgeBaseByAgent() {
KnowledgeAgent agent = KnowledgeAgentFactory.newKnowledgeAgent("LocalAgent");
URL url = null;
//This url is written inside the change-set.xml
// String ruleUrl = "http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/com.sample/LATEST.drl";
String changeSetPath = "change-set.xml";
return agent.getKnowledgeBase();

And no more 401 Error :)