Spring, KnowledgeAgent, and Guvnor

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Spring, KnowledgeAgent, and Guvnor

paulB
I'm having a problem connecting my KnowledgeAgent to a package in Guvnor.  I'm using Spring to instantiate the KnowledgeAgent.  The agent initializes perfectly well when I point to a local change-set that in-turn points to a local rule.  However, even though I have the same rule in a package in Guvnor, the KnowledgeAgent fails with the following exception when I point to the package's change-set in Guvnor:

java.lang.NullPointerException
	at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:148)
	at org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1016)
	at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:785)
	at org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:657)
	at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:190)
	at org.drools.container.spring.beans.KnowledgeAgentBeanFactory.afterPropertiesSet(KnowledgeAgentBeanFactory.java:91)
...


The code at KnowledgeBaseImpl.java:148 is (using 5.3.0.Final):

    public void addKnowledgePackages(Collection<KnowledgePackage> knowledgePackages) {
        List<Package> list = new ArrayList<Package>();
        for ( KnowledgePackage knowledgePackage : knowledgePackages ) {
            list.add( ((KnowledgePackageImp) knowledgePackage).pkg  );   //148
        }
        ((ReteooRuleBase)ruleBase).addPackages( list);
    }


Here is the simple rule in the Guvnor as returned by the URL for the package source URL:

package Survey


declare TestTest
	jojo: String
end

rule "CompleteSurvey"
	dialect "mvel"
	no-loop
	when
		Object()
	then
		System.out.println("\r\nCOMPLETESURVEY FIRED!!\r\n");
end


Here is the local change-set definition.  The line that is commented is the failing resource, whereas the local file resource works fine:

<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.xsd' >
  <add>
      <resource source='file:c:/etc/drools/Test.drl' type='DRL' /> 
	<!-- <resource source='http://myTCServer:8080/guvnor-5.2.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/package/Survey/LATEST/ChangeSet.xml' type='PKG' />-->
  </add>
</change-set>


Guvnor is residing on a Tomcat server.

I could not find anything related to this on the forum.  Thank you for any hints.

-Paul
Reply | Threaded
Open this post in threaded view
|

Re: Spring, KnowledgeAgent, and Guvnor

paulB
My apologies, the above change-set is not what I had for the given failure (in reference to the commented line).  Instead I had put the URL for the change-set of Guvnor in my spring configuration.  The example above has PKG as the resource for the Guvnor change-set.  That is incorrect and not what I did.

Here's a snippet of my Spring configuration that fails with the above exception:

		<drools:kbase id="kbase1" />
		
	    
	    <drools:kagent id="kAgent1" kbase="kbase1">
			<drools:resources>
				<drools:resource type="CHANGE_SET" source="http://myTCServer:8080/guvnor-5.2.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/package/Survey/LATEST/ChangeSet.xml" />
			</drools:resources>
		</drools:kagent>


Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Spring, KnowledgeAgent, and Guvnor

paulB
Seems that upgrading my Guvnor install to match the version Drools in my project has done the trick to some extent.  Still dealing with some errors, but the original error has not presented itself.
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Spring, KnowledgeAgent, and Guvnor

Mark Proctor
We'll be working on deployment next year that is not tied to specific versions of drools. The reason for this is that the Packge is really just a cached form representing the DRL, to avoid compiling drls on the client. We actually just serialise the resulting objects. But internally we do a lot of changes as we add features, so binary compatability of these cached objects is not easily and cheapily possible.

In the future we hope to produec a simpler intermediary format that will be durable across different versions of drools. It will require the clients to do a bit more work, as it won't be as cheap as serialisation. But we hope that it'll be an acceptable trade off.

Mark

On Mon, Nov 28, 2011 at 5:23 PM, paulB <[hidden email]> wrote:
Seems that upgrading my Guvnor install to match the version Drools in my
project has done the trick to some extent.  Still dealing with some errors,
but the original error has not presented itself.

--
View this message in context: http://drools.46999.n3.nabble.com/Spring-KnowledgeAgent-and-Guvnor-tp3500761p3542830.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: Spring, KnowledgeAgent, and Guvnor

ganeshneelekani
In reply to this post by paulB
Hi

Can you please provide me sample code involves spring and drools


Thanks
Ganesh Neelekani