KnowledgeBases are not aware of Guvnor, nor are ChangeSets.<br><br>If you create a new rule and want to add it to Guvnor you&#39;ll need to use a suitable API.<br><br>Please look at Guvnor&#39;s documentation, in particular the Integration section and REST API.<br>
<br>With kind regards,<br><br>Mike<br><br><div class="gmail_quote">On 7 March 2012 07:12, PC <span dir="ltr">&lt;<a href="mailto:prakash.3098@gmail.com">prakash.3098@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
 i am using Guvnor-5.2.0 . Through a simple java client class i wanted to<br>
add<br>
a rule at runtime.<br>
<br>
below is the snippet of java code i am using to add a rule.<br>
<br>
KnowledgeBase knowledgeBase = createKnowledgeBase();<br>
session = knowledgeBase.newStatefulKnowledgeSession();<br>
logger = KnowledgeRuntimeLoggerFactory.newFileLogger(session,<br>
&quot;log/DroolsSample&quot;);<br>
KnowledgeRuntimeLoggerFactory.newConsoleLogger(session);<br>
String ruleDescription = &quot;package com.tcube.atyaf.dto;&quot;+<br>
                                        &quot;import<br>
com.tcube.atyaf.dto.EmployeeDataDTO;&quot; +<br>
                                        &quot;rule \&quot;SimpleDRLRule\&quot;&quot;+<br>
                                        &quot; @ID(11003588)&quot;+<br>
                                        &quot; lock-on-active true&quot;+<br>
                                        &quot; salience -11&quot;+<br>
                                        &quot; dialect &#39;mvel&#39;&quot;+<br>
                                        &quot; when m :<br>
EmployeeDataDTO(empName==\&quot;PC\&quot;);&quot;+<br>
                                        &quot; then System.out.println(<br>
\&quot;*************rule executed\&quot;);&quot; +<br>
                                        &quot; m.setDesignation( \&quot;Manager<br>
,Additional Duties &amp; Additional hike<br>
!!!\&quot; );&quot;+<br>
                                        &quot; update( m );&quot;+<br>
                                        &quot; end&quot;;<br>
byte[] data = ruleDescription.getBytes();<br>
<br>
KnowledgeBuilder kbuilder =<br>
KnowledgeBuilderFactory.newKnowledgeBuilder(knowledgeBase);<br>
kbuilder.add( ResourceFactory.newClassPathResource(&quot;ChangeSet.xml&quot;),<br>
ResourceType.CHANGE_SET );<br>
kbuilder.add( ResourceFactory.newClassPathResource(&quot;TestRule.drl&quot;),<br>
ResourceType.DRL);<br>
kbuilder.add(ResourceFactory.newByteArrayResource(data),<br>
ResourceType.DRL);<br>
<br>
if(kbuilder.hasErrors()) {<br>
                            System.out.println( kbuilder.getErrors() );<br>
                            return;<br>
                        }<br>
Collection&lt;KnowledgePackage&gt; kpkgs = kbuilder.getKnowledgePackages();<br>
knowledgeBase.addKnowledgePackages( kpkgs );<br>
<br>
<br>
emp = new EmployeeDataDTO();<br>
emp.setEmpNo(1);<br>
emp.setEmpName(&quot;PC&quot;);<br>
emp.setAge(29);<br>
emp.setSalary(new BigDecimal(&quot;6500&quot;));<br>
<br>
session.insert(emp);<br>
<br>
session.fireAllRules();<br>
<br>
I am getting all the rules executed as per exceptation since it is in the<br>
same session, however the new rules that i have added are not reflected in<br>
Drools-Guvnor UI....<br>
<br>
please help me on code for deploying the knowldgeBase/Package(kpkgs) to<br>
Drools-Guvnor UI..<br>
<br>
-----<br>
PC<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/facing-problems-while-adding-a-Rule-to-DROOLS-using-java-client-tp3806068p3806068.html" target="_blank">http://drools.46999.n3.nabble.com/facing-problems-while-adding-a-Rule-to-DROOLS-using-java-client-tp3806068p3806068.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>