<p><br>
Am 23.09.2011 20:03 schrieb "TroyL" <<a href="mailto:troylparrish@aol.com">troylparrish@aol.com</a>>:<br>
><br>
> Thank you for the reply. I have run a number of much simpler applications in<br>
> several environments, below are my results:<br>
><br>
> 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>><br>
> *My Test Application*:<br>
><br>
> KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
> builder.add(ResourceFactory.newClassPathResource("declaredType.drl"),<br>
> ResourceType.DRL);<br>
><br>
> if(builder.hasErrors()){<br>
> System.out.println(builder.getErrors().toString());<br>
> }<br>
><br>
> KnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase();<br>
> base.addKnowledgePackages(builder.getKnowledgePackages());<br>
><br>
> StatefulKnowledgeSession session = base.newStatefulKnowledgeSession();<br>
><br>
> Test test = new Test();<br>
> test.setName("Test");<br>
><br>
> session.insert(test);<br>
> session.fireAllRules();<br>
><br>
> session.dispose();<br>
><br>
> *My DRL*:<br>
><br>
> package com.test<br>
><br>
> declare SubTest<br>
><br>
> name : String<br>
> id : int<br>
><br>
> end<br>
><br>
> rule "Test Rule"<br>
><br>
> when<br>
> Test(name == "Test")<br>
> then<br>
> SubTest sTest = new SubTest();<br>
> sTest.setName("SubTest");<br>
> sTest.setId(12);<br>
> System.out.println("Test Ran");<br>
> System.out.println(sTest.getName() + " " + sTest.getId());<br>
><br>
> end<br>
><br>
> When I run my test application the drl compiles and I get the following<br>
> output to the console:<br>
><br>
> Test Ran<br>
> SubTest 12<br>
><br>
> However I get the following error when trying to compile it with the Ant<br>
> Script:<br>
><br>
> [compiler] Duplicate type definition. A class with the name<br>
> 'com.test.SubTest' was found in the classpath while<br>
><br>
> trying to redefine the fields in the declare statement. Fields can only be<br>
> defined for non-existing classes.<br>
><br>
> BUILD FAILED<br>
> C:\Users\troy.l\conceptsWorkspace\DeclaredType\build1.xml:23: RuleBaseTask<br>
> failed: Duplicate type definition. A<br>
><br>
> class with the name 'com.test.SubTest' was found in the classpath while<br>
> trying to redefine the fields in the<br>
><br>
> declare statement. Fields can only be defined for non-existing classes.<br>
><br>
> This error goes away when the Declared Type has only one field IE:<br>
><br>
> declare SubTest<br>
><br>
> name : String<br>
><br>
> end<br>
><br>
> The drl compiles into a PKG and the I can successfully use the PKG in my<br>
> test application when the Declared Type has only one field. Also I do not<br>
> have this issue in other Drools versions (I have tried 5.1.1, 5.0.1 and<br>
> 5.2.0.M2).<br>
><br>
> This is a stand alone test application and the above represents almost the<br>
> entire test project with the exception of the Test.java class which is a<br>
> pojo.<br>
><br>
> Thanks again for responding.<br>
><br>
> --<br>
> 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>
> Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</p>