<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<a class="moz-txt-link-freetext" href="http://wiki.jboss.org/wiki/Wiki.jsp?page=RulesTomcat">http://wiki.jboss.org/wiki/Wiki.jsp?page=RulesTomcat</a><br>
<br>
SB.Raghavendra wrote:
<blockquote
 cite="mid:19aa58e90803031637r1b3d416dr1a7a948bcdfee772@mail.gmail.com"
 type="cite">
  <div>Hi All,</div>
  <div>Iam very new to Drools BRMS.In one of the project we are
implementing drools.Currentluy iam working on BRMS.I have downloaded
Insurance Example from Jboss and deployed in BRMS.I have downloaded
Binary package to "c:\Raghu".Now i want to use this downloaded binary
package in one of my rule project and wants to execute.I written
following lines of code in the main executable class :</div>
  <div>&nbsp;</div>
  <b><font color="#7f0055" size="2">
  <p align="left">package</p>
  </font></b><font size="2"> com.test;
  </font><b><font color="#7f0055" size="2">
  <p align="left">import</p>
  </font></b><font size="2"> java.io.FileInputStream;</font><b><font
 color="#7f0055" size="2">
  <p align="left">import</p>
  </font></b><font size="2"> java.io.InputStreamReader;</font><b><font
 color="#7f0055" size="2">
  <p align="left">import</p>
  </font></b><font size="2"> java.io.Reader;
  </font><b><font color="#7f0055" size="2">
  <p align="left">import</p>
  </font></b><font size="2"> org.drools.RuleBase;</font><b><font
 color="#7f0055" size="2">
  <p align="left">import</p>
  </font></b><font size="2"> org.drools.RuleBaseFactory;</font><b><font
 color="#7f0055" size="2">
  <p align="left">import</p>
  </font></b><font size="2"> org.drools.StatefulSession;</font><b><font
 color="#7f0055" size="2">
  <p align="left">import</p>
  </font></b><font size="2"> org.drools.compiler.PackageBuilder;
  </font><b><font color="#7f0055" size="2">public</font></b><font
 size="2"> </font><b><font color="#7f0055" size="2">class</font></b><font
 size="2"> Test1 {
  </font><font color="#3f5fbf" size="2">/**</font><font size="2">
  </font><font color="#3f5fbf" size="2">*</font><font size="2"> </font><b><font
 color="#7f9fbf" size="2">@param</font></b><font size="2"> </font><font
 color="#3f5fbf" size="2">args</font><font size="2">
  </font><font color="#3f5fbf" size="2">*/</font><font size="2">
  </font><b><font color="#7f0055" size="2">public</font></b><font
 size="2"> </font><b><font color="#7f0055" size="2">static</font></b><font
 size="2"> </font><b><font color="#7f0055" size="2">void</font></b><font
 size="2"> main(String[] args) </font><b><font color="#7f0055" size="2">throws</font></b><font
 size="2"> Exception{
  </font><font color="#3f7f5f" size="2">// </font><b><font
 color="#7f9fbf" size="2">TODO</font></b><font color="#3f7f5f" size="2">
Auto-generated method stub</font><font size="2">
  <p align="left">System.</p>
  </font><i><font color="#0000c0" size="2">out</font></i><font size="2">.println(</font><font
 color="#2a00ff" size="2">"Method Starts..."</font><font size="2">);
  <p align="left">PackageBuilder builder = </p>
  </font><b><font color="#7f0055" size="2">new</font></b><font size="2">
PackageBuilder();
  <p align="left">Reader source = </p>
  </font><b><font color="#7f0055" size="2">new</font></b><font size="2">
InputStreamReader(</font><b><font color="#7f0055" size="2">new</font></b><font
 size="2"> FileInputStream(</font><font color="#2a00ff" size="2">"testpackage.pkg"</font><font
 size="2">));
  <p align="left">System.</p>
  </font><i><font color="#0000c0" size="2">out</font></i><font size="2">.println(</font><font
 color="#2a00ff" size="2">"Got source.."</font><font size="2">);
  </font><font color="#3f7f5f" size="2">//PackageBuilder builder = new
PackageBuilder(new Package("/testpackage.pkg"));</font><font size="2">
  <p align="left">builder.addPackageFromDrl(source);</p>
  </font><font color="#3f7f5f" size="2">//builder.addPackage(new
PackageDescr("/testpackage.pkg")); </font><font size="2">
  <p align="left">System.</p>
  </font><i><font color="#0000c0" size="2">out</font></i><font size="2">.println(</font><font
 color="#2a00ff" size="2">"After adding package : "</font><font size="2">+builder.getPackage());
  <p align="left">RuleBase ruleBase = RuleBaseFactory.<i>newRuleBase</i>();</p>
  <p align="left">ruleBase.addPackage(builder.getPackage());</p>
  <p align="left">StatefulSession session =
ruleBase.newStatefulSession();</p>
  </font><font color="#3f7f5f" size="2">//RuleAgent.</font><font
 size="2">
  <p align="left">Person adult = </p>
  </font><b><font color="#7f0055" size="2">new</font></b><font size="2">
Person(</font><font color="#2a00ff" size="2">"Raghu"</font><font
 size="2">,25);
  </font><font color="#3f7f5f" size="2">//Person child = new
Person("John",12);</font><font size="2">
  <p align="left">session.insert(adult);</p>
  <p align="left">session.fireAllRules();</p>
  <p align="left">System.</p>
  </font><i><font color="#0000c0" size="2">out</font></i><font size="2">.println(</font><font
 color="#2a00ff" size="2">"Method Ends..."</font><font size="2">);
  <p align="left">}</p>
  <p align="left">}</p>
  <div>But iam getting follwing error on console : </div>
  </font><font color="#ff0000" size="2">
  <p align="left">Exception in thread "main" </p>
  </font><u><font color="#000080" size="2">org.drools.compiler.PackageBuilder$MissingPackageNameException</font></u><font
 color="#ff0000" size="2">: Missing package name for rule package.
  <p align="left">at
org.drools.compiler.PackageBuilder.validatePackageName(</p>
  </font><u><font color="#000080" size="2">PackageBuilder.java:320</font></u><font
 color="#ff0000" size="2">)
  <p align="left">at org.drools.compiler.PackageBuilder.addPackage(</p>
  </font><u><font color="#000080" size="2">PackageBuilder.java:236</font></u><font
 color="#ff0000" size="2">)
  <p align="left">at
org.drools.compiler.PackageBuilder.addPackageFromDrl(</p>
  </font><u><font color="#000080" size="2">PackageBuilder.java:167</font></u><font
 color="#ff0000" size="2">)
  <p align="left">at com.test.Test1.main(</p>
  </font><u><font color="#000080" size="2">Test1.java:29</font></u><font
 color="#ff0000" size="2">)</font>
  <p align="left"><font color="#ff0000" size="2">I kept downloaded pkg
in the Rules project.</font></p>
  <p align="left"><font color="#ff0000" size="2"><font color="#3333ff">Iam
trying to execute in Eclipse.Tomcat version 6.016.Could you please let
me know how to resolve the isse....</font></font></p>
  <p>Also Please let me know how to use the Binay package of BRMS..</p>
  <div><br clear="all">
  <br>
-- <br>
Regards,<br>
SB.Raghavendra. </div>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>