List Info

Thread: Re: MissingPackageName Exception | Eclipse | brl to drl




Re: MissingPackageName Exception | Eclipse | brl to drl
user name
2008-05-21 08:38:38
Hi,
  as mentioned in the docs, you could use an ant task. So if
you look at 
the sources
drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAn
tTask.java
you will notice, that it adds the package file explicitly.

In your case, try this:
String rulePackageContent =
FileUtils.readFileToString(rule.package);
String brl = FileUtils.readFileToString(file);
String outputDRL = rulePackageContent +
write.marshal(read.unmarshal(brl));

HTH,
  Jarek

----- Original Message -----
Hi,

We created a brl rule using guided editor in Eclipse 3.3
On trying to create a rule package we are getting a
'MissingPackageName'
exception.
As like a brl rule created in BRMS, on eclipse, the DRL
source of the
created brl shows only the rule body `with the exception of
the package
statement and imports. Our understanding is that
packagebuilder in
drools-compiler should pick the package name and the imports
defined in the
rules.package text file.

Things work fine for business rules created in guided editor
in BRMS. Are we
missing something obvious here? or there isn't a way to
compile and test the
brl files created in Eclipse. Any inputs are highly
appreciated. Thanks.

Code snippet fyi
                         File file = new File(test_brl);
                       	BRXMLPersistence read =
(BRXMLPersistence)
BRXMLPersistence.getInstance();		
			BRDRLPersistence write =
(BRDRLPersistence)BRDRLPersistence.getInstance();
			String brl = FileUtils.readFileToString(file);
			String outputDRL = write.marshal(read.unmarshal(brl));
			System.out.println("outputDRl"+outputDRL);
                         //Output DRL here doesn't show the
import 
statements
and package name

                         PackageBuilder builder = new
PackageBuilder();
                         builder.addPackageFromDrl(new 
StringReader(outputDRL
));  //Missing package name for rule package exception
occurs here
		        Package pkg = builder.getPackage();
		       RuleBase ruleBase = RuleBaseFactory.newRuleBase();
		       ruleBase.addPackage( pkg );

			WorkingMemory workingMemory =
ruleBase.newStatefulSession();
	                workingMemory.insert(obj);
	                workingMemory.fireAllRules();
_______________________________________________
rules-users mailing list
rules-userslists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )