[rules-users] unable to update the changes (guvnor rules) to application using changeset

Michael Anstis michael.anstis at gmail.com
Wed Jan 25 08:51:14 EST 2012


OK, in which case I don't believe there is an alternative to what you are
attempting.

Technology aside the requirement is the same:-

   - Download remote resource (JARs in your case)
   - Add resource to local environment (JARs to required classpath in your
   case)

My advice would have been:-

   - Use the REST API to retrieve a list of assets.
   - Iterate list identifying which assets are model JARs
   - Iterate JAR list and use REST API to download binary

How you add the binary to your classpath is up to you.

This is obviously what you are doing.

2012/1/25 Voradov <madalin100884 at yahoo.com>

> Hi, the context is that somebody else creates the fact models and puts
> them there along with the rules.
>
> I have to create a knowledge agent without knowing the rules and jars, but
> only knowing the links to those PKG.
>
> The classloader will be used later for constructing facts in an automated
> fashion (something like genarating java code) and which need to be tested
> by the knowledge agent.
>
> How should I fulfill this remote class loading of the jar files?
>
>
>
>
> --- On *Wed, 1/25/12, manstis [via Drools] <[hidden email]<http://user/SendEmail.jtp?type=node&node=3687677&i=0>
> >* wrote:
>
>
> From: manstis [via Drools] <[hidden email]<http://user/SendEmail.jtp?type=node&node=3687677&i=1>
> >
> Subject: Re: [rules-users] unable to update the changes (guvnor rules) to
> application using changeset
> To: "Voradov" <[hidden email]<http://user/SendEmail.jtp?type=node&node=3687677&i=2>
> >
> Date: Wednesday, January 25, 2012, 3:17 PM
>
> Why not just ensure the model JARs uploaded to Guvnor are also on the KA's
> classpath?
>
> This of course assumes you have the JARs in the first place, and they are
> not added remotely to Guvnor by another user, in a different location.
>
> If this is however the case then you'd have the same problem whether using
> KA or not; i.e. needing JARs you don't have.
>
> 2012/1/25 Voradov <[hidden email]>
>
> Hi, exactly, this is the issue:
> I have a remote Guvnor server, not a local one and I had tried to set up a
> changeset.xml with PKG type links to the remote contained packages, in
> order to load in a local running agent those packages.
>
> But it was not enough.
> When loading the packages, it does not know to load also the jar files, so
> because of this, somehow the jars should be added in the classpath. At this
> moment i ended by filling the classpath of my local running eclipse with
> all the local jars in order to create a running knowledge agent.
>
> I can use REST protocol to get all packages, and from there to obtain the
> URL of the contained jars from each package and to programmatically
> download locally the jars in a folder and after that, for each of them to
> do something like this
>
> URL jarURL = this.getClass().getResource(SomeExternalJar.jar);
> URLClassLoader ucl = new URLClassLoader(new URL[]{jarURL}, this
> .getClass().getClassLoader());
>
> But my question is if I cannot somehow avoid this and make it easier.
>
> So, the main question is: when having a remote guvnor having set packages
> with rules and fact models, how can I create a local knowledge agent and to
> fill it with some required fact models and rules from that remote guvnor
> server?
>
> At the first glace, I had expected when filling the knowledge agent with a
> remote package, along with the test cases and rules, also the jar files to
> be loaded, but it seems not.
>
> At this moment I cannot see any other option, than this one. I had read
> the entyre documentation, but i did not find something like this explained.
> Could you help me? Do you have an idea about how to do this more easier
> than presented above?
>
> Madalin Gavrilescu
>
>
> --- On *Wed, 1/25/12, manstis [via Drools] <[hidden email]<http://user/SendEmail.jtp?type=node&node=3687625&i=0>
> >* wrote:
>
>
> From: manstis [via Drools] <[hidden email]<http://user/SendEmail.jtp?type=node&node=3687625&i=1>
> >
> Subject: Re: [rules-users] unable to update the changes (guvnor rules) to
> application using changeset
> To: "Voradov" <[hidden email]<http://user/SendEmail.jtp?type=node&node=3687625&i=2>
> >
> Date: Wednesday, January 25, 2012, 2:48 PM
>
> What is it you are trying to achieve?
>
> If the change set contains DRL items the Classes used therein will need to
> be on your client-side classpath (as explained in Esteban's blog). If you
> want to use rules authored in Guvnor and Types declared in (or uploaded to)
> Guvnor you should use the PKG resource type in your change-set and build
> the package in Guvnor. I don't believe you should need to use a custom
> class loader *unless* you really want only the DRL in your change-set but
> your model classes only in Guvnor.
>
> On 25 January 2012 12:27, Voradov <[hidden email]> wrote:
>
>  Hi, Esteban, Hi srinivasasanda.
>
> My opinion regarding the issue posted by srinivasasanda is the following:
>
> Having the changeset filled with DRL's taken from local jBoss application
> and using it in a java local running knowledge agent which has not added
> into the classpath the fact models will fail, of course with that
> /"java.lang.RuntimeException: KnowledgeAgent exception while trying to
> deserialize KnowledgeDefinitionsPackage"./
>
> On the other hand, when having changeset.xml set as:
> /<add>
>        <resource source='file:D:\rulemaster.drl' type='DRL' />
>   </add>/
> is working because it seems that the fact models used in defining those
> packages are in the classpath.
>
> REST protocol is used correctly in the changeset.xml.
>
> The problem with remotely loading pkg\drl files using REST is that you
> should somehow specify a custom classloader, like this:
>
> /KnowledgeBaseConfiguration kbaseConfig =
> KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null,
> *customClassLoader*);
> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
> //kbase with custom classloader
> KnowledgeAgentConfiguration aconf =
> KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
> aconf.setProperty("drools.agent.useKBaseClassLoaderForCompiling", "true");
> KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("test
> agent", kbase, aconf);
>  kagent.applyChangeSet(ResourceFactory.newFileResource(changeSetFile));/
>
> My question is: is there any possibility to create the classloader
> identical
> to the remote classloader used by guvnor? if yes, could you please show us
> exactly how to load remotelly from guvnor?
>
> Here, at
>
> http://ilesteban.wordpress.com/2010/06/22/knowledge-agent-custom-class-loaders/
>
> http://ilesteban.wordpress.com/2010/06/22/knowledge-agent-custom-class-loaders/
> there is described how to create a custom classloader, but it is not
> specified how to create it based on the Guvnor's jar files already existing
> there.
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/unable-to-update-the-changes-guvnor-rules-to-application-using-changeset-tp3652824p3687543.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
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://drools.46999.n3.nabble.com/unable-to-update-the-changes-guvnor-rules-to-application-using-changeset-tp3652824p3687590.html
>  To unsubscribe from unable to update the changes (guvnor rules) to
> application using changeset, click here.
> NAML<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
> ------------------------------
> View this message in context: Re: [rules-users] unable to update the
> changes (guvnor rules) to application using changeset<http://drools.46999.n3.nabble.com/unable-to-update-the-changes-guvnor-rules-to-application-using-changeset-tp3652824p3687625.html>
>
> Sent from the Drools: User forum mailing list archive<http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html>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
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://drools.46999.n3.nabble.com/unable-to-update-the-changes-guvnor-rules-to-application-using-changeset-tp3652824p3687649.html
>  To unsubscribe from unable to update the changes (guvnor rules) to
> application using changeset, click here.
> NAML<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
> ------------------------------
> View this message in context: Re: [rules-users] unable to update the
> changes (guvnor rules) to application using changeset<http://drools.46999.n3.nabble.com/unable-to-update-the-changes-guvnor-rules-to-application-using-changeset-tp3652824p3687677.html>
> Sent from the Drools: User forum mailing list archive<http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html>at Nabble.com.
>
> _______________________________________________
> 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/20120125/fc58dda8/attachment.html 


More information about the rules-users mailing list