You have to create a change-set containing authentication information for the resource. Please search in this mailing list since this problem was previously solved.
Best Regards, XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com On Tue, Jan 3, 2012 at 2:44 PM, kachaps4u <[email protected]> wrote: > /Hello there, I was trying to do write a simple rule inside BRMS: When a > car > model year is older than 1989, then destroy the car. Package was validated > and created the snapshot and copied the uri. Then I created a Drools > Project > and was trying to access those resources through uri but I am not able to > go > forward. Its showing 401 exception at the line I specified the uri in the > code, see below:/ > > package pop.blah.test; > > import org.drools.KnowledgeBase; > import org.drools.agent.KnowledgeAgent; > import org.drools.agent.KnowledgeAgentFactory; > import org.drools.io.ResourceFactory; > import org.drools.runtime.StatefulKnowledgeSession; > import org.drools.definition.type.FactType; > > > public class CarApp { > > public static void main(String[] args) { > > KnowledgeAgent kagent = > KnowledgeAgentFactory.newKnowledgeAgent( > "myAgent1" ); > kagent.applyChangeSet( > ResourceFactory.newUrlResource(" > http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/pop.blah.test/CAR/LATEST > ")); > KnowledgeBase kbase = kagent.getKnowledgeBase(); > StatefulKnowledgeSession ksession = > kbase.newStatefulKnowledgeSession(); > ResourceFactory.getResourceChangeScannerService().start(); > try { > FactType carType = kbase.getFactType( "pop.blah.test", > "Car" ); > Object bmw = carType.newInstance(); > carType.set( bmw,"name","My Car" ); > carType.set( bmw,"make","BMW-x5" ); > carType.set( bmw,"year", 1977); > ksession.insert( bmw ); > ksession.fireAllRules(); > boolean dest = (Boolean) carType.get( bmw, "destroy" ); > if (dest==true) { > System.out.println("I am gona destroy that car!"); > } > else { > System.out.println("I am happy with my car!"); > } > } > catch (Exception E) { > E.printStackTrace(); > } > finally { > ksession.dispose(); > } > } > > } > > > /and here is my Error:/ > > [2012:01:03 08:01:578:info] ResourceChangeNotification created > [2012:01:03 08:01:578:info] ResourceChangeScanner reconfigured with > interval=60 > [2012:01:03 08:01:578:info] ResourceChangeScanner created with default > interval=60 > [2012:01:03 08:01:578:debug] ResourceChangeNotification monitor added > monitor=org.drools.io.impl.ResourceChangeScannerImpl@1bd7848 > [2012:01:03 08:01:593:debug] KnowledgeAgent building resource map > [2012:01:03 08:01:593:info] KnowledegAgent has started listening for > ChangeSet notifications > [2012:01:03 08:01:593:info] KnowledgeAgent created, with configuration: > monitorChangeSetEvents=true scanResources=true scanDirectories=true > newInstance=true > [2012:01:03 08:01:859:exception] > java.lang.RuntimeException: Unable to parse ChangeSet > at > > org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:393) > at > > org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168) > at pop.blah.test.CarApp.main(CarApp.java:16) > Caused by: java.io.IOException: Server returned HTTP response code: 401 for > URL: > > http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/pop.blah.test/CAR/LATEST > at > sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown > Source) > at org.drools.io.impl.UrlResource.grabStream(UrlResource.java:210) > at > org.drools.io.impl.UrlResource.getInputStream(UrlResource.java:146) > at org.drools.io.impl.UrlResource.getReader(UrlResource.java:214) > at > > org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:391) > ... 2 more > [2012:01:03 08:01:859:exception] > java.lang.RuntimeException: Unable to parse ChangeSet > at > > org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:397) > at > > org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168) > at pop.blah.test.CarApp.main(CarApp.java:16) > [2012:01:03 08:01:859:info] KnowledgeAgent applying ChangeSet > Exception in thread "main" java.lang.NullPointerException > at > > org.drools.agent.impl.KnowledgeAgentImpl.processChangeSet(KnowledgeAgentImpl.java:215) > at > > org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:183) > at > > org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168) > at pop.blah.test.CarApp.main(CarApp.java:16) > > > > Please help me. > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/urlResource-applyChangeset-and-authentication-error-tp3629051p3629051.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
