[rules-users] 4.0.0.MR3 Problems

Mark Proctor mproctor at codehaus.org
Tue Jul 3 18:36:20 EDT 2007


Using the string you have there and reflection the system tries to load 
the JavaDialect, as long as its in your classpath it should work. The 
code to do this is straight forward and is in PackageBuilderConfiguration:
    public DialectRegistry buildDialectRegistry(PackageBuilder 
packageBuilder) {
        DialectRegistry registry = new DialectRegistry();
        ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
        for ( Iterator it = this.dialects.entrySet().iterator(); 
it.hasNext(); ) {
            Entry entry = (Entry) it.next();
            String str = (String) entry.getKey();
            String dialectName = str.substring( str.lastIndexOf( "." ) + 
1 );
            String dialectClass = (String) entry.getValue();
            try {
                Class cls = classLoader.loadClass( dialectClass );
                Constructor cons = cls.getConstructor( new 
Class[]{PackageBuilder.class} );
                registry.addDialect( dialectName,
                                     (Dialect) cons.newInstance( new 
Object[]{packageBuilder} ) );
            } catch ( Exception e ) {
                throw new RuntimeDroolsException( "Unable to load 
dialect '" + dialectClass + ":" + dialectName + "'" );
            }
        }
        return registry;
    }

I've know idea why this is failing for you, let me know what you find.

Mark
Ronald R. DiFrango wrote:
> All,
>
> I am in the process of migrating my 3.0. project to the 4.x series and 
> when I attempt to run my code I get the following exception when I 
> attempt to load my .drl files:
>
> Caused by: org.drools.RuntimeDroolsException : Unable to load dialect 
> 'org.drools.rule.builder.dialect.java.JavaDialect:java'
>
> Here is my package builder code:
>
> static
>     {
>         try
>         {
>             builder = new PackageBuilder();
>             builder.addPackageFromDrl( new InputStreamReader( 
> RtvDecisionEngine.class.getResourceAsStream("rtv.drl" ) ) );
>             builder.addPackageFromDrl( new InputStreamReader( 
> RtvDecisionEngine.class.getResourceAsStream 
> ("modelDiscrepancyRules.drl" ) ) );
>             ruleBase = RuleBaseFactory.newRuleBase();
>             ruleBase.addPackage( builder.getPackage() );
>         }
>         catch(Exception e)
>         {
>             throw new RuntimeException("Failure loading the Rules", e);
>         }
>     }
>
>
> Any thoughts appreciated.
>
> Ron
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070703/7e96b206/attachment.html 


More information about the rules-users mailing list