8 Replies Latest reply on Aug 9, 2006 9:57 AM by oranheim

    Maven2 and JBoss Seam DVD Store demo

    oranheim

      I have mavenized the JBoss Seam DVD Store example to Maven2. It's more or less complete, but the test-cases fails (TestNG). The error seem to be caused by a jndi-configuration error. The jboss console doesn't show any thrown exceptions, but this is the output from the admin-test-case:

      -------------------------------------------------------------------------------
      Test set: admin beans
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.356 sec <<< FAILURE!
      testTopProducts Time elapsed: 0.006 sec <<< FAILURE!
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: stats
       at org.jboss.seam.Component.newInstance(Component.java:735)
       at org.jboss.seam.Component.newInstance(Component.java:1308)
       at org.jboss.seam.Component.getInstance(Component.java:1263)
       at org.jboss.seam.Component.getInstance(Component.java:1246)
       at org.jboss.seam.mock.SeamTest$Script.getInstance(SeamTest.java:125)
       at com.jboss.dvd.seam.test.StoreManagerTest$1.updateModelValues(StoreManagerTest.java:22)
       at org.jboss.seam.mock.SeamTest$Script.run(SeamTest.java:237)
       at com.jboss.dvd.seam.test.StoreManagerTest.testTopProducts(StoreManagerTest.java:17)
      


      I have any clue what causes this? If you'd like to investigate, the the source-code is available at:

      http://people.opera.com/over/maven2/seam-dvd-1.0.1.zip

      I have updated the readme.txt with regards to jboss-seam-server installation issues. This due to problems with running Seam 1.0.1.GA in JBoss 4.0.4 and Seam 1.0.1.GA. Therefore you have to patch your jboss-installation.

      Everything is pre-configured, but you may configure the jboss properties in the bottom of the jboss-seam-dvd/pom.xml (EAR). If you are going to deploy on JBoss you should copy the datasource 'jboss-seam-dvd-ejb/src/main/resources/META-INF/dvd-ds.xml' to deployment directory, before you issue 'mvn cargo:deploy'.

      All the best,
      Ove Ranheim


        • 1. Re: Maven2 and JBoss Seam DVD Store demo
          gavin.king

          you did not show the whole stacktrace

          • 2. Re: Maven2 and JBoss Seam DVD Store demo
            oranheim

            You're right. Here is the console output:

            INFO 05-07 05:51:03,996 (Log4JLogger.java:info:94) -Component: cart, scope: SESSION, type: STATEFUL_SESSION_BEAN, class: com.jboss.dvd.seam.ShoppingCartBean, JNDI: jboss-seam-dvd-1.0/ShoppingCartBean/local
            INFO 05-07 05:51:04,010 (Log4JLogger.java:info:94) -done initializing Seam
            INFO 05-07 05:51:04,190 (Log4JLogger.java:info:94) -Hibernate EntityManager 3.2.0.CR1
            INFO 05-07 05:51:04,320 (Log4JLogger.java:info:94) -Hibernate Annotations 3.2.0.CR1
            INFO 05-07 05:51:04,364 (Log4JLogger.java:info:94) -Hibernate 3.2 cr2
            INFO 05-07 05:51:04,374 (Log4JLogger.java:info:94) -hibernate.properties not found
            INFO 05-07 05:51:04,381 (Log4JLogger.java:info:94) -Bytecode provider name : cglib
            INFO 05-07 05:51:04,451 (Log4JLogger.java:info:94) -using JDK 1.4 java.sql.Timestamp handling
            FATAL 05-07 05:51:05,805 (Log4JLogger.java:fatal:124) -import.sqlO-:-Ofalse
            FATAL 05-07 05:51:05,807 (Log4JLogger.java:fatal:124) -META-INF/dvd-ds.xmlO-:-Ofalse
            FATAL 05-07 05:51:05,810 (Log4JLogger.java:fatal:124) -META-INF/ejb-jar.xmlO-:-Ofalse
            FATAL 05-07 05:51:05,812 (Log4JLogger.java:fatal:124) -META-INF/persistence.xmlO-:-Ofalse
            FATAL 05-07 05:51:05,813 (Log4JLogger.java:fatal:124) -seam.propertiesO-:-Ofalse
            INFO 05-07 05:51:06,079 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.User
            INFO 05-07 05:51:06,189 (Log4JLogger.java:info:94) -Bind entity com.jboss.dvd.seam.User on table USERS
            INFO 05-07 05:51:06,385 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.Order
            INFO 05-07 05:51:06,388 (Log4JLogger.java:info:94) -Bind entity com.jboss.dvd.seam.Order on table ORDERS
            INFO 05-07 05:51:06,524 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.Actor
            INFO 05-07 05:51:06,525 (Log4JLogger.java:info:94) -Bind entity com.jboss.dvd.seam.Actor on table ACTORS
            INFO 05-07 05:51:06,529 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.Product
            INFO 05-07 05:51:06,531 (Log4JLogger.java:info:94) -Bind entity com.jboss.dvd.seam.Product on table PRODUCTS
            INFO 05-07 05:51:06,595 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.Admin
            INFO 05-07 05:51:06,645 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.OrderLine
            INFO 05-07 05:51:06,651 (Log4JLogger.java:info:94) -Bind entity com.jboss.dvd.seam.OrderLine on table ORDERLINES
            INFO 05-07 05:51:06,658 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.Category
            INFO 05-07 05:51:06,661 (Log4JLogger.java:info:94) -Bind entity com.jboss.dvd.seam.Category on table CATEGORIES
            INFO 05-07 05:51:06,665 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.Inventory
            INFO 05-07 05:51:06,667 (Log4JLogger.java:info:94) -Bind entity com.jboss.dvd.seam.Inventory on table INVENTORY
            INFO 05-07 05:51:06,680 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.Customer
            INFO 05-07 05:51:06,732 (Log4JLogger.java:info:94) -Mapping collection: com.jboss.dvd.seam.Order.orderLines -> ORDERLINES
            INFO 05-07 05:51:07,023 (Log4JLogger.java:info:94) -JNDI InitialContext properties:{}
            FATAL 05-07 05:51:07,039 (Log4JLogger.java:fatal:129) -Could not find datasource: java:/dvdDatasource
            javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
             at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
             at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
             at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
             at javax.naming.InitialContext.lookup(InitialContext.java:351)
             at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
             at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
             at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
             at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:61)
             at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
             at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
             at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
             at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
             at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
             at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
             at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
             at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
             at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
             at com.jboss.dvd.seam.test.ProductUnitTest.em(ProductUnitTest.java:22)
             at com.jboss.dvd.seam.test.ProductUnitTest.testRequiredAttributes(ProductUnitTest.java:36)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
             at org.testng.internal.Invoker.invokeMethod(Invoker.java:407)
             at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:778)
             at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
             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(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:261)
             at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:781)
            FATAL 05-07 05:51:07,172 (Log4JLogger.java:fatal:124) -import.sqlO-:-Ofalse
            FATAL 05-07 05:51:07,174 (Log4JLogger.java:fatal:124) -META-INF/dvd-ds.xmlO-:-Ofalse
            FATAL 05-07 05:51:07,179 (Log4JLogger.java:fatal:124) -META-INF/ejb-jar.xmlO-:-Ofalse
            FATAL 05-07 05:51:07,182 (Log4JLogger.java:fatal:124) -META-INF/persistence.xmlO-:-Ofalse
            FATAL 05-07 05:51:07,183 (Log4JLogger.java:fatal:124) -seam.propertiesO-:-Ofalse
            INFO 05-07 05:51:07,187 (Log4JLogger.java:info:94) -Binding entity from annotated class: com.jboss.dvd.seam.User
            


            • 3. Re: Maven2 and JBoss Seam DVD Store demo
              jtucker

              It's probably not picking up your JNDI pattern from components.xml.

              Create a second WEB-INF directory in /src/test/resources and move your components.xml file in there.

              This ensures that it is in the right place in the maven classpath for Seam to pick it up.

              It's pretty ugly I know but it's the simplest solution I've found.

              Hope that fixes it for you.

              • 4. Re: Maven2 and JBoss Seam DVD Store demo
                oranheim

                The components.xml was placed under /src/test/resources/WEB-INF. Here is my configuration:

                <components>
                
                 <component name="org.jboss.seam.core.init">
                 <property name="debug">true</property>
                 <property name="myFacesLifecycleBug">true</property>
                 <property name="jndiPattern">jboss-seam-dvd-1.0/#{ejbName}/local</property>
                 </component>
                
                 <!-- 120 second conversation timeout -->
                 <component name="org.jboss.seam.core.manager">
                 <property name="conversationTimeout">120000</property>
                 </component>
                
                 <!--
                 <component class="org.jboss.seam.core.Jbpm">
                 <property name="processDefinitions">ordermanagement1.jpdl.xml</property>
                 <property name="pageflowDefinitions">checkout.jpdl.xml, newuser.jpdl.xml</property>
                 </component>
                
                 <component class="org.jboss.seam.core.Ejb"
                 installed="false"/>
                 -->
                
                </components>
                



                • 5. Re: Maven2 and JBoss Seam DVD Store demo
                  yuan_hang

                  Because unit test use embedded-ejb, so the configuration should like this:

                  <components>
                  
                   <component name="org.jboss.seam.core.init">
                   <property name="debug">true</property>
                   <property name="myFacesLifecycleBug">true</property>
                   <property name="jndiPattern">#{ejbName}/local</property>
                   </component>
                  
                  ...
                  
                   <component class="org.jboss.seam.core.Ejb"
                   installed="true"/>
                  
                  </components>
                  


                  • 6. Re: Maven2 and JBoss Seam DVD Store demo
                    tushardesai22

                    I am trying to run the DVD Store example from my web-browser.
                    http://localhost:8080/seam-dvd

                    I am using Eclipse 3.12 + JBossIDE-200607141757-nightly-ALL + jboss-seam-1.0.0.CR3, + jboss-4.0.4.GA

                    but I get the following error by Apache Tomcat/5.5.17 which is not even started. I am trying to run the dvde application through JBoss AS but not sure why I keep getting the error

                    HTTP Status 404 - /seam-dvd
                    type Status report
                    message /seam-dvd
                    description The requested resource (/seam-dvd) is not available.
                    Apache Tomcat/5.5.17

                    Please advice.

                    • 7. Re: Maven2 and JBoss Seam DVD Store demo
                      tushardesai22

                      It seems that 'seam-booking' example is working but 'seam-dvd' example is giving error.

                      • 8. Re: Maven2 and JBoss Seam DVD Store demo
                        oranheim

                         

                        "yuan_hang" wrote:
                        Because unit test use embedded-ejb, so the configuration should like this:
                        <components>
                        
                         <component name="org.jboss.seam.core.init">
                         <property name="debug">true</property>
                         <property name="myFacesLifecycleBug">true</property>
                         <property name="jndiPattern">#{ejbName}/local</property>
                         </component>
                        
                        ...
                        
                         <component class="org.jboss.seam.core.Ejb"
                         installed="true"/>
                        
                        </components>
                        

                        Thanks for your input. That was part of the problem, but it also turned out that I didn't configure my test resources correctly as some files were missing.

                        I am happy to tell that the JBossSeam DVDStore with Maven 2 now works. That include compile, test, package, install and deployement.

                        For those who need a Maven2 skeleton for JBossSeam can safely use this one:
                        http://people.opera.com/over/maven2/seam-dvd-1.0.1.zip

                        The old and errornous archive is renamed:
                        http://people.opera.com/over/maven2/seam-dvd-1.0.1-errornous.zip

                        Cheers,
                        Ove