[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2348) unable to resolve Type Declaration class

Richard Ambridge (JIRA) jira-events at lists.jboss.org
Fri Nov 27 07:04:29 EST 2009


    [ https://jira.jboss.org/jira/browse/JBRULES-2348?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12496957#action_12496957 ] 

Richard Ambridge commented on JBRULES-2348:
-------------------------------------------

If i change this from:
   for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
                    lastType = type;
                    type.setTypeClass( this.rootClassLoader.loadClass( pkg.getName() + "." + type.getTypeName() ) );
                }
            }
        } catch ( ClassNotFoundException e ) {
            throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName() + "'" );
        } 

to:  (using getTypeClassName  and remove the pkg.getName())

 for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
                    lastType = type;
                    type.setTypeClass( this.rootClassLoader.loadClass( type.getTypeClassName() ) );
                }
            }
        } catch ( ClassNotFoundException e ) {
            throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeClassName() + "'" );
        }

it works.

> unable to resolve Type Declaration class
> ----------------------------------------
>
>                 Key: JBRULES-2348
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-2348
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-compiler, drools-guvnor
>    Affects Versions: 5.0.1.FINAL, 5.1.0.M1
>         Environment: Ubuntu 8.04
>            Reporter: Richard Ambridge
>            Assignee: Mark Proctor
>         Attachments: repository_export.zip, workbench.tar
>
>
> Using the following code to create a Knowledge Base from a guvnor compiled pkg, (download the pkg and put in /tmp/my.pkg)
>  	private static KnowledgeBase readKnowledgeBase() throws Exception {
> 		KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
> 		File pkgFile = new File("/tmp/my.pkg");
>       if (pkgFile.exists() == false) {
>           System.out.println("Unable to find rule pkg");
>       } else {
>     	  System.out.println("RuleService. adding pkg");
>     	  kbuilder.add(ResourceFactory.newFileResource(pkgFile), ResourceType.PKG);
>       }
> 		KnowledgeBuilderErrors errors = kbuilder.getErrors();
> 		if (errors.size() > 0) {
> 			for (KnowledgeBuilderError error: errors) {
> 				System.err.println(error);
> 			}
> 			throw new IllegalArgumentException("Could not parse knowledge.");
> 		}
> 		KnowledgeBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
> 		conf.setOption(EventProcessingOption.STREAM);
> 		KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
> 		kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
> 		
> 		return kbase;
> 	}
> The pkg was created from Guvnor.
> If in the package declaration area in Guvnor,  (where you put the import statements)
> If I put
> import com.sample.Message
> declare Message
>   @role( event )
> end
> then build the package, save it to disk /tmp/my.pkg
> on startup I get:
> org.drools.RuntimeDroolsException: unable to resolve Type Declaration class 'Message'
> 	at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:759)
> 	at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:516)
> 	at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
> 	at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:69)
> 	at com.sample.DroolsTest.main(DroolsTest.java:27)
> I am unable to declare an object as an event type in guvnor. This prevents any rules creation and compiling :(
> Attached is the workbench from eclipse, and the guvnor repository export

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list