<p><br>
Am 23.09.2011 20:03 schrieb &quot;TroyL&quot; &lt;<a href="mailto:troylparrish@aol.com">troylparrish@aol.com</a>&gt;:<br>
&gt;<br>
&gt; Thank you for the reply.  I have run a number of much simpler applications in<br>
&gt; several environments, below are my results:<br>
&gt;<br>
&gt; My Ant Script remains unchanged.</p>
<p>Next things to try could be:<br>
- increase verbosity of your ant compile so you can see what is actually being compiled.<br>
- make sure the Ant build is as similar as possible to your unit test (observe verbose output of Ant build carefully)</p>
<p>Best regards,</p>
<p>Ansgar<br><br></p>
<p>&gt;<br>
&gt; *My Test Application*:<br>
&gt;<br>
&gt; KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
&gt;                builder.add(ResourceFactory.newClassPathResource(&quot;declaredType.drl&quot;),<br>
&gt; ResourceType.DRL);<br>
&gt;<br>
&gt;                if(builder.hasErrors()){<br>
&gt;                        System.out.println(builder.getErrors().toString());<br>
&gt;                }<br>
&gt;<br>
&gt;                KnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase();<br>
&gt;                base.addKnowledgePackages(builder.getKnowledgePackages());<br>
&gt;<br>
&gt;                StatefulKnowledgeSession session = base.newStatefulKnowledgeSession();<br>
&gt;<br>
&gt;                Test test = new Test();<br>
&gt;                test.setName(&quot;Test&quot;);<br>
&gt;<br>
&gt;                session.insert(test);<br>
&gt;                session.fireAllRules();<br>
&gt;<br>
&gt;                session.dispose();<br>
&gt;<br>
&gt; *My DRL*:<br>
&gt;<br>
&gt; package com.test<br>
&gt;<br>
&gt; declare SubTest<br>
&gt;<br>
&gt;        name : String<br>
&gt;        id : int<br>
&gt;<br>
&gt; end<br>
&gt;<br>
&gt; rule &quot;Test Rule&quot;<br>
&gt;<br>
&gt;        when<br>
&gt;                Test(name == &quot;Test&quot;)<br>
&gt;        then<br>
&gt;                SubTest sTest = new SubTest();<br>
&gt;                sTest.setName(&quot;SubTest&quot;);<br>
&gt;                sTest.setId(12);<br>
&gt;                System.out.println(&quot;Test Ran&quot;);<br>
&gt;                System.out.println(sTest.getName() + &quot; &quot; + sTest.getId());<br>
&gt;<br>
&gt; end<br>
&gt;<br>
&gt; When I run my test application the drl compiles and I get the following<br>
&gt; output to the console:<br>
&gt;<br>
&gt; Test Ran<br>
&gt; SubTest 12<br>
&gt;<br>
&gt; However I get the following error when trying to compile it with the Ant<br>
&gt; Script:<br>
&gt;<br>
&gt; [compiler] Duplicate type definition. A class with the name<br>
&gt; &#39;com.test.SubTest&#39; was found in the classpath while<br>
&gt;<br>
&gt; trying to redefine the fields in the declare statement. Fields can only be<br>
&gt; defined for non-existing classes.<br>
&gt;<br>
&gt; BUILD FAILED<br>
&gt; C:\Users\troy.l\conceptsWorkspace\DeclaredType\build1.xml:23: RuleBaseTask<br>
&gt; failed: Duplicate type definition. A<br>
&gt;<br>
&gt; class with the name &#39;com.test.SubTest&#39; was found in the classpath while<br>
&gt; trying to redefine the fields in the<br>
&gt;<br>
&gt; declare statement. Fields can only be defined for non-existing classes.<br>
&gt;<br>
&gt; This error goes away when the Declared Type has only one field IE:<br>
&gt;<br>
&gt; declare SubTest<br>
&gt;<br>
&gt; name : String<br>
&gt;<br>
&gt; end<br>
&gt;<br>
&gt; The drl compiles into a PKG  and the I can successfully use the PKG in my<br>
&gt; test application when the Declared Type has only one field.  Also I do not<br>
&gt; have this issue in other Drools versions (I have tried 5.1.1, 5.0.1 and<br>
&gt; 5.2.0.M2).<br>
&gt;<br>
&gt; This is a stand alone test application and the above represents almost the<br>
&gt; entire test project with the exception of the Test.java class which is a<br>
&gt; pojo.<br>
&gt;<br>
&gt; Thanks again for responding.<br>
&gt;<br>
&gt; --<br>
&gt; View this message in context: <a href="http://drools.46999.n3.nabble.com/Re-rules-users-Ant-Build-of-PKG-with-Declared-Types-tp3362455p3362596.html">http://drools.46999.n3.nabble.com/Re-rules-users-Ant-Build-of-PKG-with-Declared-Types-tp3362455p3362596.html</a><br>

&gt; Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</p>