[
https://issues.jboss.org/browse/JBRULES-3630?page=com.atlassian.jira.plug...
]
Chris Rankin edited comment on JBRULES-3630 at 9/20/12 8:44 AM:
----------------------------------------------------------------
According to the [Drools
documentation|http://docs.jboss.org/drools/release/5.4.0.Final/drools-exp...]:
{quote}Using the ClassPath resource loader in Java allows you to specify the Class Loader
to be used to locate the resource but this is not possible from XML. Instead, the Class
Loader will default to the one used by the Knowledge Builder unless the ChangeSet XML is
itself loaded by the ClassPath resource, in which case it will use the Class Loader
specified for that resource.{quote}
In my case, both my {{ClassPath}} resource and my {{KnowledgeBuilder}} have been
configured to use my custom class loader, and so I am forced to assume that the failure to
locate the {{.drl}} file referred to by the change set is a bug in Drools.
was (Author: chrisjr):
According to the [Drools
documentation|http://docs.jboss.org/drools/release/5.4.0.Final/drools-exp...]:
{quote}Using the ClassPath resource loader in Java allows you to specify the Class Loader
to be used to locate the resource but this is not possible from XML. Instead, the Class
Loader will default to the one used by the Knowledge Builder unless the ChangeSet XML is
itself loaded by the ClassPath resource, in which case it will use the Class Loader
specified for that resource.{quote}
In my case, both my {{ClassPath}} resource and my {{KnowledgeBuilder}} have been
configured to use my custom class loader, and so I am forced to assume that the failure to
locate the {{.drl}} file is a bug in Drools.
Nested ClassPathResources within ChangeSet use wrong ClassLoader
----------------------------------------------------------------
Key: JBRULES-3630
URL:
https://issues.jboss.org/browse/JBRULES-3630
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core
Affects Versions: 5.1.1.FINAL, 5.4.0.Final
Environment: Win7 / Java6 / JBoss6
Reporter: Chris Rankin
Assignee: Mark Proctor
I am trying to load a "rules" JAR dynamically. This JAR contains a
{{change-set.xml}} and all of its DRL files:
{code:XML}
<?xml version="1.0" encoding="UTF-8"?>
<change-set
xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...
<add>
<resource source='classpath:com/my/stuff/rules/Stuff.drl'
type='DRL' />
</add>
</change-set>
{code}
I am loading the JAR dynamically via {{URLClassLoader}} and _successfully_ creating the
ChangeSet resource:
{code}
Resource changeSet = ResourceFactory.newClassPathResource("change-set.xml",
classLoader);{code}
However, it then always explodes when I try to add the resource to the
{{KnowledgeBuilder}}, complaining that "'com/my/stuff/rules/Stuff.drl' cannot
be opened because it does not exist".
I am suspecting that the {{KnowledgeBuilder}} is not using my class loader to load
{{Stuff.drl}}, despite me passing the correct class loader in via
{{KnowledgeBuilderConfiguration}}. (And the "changeset:" handling in
{{org.drools.xml.changeset.ResourceHandler}} would seem to support my theory.)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira