Your code is a bit of a mix-up of different requirements for local (files in  directories) and remote (Guvnor repository) resources .

IIRC, you should use:-
(a) A ClassPathResource pointing to a ChangeSet.xml file on the classpath (with UserName and Password) or
(b) A URLResource configured with UserName and Password (see API)

I suggest you take a look at the Mortgages example which should help.

With kind regards,

Mike

On 2 February 2011 13:06, drools10 <tsarkar@professionalaccess.com> wrote:

Hi,
  My code is something like this:
KnowledgeAgentConfiguration kaconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
kaconf.setProperty( "drools.agent.scanDirectories","true" );
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "Agent1",
kaconf );
kagent.applyChangeSet( ResourceFactory.newUrlResource( "url generated by
guvnor" ) );
KnowledgeBase kbase = kagent.getKnowledgeBase();
                                       ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test.log");
ksession.insert('Value Object');
ksession.fireAllRules();

And my ChangeSet.xml is as follows:
<change-set xmlns='http://drools.org/drools-5.0/change-set'
   xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
   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'
>
   <add>
        <resource

source='http://pcbng100:18080/drools-guvnor/org.drools.guvnor.Guvnor/package/com.drools/LATEST'
        type='PKG' basicAuthentication="enabled" username="admin"
password=""/>
   </add>
</change-set>

As you can see, I have given the username in ChangeSet.xml as admin.
Actually before this step, I used to get 401 error even when I ran the code
as normal java application.With this entry, the code runs fine as a java
application, but when the web application tries to run it, it gives the
mentioned error.

One more thing I observed:
I get a similar error even when I run as java application, unless I have
this entry in my .classpath:
<classpathentry kind="con" path="DROOLS/Drools"/>

Would it be possible to add these jars to my manifest file? I am not sure
which jars "DROOLS/Drools" refers to.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/guvnor-integration-gives-401-error-tp2404740p2405115.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users