Which version of drools are you using? RuleBase, RuleAgent and WorkingMemory are not used anymore. And, this piece of log makes me think if the version of Guvnor you are running is different to the version of Drools you are using in your webapp:

org.drools.
rule.Package; local class incompatible: stream classdesc serialVersionUID =
510, local class serialV
ersionUID = 400

Seems you are using Guvnor 5.1 but Drools 4.0 in your webapp. If you are just starting with drools, I'd suggest you to use the latest stable version 5.3.

Best Regards,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


2011/12/5 Jackson Cunha <jackson.cereb@gmail.com>
So, let's talk about some points:
  • You should not create a new knowledge base every time you need a session, because construction of knowledge bases is very expensive. You would do this at start of application applying Singleton pattern.
  • If you already have a knowledge base, you are able to get parameters from GET or POST using your preferred controller, instantiate your objects using then and after that pass your objects for a new knowledge session (stateless or statefull).

On 5 December 2011 10:13, srinivasasanda <srinivasasanda@gmail.com> wrote:
this piece of application is working using drools project, but its not
working in (webapplication)

i had a text box age and income that values i am trying passing this data to
rule and run the rules.
i created one jsp , jsp call servlet, In servelt i called the below piece of
code in servlet but not executing

I am trying to include it this piece of code into webapplication (in servlet
or jsp) it is showing error.

public static final void runMain() {
       try {
               RuleAgent agent = RuleAgent.newRuleAgent("/guvnor.properties");
           RuleBase ruleBase = agent.getRuleBase();
           WorkingMemory workingMemory = ruleBase.newStatefulSession();
           FactType ft= ruleBase.getFactType("sample.person");  //created
declarative model in guvnor
           Object obj=ft.newInstance();
           ft.set(obj,"age", 67);
//setting data into into person
           ft.set(obj, "income", 1000);
           workingMemory.insert(obj);
           workingMemory.fireAllRules();
           System.out.print(ft.get(obj, "age"));
           System.out.print(ft.get(obj, "income"));
             } catch (Throwable t) {
           t.printStackTrace();
       }
   }


12:46:44,409 ERROR [STDERR] RuleAgent(default) INFO (Mon Dec 05 12:46:44 GMT
2011): Configuring with
 newInstance=false, secondsToRefresh=-1
12:46:44,419 ERROR [STDERR] RuleAgent(default) INFO (Mon Dec 05 12:46:44 GMT
2011): Configuring pack
age provider : URLScanner monitoring URLs:
http://localhost:8082/guvnor-5.2.0.Final-jboss-as-5.1/or
g.drools.guvnor.Guvnor/package/sample/LATEST
12:46:44,669 INFO  [STDOUT] INFO  05-12 12:46:44,669
(NilAuthenticator.java:authenticate:35)     All
 users are guests.


12:46:44,359 ERROR [STDERR] java.lang.IllegalArgumentException: Could not
parse knowledge.
12:46:44,359 ERROR [STDERR]     at
com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:115)
12:46:44,359 ERROR [STDERR]     at
com.sample.DroolsTest.FireRools(DroolsTest.java:62)
12:46:44,359 ERROR [STDERR]     at p1.Login.doGet(Login.java:37)
12:46:44,359 ERROR [STDERR]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
12:46:44,359 ERROR [STDERR]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


12:46:44,699 ERROR [STDERR] RuleAgent(default) EXCEPTION (Mon Dec 05
12:46:44 GMT 2011): org.drools.
rule.Package; local class incompatible: stream classdesc serialVersionUID =
510, local class serialV
ersionUID = 400. Stack trace should follow.
12:46:44,699 ERROR [STDERR] java.io.InvalidClassException:
org.drools.rule.Package; local class inco
mpatible: stream classdesc serialVersionUID = 510, local class
serialVersionUID = 400
12:46:44,699 ERROR [STDERR]     at
java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562
)

--
View this message in context: http://drools.46999.n3.nabble.com/Calling-drools-into-the-Web-Application-tp3561362p3561362.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
----------------------------------------------------------------------------------------------------------------
Jackson Cunha Cassimiro (CereB)
Bacharel em Ciencia da Computação - UFPI
MSN: jackson.cereb@gmail.com
Telefone Móvel +55 86 9928 1251
Analista de Sistemas - Infoway - http://www.infoway-pi.com.br
Missão Infoway - "Influenciar a Gestão de Sistemas de Saúde através de e-health"

("A vida é um combate que os fracos abate, aos bravos, aos fortes só pode exaltar" - Canção do Tamoio, Gonçalves Dias)
----------------------------------------------------------------------------------------------------------------

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users