7 Replies Latest reply on Jul 31, 2007 12:12 PM by stu2

    SeamTest breaks on drools 4.0

    stu2

      Scenario:

      Create a new seam-gen project, using lastest Seam from CVS. Use seam-gen to create a new action. Run the unit test. It fails with the following:

      aused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not in the classpath
      at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:98)
      at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:56)
      at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(PackageBuilderConfiguration.java:134)
      ... 57 more
      ... Removed 28 stack frames


      I've recently upgraded my app to latest seam from CVS, and am getting the same symptoms. Is this working for others? I see one other person on google having the issue, but didn't find a resolution. Is this working for others?

        • 1. Re: SeamTest breaks on drools 4.0
          ellenzhao

          There are two solutions:

          1.delete the Janino compiler in Seam lib and use Eclipse compiler. You can get the Eclipse compiler after downloading the Drools 4.0 binary. In the drools/lib, you see a core-xxxx.jar. That is Eclipse compiler. Drop it into your Seam lib folder, edit your build.xml, edit your application.xml.

          2. Drools 4.0 uses Eclipse compiler by default. You can use Janino compiler, but you need to provide a conf file. Example please see here:

          http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-compiler/src/main/resources/META-INF/drools.default.packagebuilder.conf

          Regards,
          Ellen

          • 2. Re: SeamTest breaks on drools 4.0
            stu2

             

            "ellenzhao" wrote:
            There are two solutions:

            1.delete the Janino compiler in Seam lib and use Eclipse compiler. You can get the Eclipse compiler after downloading the Drools 4.0 binary. In the drools/lib, you see a core-xxxx.jar. That is Eclipse compiler. Drop it into your Seam lib folder, edit your build.xml, edit your application.xml.

            Regards,
            Ellen


            Thanks Ellen. I tried the first option, grabbing the Drools 4.0 distribution. I copied the lib over, and added

            <module>
             <java>core-3.2.3.v_686_R32x.jar</java>
             </module>


            to application.xml, and removed the janino.jar. After a clean build and making sure the jars were in test-build, I still get the same exception though.

            For the Seam guys, is this something new seam-gen users are expected to setup? Or has seam-gen not yet been updated since the drools update?

            Any suggestions are appreciated.

            • 3. Re: SeamTest breaks on drools 4.0
              stu2

              Oh, and after doing the above, drools is now not working when I startup the app for real - so obviously I've done something wrong. Here's what I see:

              Caused by: java.lang.NoSuchMethodError: org.drools.compiler.PackageBuilderConfiguration.setCompiler(I)V
               at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:41)
               ... 85 more


              Anyone know what I'm doing wrong? And is seam-gen working correctly or is it just me?

              • 4. Re: SeamTest breaks on drools 4.0
                shane.bryzak

                Update to latest CVS - setCompiler() is no longer called in RuleBase.

                • 5. Re: SeamTest breaks on drools 4.0
                  stu2

                  Thanks Shane. It works fine from within JBoss, but when I run the unit test here's what I see:

                  FAILED CONFIGURATION: @BeforeMethod begin
                  org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
                   at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(PackageBuilderConfiguration.java:138)
                   at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:114)
                   at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:87)
                   at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:40)
                   at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
                   at org.jboss.seam.Component.callComponentMethod(Component.java:2067)
                   at org.jboss.seam.Component.callCreateMethod(Component.java:1990)
                   at org.jboss.seam.Component.newInstance(Component.java:1961)
                   at org.jboss.seam.Component.getInstance(Component.java:1858)
                   at org.jboss.seam.Component.getInstance(Component.java:1825)
                   at org.jboss.seam.security.RuleBasedIdentity.initSecurityContext(RuleBasedIdentity.java:62)
                   at org.jboss.seam.security.RuleBasedIdentity.create(RuleBasedIdentity.java:55)
                   at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
                   at org.jboss.seam.Component.callComponentMethod(Component.java:2067)
                   at org.jboss.seam.Component.callCreateMethod(Component.java:1990)
                   at org.jboss.seam.Component.newInstance(Component.java:1961)
                   at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
                   at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
                   at org.jboss.seam.contexts.Lifecycle.beginSession(Lifecycle.java:187)
                   at org.jboss.seam.contexts.ServletLifecycle.beginSession(ServletLifecycle.java:124)
                   at org.jboss.seam.mock.BaseSeamTest.begin(BaseSeamTest.java:877)
                   at org.jboss.seam.mock.SeamTest.begin(SeamTest.java:28)
                   at com.fb.core.test.support.SeamDbUnitTest.begin(SeamDbUnitTest.java:59)
                  Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not in the classpath
                   at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:98)
                   at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:56)
                   at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(PackageBuilderConfiguration.java:134)
                   ... 56 more
                  ... Removed 32 stack frames


                  This is what I've been seeing consistently. Any ideas?

                  • 6. Re: SeamTest breaks on drools 4.0
                    dmitriy.lapko

                    I had the same problem and went by second way proposed ellenzhao (thank you :) )

                    Just add to /resources/META-INF file drools.default.packagebuilder.conf
                    with next contents:

                    drools.dialect.default = java
                    drools.dialect.java = org.drools.rule.builder.dialect.java.JavaDialectConfiguration
                    drools.dialect.java.compiler = JANINO
                    
                    drools.dialect.mvel = org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration
                    drools.dialect.mvel.strict = true
                    
                    drools.accumulate.function.average = org.drools.base.accumulators.AverageAccumulateFunction
                    drools.accumulate.function.max = org.drools.base.accumulators.MaxAccumulateFunction
                    drools.accumulate.function.min = org.drools.base.accumulators.MinAccumulateFunction
                    drools.accumulate.function.count = org.drools.base.accumulators.CountAccumulateFunction
                    drools.accumulate.function.sum = org.drools.base.accumulators.SumAccumulateFunction


                    and add janino-2.5.7.jar into classpath.

                    Next problem I experienced in tests was NoCacheProviderException, I fixed it by adding

                    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>


                    into persistence.xml.

                    Also after some manipulation tests successfully worked (I have both component and integration tests).

                    Some experienced problems:
                    1) I compiled seam under JDK 1.6 but tests failed to start in JRE 1.6 because jboss-embedded-all.jar is build under JDK 1.5 and can not be started in 1.6 (the problem with Class.forName and loadClass methods), so I rebuilt seam under JDK 1.5 and start it in JRE 1.5.
                    2) Output dir in Eclipse project should contain only one *-ds.xml, so just exclude other from class path to prevent error with already added datasource

                    And when I managed to start my tests, they work so slowly!!! I think, it is awful... How can I practice TDD with SEAM??? Everything is bound to its environment, and for tests I have to start so many stuff... I'm in despair... Someone, give me a hope!

                    • 7. Re: SeamTest breaks on drools 4.0
                      stu2

                      Thanks Dmitriy. I'll try that again.

                      As for slow test startup, I try to design so that much of the "interesting" logic can be tested in vanilla unit tests (not extending SeamTest) with dependencies filled via JMock. Because you're right, waiting 15 seconds for the test to start up slows things down considerably at certain phases of development. Anyway, I've found that if the tricky business logic is testable outside of SeamTest, all that remains ends up being rather straightforward.