8 Replies Latest reply on Jul 12, 2006 5:58 AM by Ove Ranheim

    help with Maven 2 and SeamTest (part 2)

    Bradley Smith Master

      Hello,

      I have had some success in getting SeamTest tests to run under maven 2. However, now, when SeamTest tries to load the JBoss Microcontainer, it complains that it cannot find embedded-jboss-beans.xml. Here is the exception:

      14:41:36,499 DEBUG org.jboss.seam.Component.(debug:84) - instantiating Seam component: org.jboss.seam.core.ejb
      14:41:36,499 INFO org.jboss.seam.core.Ejb.(info:94) - starting the embedded EJB container
      14:41:36,546 DEBUG org.jboss.kernel.KernelFactory.(assembleNewKernel:86) - Starting JBoss Kernel construction...
      14:41:36,764 DEBUG org.jboss.kernel.KernelFactory.(assembleNewKernel:112) - Completed JBoss Kernel construction. Durati
      on: 218 milliseconds
      14:41:36,764 DEBUG org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.(loadMBeanServer:408) - !!loadMBeanServer servers 0
      14:41:36,764 DEBUG org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.(loadMBeanServer:411) - !!loadMBeanServer creating...
      
      java.lang.RuntimeException: java.lang.RuntimeException: Cannot find embedded-jboss-beans.xml
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:391)
       at org.jboss.seam.core.Ejb.startup(Ejb.java:38)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1334)
       at org.jboss.seam.Component.callCreateMethod(Component.java:1322)
       at org.jboss.seam.Component.newInstance(Component.java:1312)
       at org.jboss.seam.Component.getInstance(Component.java:1263)
       at org.jboss.seam.Component.getInstance(Component.java:1253)
       at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:125)
       at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:104)
       at org.jboss.seam.init.Initialization.init(Initialization.java:196)
       at org.jboss.seam.mock.SeamTest.init(SeamTest.java:321)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
       at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:318)
       at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:152)
       at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
       at org.testng.TestRunner.privateRun(TestRunner.java:682)
       at org.testng.TestRunner.run(TestRunner.java:566)
       at org.testng.SuiteRunner.privateRun(SuiteRunner.java:220)
       at org.testng.SuiteRunner.run(SuiteRunner.java:146)
       at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:713)
       at org.testng.TestNG.runSuitesLocally(TestNG.java:676)
       at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:64)
       at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
       at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
       at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
      Caused by: java.lang.RuntimeException: Cannot find embedded-jboss-beans.xml
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:379)
       ... 39 more
      Tests run: 5, Failures: 1, Errors: 0, Skipped: 4, Time elapsed: 2.437 sec <<< FAILURE!
      


      the microcontainer jars are in my class path (via the pom.xml). Also the microcontainer configuration files (*.xml) are in the class path of the test runner under target/test-classes/conf (here is a listing).

      bash-2.05b$ ls -l target/test-classes/conf/
      total 49
      -rwxrwxrwx 1 A428302 mkgroup-l-d 1020 Jun 27 08:17 default.persistence.properties
      -rwxrwxrwx 1 A428302 mkgroup-l-d 23397 Jun 27 08:17 ejb3-interceptors-aop.xml
      -rwxrwxrwx 1 A428302 mkgroup-l-d 4101 Jun 27 08:17 embedded-jboss-beans.xml
      -rwxrwxrwx 1 A428302 mkgroup-l-d 1907 Jun 27 14:41 jboss-beans.xml
      -rwxrwxrwx 1 A428302 mkgroup-l-d 11461 Jun 27 08:17 jboss-jms-beans.xml
      -rwxrwxrwx 1 A428302 mkgroup-l-d 1446 Jun 27 08:17 log4j.xml
      -rwxrwxrwx 1 A428302 mkgroup-l-d 2212 Jun 27 08:17 login-config.xml
      -rwxrwxrwx 1 A428302 mkgroup-l-d 502 Jun 27 08:17 security-beans.xml
      


      Here are the microcontainer jars listed as dependencies in my pom.xml:

      <!-- JBoss EJB3 Microcontainer for testing -->
       <dependency>
       <groupId>org.jboss.ejb3.microcontainer</groupId>
       <artifactId>jboss-ejb3-all</artifactId>
       <version>Alpha8.P2</version>
       <scope>test</scope>
       </dependency>
      
       <dependency>
       <groupId>org.jboss.ejb3.microcontainer</groupId>
       <artifactId>hibernate-all</artifactId>
       <version>Alpha8.P2</version>
       <scope>test</scope>
       </dependency>
      
       <dependency>
       <groupId>org.jboss.ejb3.microcontainer</groupId>
       <artifactId>thirdparty-all</artifactId>
       <version>Alpha8.P2</version>
       <scope>test</scope>
       </dependency>
      


      Has anyone else been able to get the microcontainer to come up for test purposes with Maven 2? If so, can you share your pom.xml and any other information you need to know about this?

      Thanks


        • 1. Re: help with Maven 2 and SeamTest (part 2)
          Bradley Smith Master

          In my components.xml file, I changed from the EJB component to the Microcontainer component...




          Now I am getting the following exception:

          16:23:09,077 DEBUG org.jboss.kernel.KernelFactory.(assembleNewKernel:86) - Starting JBoss Kernel construction...
          16:23:09,202 DEBUG org.jboss.kernel.KernelFactory.(assembleNewKernel:112) - Completed JBoss Kernel construction. Durati
          on: 125 milliseconds
          16:23:09,249 DEBUG org.jboss.seam.Component.(debug:84) - instantiating Seam component: org.jboss.seam.core.hibernate
          16:23:09,295 INFO org.hibernate.cfg.annotations.Version.(info:94) - Hibernate Annotations 3.2.0.CR1
          16:23:09,311 INFO org.hibernate.cfg.Environment.(info:94) - Hibernate 3.2 cr2
          16:23:09,327 INFO org.hibernate.cfg.Environment.(info:94) - hibernate.properties not found
          16:23:09,327 INFO org.hibernate.cfg.Environment.(info:94) - Bytecode provider name : cglib
          16:23:09,342 INFO org.hibernate.cfg.Environment.(info:94) - using JDK 1.4 java.sql.Timestamp handling
          16:23:09,467 INFO org.hibernate.cfg.Configuration.(info:94) - configuring from resource: /hibernate.cfg.xml
          16:23:09,467 INFO org.hibernate.cfg.Configuration.(info:94) - Configuration resource: /hibernate.cfg.xml
          16:23:09,639 INFO org.hibernate.cfg.Configuration.(info:94) - Configured SessionFactory: java:/appssoSessionFactory
          16:23:09,749 INFO org.hibernate.cfg.AnnotationBinder.(info:94) - Binding entity from annotated class: com.evergreen.use
          rlinks.orm.User
          16:23:09,827 INFO org.hibernate.cfg.annotations.EntityBinder.(info:94) - Bind entity com.evergreen.userlinks.orm.User o
          n table user
          org.hibernate.AnnotationException: @Temporal should be set on a java.util.Date or java.util.Calendar property: com.everg
          reen.userlinks.orm.User.createDate
           at org.hibernate.cfg.annotations.SimpleValueBinder.setType(SimpleValueBinder.java:88)
           at org.hibernate.cfg.annotations.PropertyBinder.bind(PropertyBinder.java:111)
           at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1521)
           at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:699)
           at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
           at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1205)
           at org.jboss.seam.core.Hibernate.startup(Hibernate.java:69)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32)
           at org.jboss.seam.Component.callComponentMethod(Component.java:1334)
           at org.jboss.seam.Component.callCreateMethod(Component.java:1322)
           at org.jboss.seam.Component.newInstance(Component.java:1312)
           at org.jboss.seam.Component.getInstance(Component.java:1263)
           at org.jboss.seam.Component.getInstance(Component.java:1253)
           at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:125)
           at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:104)
           at org.jboss.seam.init.Initialization.init(Initialization.java:196)
           at org.jboss.seam.mock.SeamTest.init(SeamTest.java:321)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
           at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:318)
           at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:152)
           at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
           at org.testng.TestRunner.privateRun(TestRunner.java:682)
           at org.testng.TestRunner.run(TestRunner.java:566)
           at org.testng.SuiteRunner.privateRun(SuiteRunner.java:220)
           at org.testng.SuiteRunner.run(SuiteRunner.java:146)
           at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:713)
           at org.testng.TestNG.runSuitesLocally(TestNG.java:676)
           at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:64)
           at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
           at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
           at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
          


          I am using the Alpha8 patch2 release of JBoss Embeddable EJB3 container (jboss-EJB-3.0_Embeddable_ALPHA_8-patch2) via:

          jboss-EJB-3.0_Embeddable_ALPHA_8-patch2
          


          I've seen the org.hibernate.AnnotationException:
          @Temporal should be set on a
          error before in the container (JBoss application server) I can't quite remember how/why it went away. Has anbody else seen this error message for the @Timestamp annotations? If so, how did you solve it?



          • 2. Re: help with Maven 2 and SeamTest (part 2)
            Bradley Smith Master

            Ugh! disregard the @Temporal error message - I remember how I fixed it - I had to move the @Temporal annotation to be in front of the field declaration instead of the getters for the temporal fields. Anyways - still looking for people to share their knowledge on getting Maven 2 to run SeamTest scripts with the Microcontainter and/or the Embeddable EJB container.

            Thanks

            • 3. Re: help with Maven 2 and SeamTest (part 2)
              Jye Tucker Newbie

              There's nothing too tricky to getting it running in Maven2.

              Your problem sounds like you need to take the config files out of target/test-classes/conf/ and just have them in target/test-classes/ instead.

              This means that if you are using a standard Maven2 layout, they should probably be in src/main/resources/ within your project.

              • 4. Re: help with Maven 2 and SeamTest (part 2)
                Bradley Smith Master

                jtucker - your suggestion on where to place the config files for testing got things working - thanks very much!

                as to putting things in the src/main/resources - I do not plan to use the test configuration for deployment - that's why I use the test-classes location.

                Now, I am having one new problem....

                 @Test
                 public void test_SessionStarter_create_delete_User() throws Exception {
                
                 new Script() {
                
                 @Override
                 protected void updateModelValues() {
                
                 log.info("updateModelValues()");
                
                 User user = (User)Component.getInstance("user", true);
                 log.info("user -> "+user);
                 assert user != null;
                 ....
                 }
                
                 ...
                 }.run();
                 }
                


                The above assertion is failing - it shouldn't because in the user class, I have defined:

                @Name("user")
                @Scope(ScopeType.SESSION)
                public class User extends BaseEntity implements Serializable {
                
                 ....
                }
                


                Now it looks like Seam itself is not getting initialized/loaded but the microcontainer....

                Any suggestions for this?

                Thanks

                • 5. Re: help with Maven 2 and SeamTest (part 2)
                  Bradley Smith Master

                  It looks like the final problem I am having is due to the fact that the my test cases are running from the test-classes directory (maven 2 convention for test classes). What's happening is that the Seam scanner is scanning test-classes only:

                  10:24:20,120 INFO org.jboss.seam.deployment.Scanner.(info:94) - scanning: c:\work\research\seam\userlinks\userlinks\tar
                  get\test-classes
                  10:24:20,120 DEBUG org.jboss.seam.deployment.Scanner.(debug:84) - directory: c:\work\research\seam\userlinks\userlinks\t
                  arget\test-classes
                  10:24:20,120 DEBUG org.jboss.seam.deployment.Scanner.(debug:84) - directory: c:\work\research\seam\userlinks\userlinks\t
                  arget\test-classes\com
                  10:24:20,136 DEBUG org.jboss.seam.deployment.Scanner.(debug:84) - directory: c:\work\research\seam\userlinks\userlinks\t
                  arget\test-classes\com\evergreen
                  10:24:20,136 DEBUG org.jboss.seam.deployment.Scanner.(debug:84) - directory: c:\work\research\seam\userlinks\userlinks\t
                  arget\test-classes\com\evergreen\userlinks
                  10:24:20,136 DEBUG org.jboss.seam.deployment.Scanner.(debug:84) - directory: c:\work\research\seam\userlinks\userlinks\t
                  arget\test-classes\com\evergreen\userlinks\biz
                  10:24:20,136 DEBUG org.jboss.seam.deployment.Scanner.(debug:84) - directory: c:\work\research\seam\userlinks\userlinks\t
                  arget\test-classes\WEB-INF
                  


                  However, all my Seam components (@Name(..)'ed classes) are located over in a parallel directory, classes. Is there a way to tell Seam to scan two locations?

                  Thanks

                  • 6. Re: help with Maven 2 and SeamTest (part 2)
                    Jye Tucker Newbie

                    Try putting an empty seam.properties file in your src/main/resources/.


                    ps. you are right of course about the src/main/resources/ for the conf files. Should be src/test/resources/

                    • 7. Re: help with Maven 2 and SeamTest (part 2)
                      Bradley Smith Master

                      That last suggestion worked too! Thanks again

                      • 8. Re: help with Maven 2 and SeamTest (part 2)
                        Ove Ranheim Novice

                        I'm struggeling a lot in order have Embedded EJB3 container running for TestNG cases. Can you provide me with an example of configuration.

                        What do you place under:

                        /src/main/resources
                        
                        /src/test/resources
                        


                        Please note that I use JBoss 4.0.4 + Seam 1.0.1. I have ported Seam DVDStore demo to Maven2. Packaging and deployment works all fine, but the test-cases want run correctly. I suspect to have a jndi-problem due to the LocalOnlyContextFactory. I am completly out of ideas.

                        /src/main/resources/META-INF/dvd-ds.xml
                        /src/main/resources/META-INF/ejb-jar.xml
                        /src/main/resources/META-INF/persistence.xml
                        /src/main/resources/components.xml
                        /src/main/resources/mport.sql
                        /src/main/resources/seam.properties
                        
                        /src/test/resources/jboss-jms-beans.xml
                        /src/test/resources/seam.properties
                        /src/test/resources/default.persistence.properties
                        /src/test/resources/jndi.properties
                        /src/test/resources/security-beans.xml
                        /src/test/resources/ejb3-interceptors-aop.xml
                        /src/test/resources/log4j.xml
                        /src/test/resources/embedded-jboss-beans.xml
                        /src/test/resources/login-config.xml
                        /src/test/resources/testng.xml
                        


                        Here is my issue:
                        http://www.jboss.com/index.html?module=bb&op=viewtopic&t=86127

                        Any valuable input is highly appreciated.

                        Cheers,
                        Ove