Am 23.09.2011 20:03 schrieb "TroyL" <troylparrish@aol.com>:
>
> Thank you for the reply.  I have run a number of much simpler applications in
> several environments, below are my results:
>
> My Ant Script remains unchanged.

Next things to try could be:
- increase verbosity of your ant compile so you can see what is actually being compiled.
- make sure the Ant build is as similar as possible to your unit test (observe verbose output of Ant build carefully)

Best regards,

Ansgar

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