[rules-users] Is it a limitation in Drools, can not add PKG and ChangeSet in Webapplication
srinivasasanda
srinivasasanda at gmail.com
Sat Dec 24 08:59:50 EST 2011
Hi All,
Please can any one help me, or Say is it a limitation or if Possible how to
do it in web applications.
I had written a peace of code in java that works fine & perfectly in simple
java class,
when i tried to copy same piece of code into servlet program and run, then
it throws an error,
even i included same jar files to both the applications --> drool5.2 jars
when tried to uncomment the commented line and run then it throws error, (
in adding the package, and changeSet)
KnowledgeAgent ka = KnowledgeAgentFactory.newKnowledgeAgent("MyAgent");
KnowledgeBuilder _kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
KnowledgeBase _kbase = KnowledgeBaseFactory.newKnowledgeBase();
String
urlString="http://localhost:8080/guvnor-5.2.0.Final-jboss-as-5.1/rest/packages/sample/source";
//String urlString =
"http://localhost:8080/guvnor-5.2.0.Final-jboss-as-5.1/org.drools.guvnor.Guvnor/package/sample/LATEST";
//String
urlString="http://localhost:8080/guvnor-5.2.0.Final-jboss-as-5.1/org.drools.guvnor.Guvnor/package/sample/LATEST/ChangeSet.xml"
URL url = new URL(urlString);
UrlResource urlResource =
(UrlResource)ResourceFactory.newUrlResource(url);
urlResource.setBasicAuthentication("enabled");
urlResource.setUsername("admin");
urlResource.setPassword("admin");
System.out.print("\n\n\n\n before adding package Sasi Sasi ");
_kbuilder.add(ResourceFactory.newUrlResource(url),ResourceType.DRL);
//_kbuilder.add(ResourceFactory.newUrlResource(url),ResourceType.PKG);
_kbase.addKnowledgePackages(_kbuilder.getKnowledgePackages());
System.out.print("\n\n\n\n added package Sasi Sasi");
// ka.applyChangeSet(urlResource);
/*KnowledgeBase kb = ka.getKnowledgeBase();
*/
FactType appType = _kbase.getFactType("sample", "person");
Object application = appType.newInstance();
appType.set(application, "age", 25);
appType.set(application, "income", 1500);
appType.set(application, "result", "");
StatelessKnowledgeSession ks = _kbase.newStatelessKnowledgeSession();
ks.execute(application);
System.out.println(application);
System.out.println("Result is "+appType.get(application, "result"));
if add resource type other than the DRL, like PKG,CHANGE_SET then it throws
error specified error
root cause
java.lang.NoSuchFieldError: DESCR
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:539)
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
RuleEngine.doGet(RuleEngine.java:85)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
--
View this message in context: http://drools.46999.n3.nabble.com/Is-it-a-limitation-in-Drools-can-not-add-PKG-and-ChangeSet-in-Webapplication-tp3610553p3610553.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list