Hi Michael, that is exactly what I think. Once your application is deployed, the URL should be static. The idea of what I&#39;m trying to do is to maintain the definitions of your change-sets using classpath notation. Then, when the application loads the resources, it converts them to static URLs.<div>

<br></div><div>Thanks!</div><div><br></div><div>Best Regards, <div><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>

- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Fri, Apr 15, 2011 at 6:45 PM, Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<p>Aren&#39;t the &#39;converted&#39; Urls just transient? I.e. tied to a runtime installation? So what is the danger of platform specific conversion?</p>
<p>sent on the move</p>
<p></p><div><div></div><div class="h5">On 15 Apr 2011 22:40, &quot;Esteban Aliverti&quot; &lt;<a href="mailto:esteban.aliverti@gmail.com" target="_blank">esteban.aliverti@gmail.com</a>&gt; wrote:<br type="attribution">&gt; Hi Geoffrey,<br>

&gt; thanks for sharing your opinion!<br>
&gt; <br>&gt; When drools-spring creates the resource from the configuration file, it<br>&gt; creates it passing the class&#39; class loader:<br>&gt; <br>&gt; new ClassPathResource(path, ClassPathResource.class.getClassLoader() );<br>


&gt; <br>&gt; Internally, ClassPathResource is doing:<br>&gt; <br>&gt; this.classLoader = ClassLoaderUtil.getClassLoader( new ClassLoader[] {<br>&gt; classLoader },null, false );<br>&gt; <br>&gt; So, a classloader is indeed supplied. AFAIK, the problem is that the<br>


&gt; provided classloader is tomcat&#39;s classloader.<br>&gt; <br>&gt; I know it is dangerous to store native URLs instead of the classpath, but<br>&gt; after all, after you deploy drools-server, each of the resources will have<br>


&gt; an URL.<br>&gt; If this is a problem, you can always use classpath resources. That is why I<br>&gt; thought in a new Resource type and not in modify ClassPathResource class.<br>&gt; <br>&gt; I have created an issue for this:<br>


&gt; <a href="https://issues.jboss.org/browse/JBRULES-2960" target="_blank">https://issues.jboss.org/browse/JBRULES-2960</a><br>&gt; <br>&gt; Thanks again for your time!<br>&gt; <br>&gt; Best Regards,<br>&gt; <br>&gt; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>


&gt; <br>&gt; Esteban Aliverti<br>&gt; - Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>&gt; - Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>

&gt; <br>&gt; <br>
&gt; On Fri, Apr 15, 2011 at 9:38 AM, Geoffrey De Smet<br>&gt; &lt;<a href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>&gt;wrote:<br>&gt; <br>&gt;&gt;  The kbuilder uses the second method of ClassPathResource<br>


&gt;&gt; (getInputStream()) to get the content of the resource.<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Shouldn&#39;t that also supply a ClassLoader or a Class (of which<br>&gt;&gt; Class.getClassLoader() is used)?<br>&gt;&gt;<br>


&gt;&gt;<br>&gt;&gt; This resource type will let you define your resources present in your<br>&gt;&gt; classpath as usually but it will translate them to URL Resource internally.<br>&gt;&gt;<br>&gt;&gt; It&#39;s probably dangerous to store the native URL the concept of a classpath<br>


&gt;&gt; is designed to have a map of files &quot;that are just there&quot; and you don&#39;t need<br>&gt;&gt; to worry what&#39;s the OS-specific underlying details.<br>&gt;&gt; Instead, I believe, the classpath key (for example &quot;simpler.drl&quot;) and the<br>


&gt;&gt; ClassLoader (for example MyApp.class.getClassLoader()) should be stored.<br>&gt;&gt;<br>&gt;&gt; Op 15-04-11 13:52, Esteban Aliverti schreef:<br>&gt;&gt;<br>&gt;&gt; Hi Guys,<br>&gt;&gt;<br>&gt;&gt;  I want to discuss a problem I have found when using the combination of<br>


&gt;&gt; knowledge agent + classpathResources.<br>&gt;&gt; I will try to describe what am I doing first to give you some context.<br>&gt;&gt; I&#39;m deploying drools-camel-server in a Tomcat 7 container. Inside the<br>&gt;&gt; WEB-INF/classes directory I have some DRL files that I want to use.<br>


&gt;&gt; My knowledge-services.xml file declares the following kagent:<br>&gt;&gt;<br>&gt;&gt;  &lt;drools:kagent id=&quot;kagent1&quot; kbase=&quot;kbase1&quot; new-instance=&quot;false&quot;&gt;<br>&gt;&gt;  &lt;drools:resources&gt;<br>


&gt;&gt;              &lt;drools:resource type=&quot;DRL&quot; source=&quot;*classpath*:simple.drl&quot;/&gt;<br>&gt;&gt;              ...<br>&gt;&gt;     &lt;/drools:resources&gt;<br>&gt;&gt; &lt;/drools:kagent&gt;<br>&gt;&gt;<br>


&gt;&gt;  When spring parses this configuration file it creates a KnowledgeAgent<br>&gt;&gt; instance with a ChangeSet containing all the listed resources.<br>&gt;&gt; The next step is to start ResourceChangeNotifierService<br>


&gt;&gt; and ResourceChangeScannerService.<br>&gt;&gt; So far so good.<br>&gt;&gt;<br>&gt;&gt;  The problem:<br>&gt;&gt; The problem I&#39;m having is not directly related to drools, but I think it is<br>&gt;&gt; quite easy to provide a solution for the people that is in my same<br>


&gt;&gt; situation.<br>&gt;&gt;<br>&gt;&gt;  ClassPathResource is the class that represents a resource defined as &quot;*<br>&gt;&gt; classpath:&quot;*<br>&gt;&gt;<br>&gt;&gt;  This class has 2 important methods:<br>&gt;&gt;<br>


&gt;&gt;   public long getLastModified(){<br>&gt;&gt;   return this.classLoader.getResource( this.path<br>&gt;&gt; ).openConnection().getLastModified();<br>&gt;&gt; }<br>&gt;&gt;<br>&gt;&gt;  public InputStream getInputStream(){<br>


&gt;&gt;   return this.classLoader.getResourceAsStream( this.path );<br>&gt;&gt; }<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;  The first method is used by ResourceChangeScannerService to check whether<br>&gt;&gt; the resource has changed or not. It works fine. When the resource in the<br>


&gt;&gt; filesystem changes, the scanner detects the change without any problem.<br>&gt;&gt; The scanner ends up notifying the kagent about the change, and the kagent<br>&gt;&gt; passes the Resource to an instance of KnowledgeBuilder.<br>


&gt;&gt; An here is when things fail.<br>&gt;&gt; The kbuilder uses the second method of ClassPathResource (getInputStream())<br>&gt;&gt; to get the content of the resource. In the case of Tomcat (and probably some<br>&gt;&gt; other environments), it seems that the classloader (Tomcat&#39;s classloader) is<br>


&gt;&gt; using a cache. So the InputStream returned doesn&#39;t reflect the current state<br>&gt;&gt; of the resource.<br>&gt;&gt; Long story short: the agent is notified about a change in the resource, but<br>&gt;&gt; the change is never applied to the kbase because the kbuilder is unable to<br>


&gt;&gt; get it :P<br>&gt;&gt;<br>&gt;&gt;  Solutions:<br>&gt;&gt; The first solution is not to use classpath resources :). You can use just<br>&gt;&gt; url resources like http:// or file:/. But honestly, when you have your<br>


&gt;&gt; rules inside your webapp, it is much more comfortable and even manageable to<br>&gt;&gt; avoid the use of real paths.<br>&gt;&gt;<br>&gt;&gt;  What I was thinking about (I already have a working prototype) is to<br>


&gt;&gt; create a new Resource type for these cases. This resource type will let you<br>&gt;&gt; define your resources present in your classpath as usually but it will<br>&gt;&gt; translate them to URL Resource internally.<br>


&gt;&gt; So, in the example above:<br>&gt;&gt;<br>&gt;&gt;  &lt;drools:resource type=&quot;DRL&quot; source=&quot;*URLClasspath*:simple.drl&quot;/&gt;<br>&gt;&gt;<br>&gt;&gt;  is going to be translated (internally and in a transparent way) to<br>


&gt;&gt; something like:<br>&gt;&gt; file:/usr/local/apache-tomcat-7/webapps/MyWebapp/WEB-INF/simple.drl.<br>&gt;&gt;<br>&gt;&gt;  Opinions?<br>&gt;&gt;<br>&gt;&gt; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>&gt;&gt;<br>


&gt;&gt; Esteban Aliverti<br>&gt;&gt; - Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>&gt;&gt; - Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>

&gt;&gt;<br>
&gt;&gt;<br>&gt;&gt; _______________________________________________<br></div></div>&gt;&gt; rules-dev mailing listrules-dev@lists.jboss.orghttps://<a href="http://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">lists.jboss.org/mailman/listinfo/rules-dev</a><div class="im">

<br>
&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; --<br>&gt;&gt; With kind regards,<br>&gt;&gt; Geoffrey De Smet<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; _______________________________________________<br>&gt;&gt; rules-dev mailing list<br>&gt;&gt; <a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a><br>


&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>&gt;&gt;<br>&gt;&gt;<br></div><p></p>
<br>_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br></blockquote></div><br></div></div>