[rules-users] Integration of drools with webapplication (Servlet)

srinivasasanda srinivasasanda at gmail.com
Thu Dec 22 12:19:34 EST 2011


Hi Leo_Gomes
        I have a this problem when i add my code with web application , but
i am getting result in console application , 
		please give me some solution.. and i am not able to sort out which jar
files exactly needed to include, 

               
...............................................................................................................
System.out.println(GlobalConfig.getConfigParameterValue("packagelisturl"));
URL packages = new
URL(GlobalConfig.getConfigParameterValue("packagelisturl"));
URLConnection yc = packages.openConnection();
BufferedReader in = new BufferedReader(new
InputStreamReader(yc.getInputStream()));
String inputLine;
inputLine = in.readLine();
System.out.print("inputLine"+inputLine);
	while ((inputLine = in.readLine()) != null)
		{
			System.out.print("inputLine"+inputLine);
            String
urlstr=GlobalConfig.getConfigParameterValue("packageurl")+""+inputLine+"/LATEST";
            URL url = new URL(urlstr);
            UrlResource urlResource =
(UrlResource)ResourceFactory.newUrlResource(url);
            urlResource.setBasicAuthentication("enabled");
            urlResource.setUsername("admin");
            urlResource.setPassword("admin");
             _kbuilder.add(urlResource, ResourceType.PKG);
             System.out.println("added pacakges into _kbuilder"+urlstr);
        }
   in.close();
  ......................................................... some other code
to fire rules.....
	when i type the url in browser it results as following 

packagelisturl=http://localhost:8080/guvnor-5.2.0.Final-jboss-as-5.1/org.drools.guvnor.Guvnor/webdav/packages
    (which show the list of package ==>
                                                        Contents of this
Folder:
                                                        defaultPackage
                                                        mortgages
                                                        sample
                                                        demo

storing above list result in buffered reader, and manuplateing the eachline
and adding all the package dynamically to the kbuilder()
  
  As per my understaning noting wrong in code, because it works with simple
java application, but when i try the same code with webapplication problem
  i checked the drools-core which contains
urlresource.setBasicAuthentication is there. But it shows error is not able
to find that method,
  
  null authenticated for rest api--> how to set the authentication to the in
webapplication.
  
  but when i try to use this in some web application , the packages are not
adding to kbuilder  and it shows the following error 

16:27:00,000 INFO  [STDOUT] INFO  22-12 16:26:59,999
(NilAuthenticator.java:authenticate:35)     All users are guests.
16:27:00,001 INFO  [STDOUT] INFO  22-12 16:27:00,001
(RepositoryServlet.java:allowUser:114)      null authenticated for
rest api
16:27:00,011 INFO  [STDOUT] inputLineContents of this Folder:
16:27:00,011 INFO  [STDOUT] inputLinedefaultPackage
16:27:00,011 INFO  [STDOUT] added pacakges into
_kbuilderhttp://localhost:8080/guvnor-5.2.0.Final-jboss-as-5.1/
org.drools.guvnor.Guvnor/package/defaultPackage/LATEST
16:27:00,018 ERROR [[StartRules]] Servlet.service() for servlet StartRules
threw exception
java.lang.NoSuchMethodError:
org.drools.io.impl.UrlResource.setBasicAuthentication(Ljava/lang/String;)V
        at
org.in.treetech.bss.rules.RuleEngine.addAllPackagesTo_kbuilder(RuleEngine.java:216)
        at org.in.treetech.bss.rules.RuleEngine.start(RuleEngine.java:104)
        at StartRules.doGet(StartRules.java:33)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
        at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
        at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.jav
a:126)
        at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java
:70)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
        at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:662)
16:42:35,220 INFO  [STDOUT] Clearing rules repository

Regards & Thanks
Srinivasa

--
View this message in context: http://drools.46999.n3.nabble.com/Integration-of-drools-with-webapplication-Servlet-tp3606467p3607048.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list