2 Replies Latest reply on Dec 14, 2007 7:59 AM by Pete Muir

    configuration question

    Levent Aksu Newbie

      Hi,
      I have a 1.2.1 working project that I am trying to migrate to 2.0.0 GA.
      To avoid issues with testng configuration I have started with a fresh seam-gen generated template."seam setup", "seam new project", "seam explode"
      I copied my classes and pages into it. I left Glassfish aside for the time being, again to avoid configuration issues and converted to JBoss AS.
      Due to some bug (http://jira.jboss.org/jira/browse/JBSEAM-2220) I decided to convert to annotations and leave hbm.xml configuration. I have a few mapping issues there because of this conversion but the whole thing is almost working.
      Note that I use Hibernate for persistence instead of JPA and I had to have some modifications on top of the seam-gen generated template like preventing persistence.xml to be copied to the build etc.
      Now, back to testing again I have a problem with configuration. This is probably due to my lack of knowledge about the embedded container and I cannot figure out a correct recipe from the examples, info provided in the manual and "seam-gen"erated project combined.
      So I need your help:
      Here follows my latest configuration files:
      components.xml:

      <core:init debug="@debug@" jndi-pattern="@jndiPattern@" />
      
       <core:manager concurrent-request-timeout="500"
       conversation-timeout="120000"
       conversation-id-parameter="cid"/>
      
       <persistence:hibernate-session-factory name="hibernateSessionFactory"/>
       <persistence:managed-hibernate-session name="hibernateSession"
       auto-create="true"
       session-factory-jndi-name="java:/payrollSessionFactory"/>
      
       <persistence:hibernate-transaction session="#{hibernateSession}"/>
      
      

      payroll-test-ds
      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE datasources
      PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
      "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
      
      <datasources>
      
       <local-tx-datasource>
       <jndi-name>payrollDatasource</jndi-name>
       <connection-url>jdbc:postgresql://192.168.10.79:5432/payroll_levent</connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>postgres</user-name>
       <password>postgres</password>
       <metadata>
       <type-mapping>PostgreSQL 8.0</type-mapping>
       </metadata>
       <new-connection-sql>select 1</new-connection-sql>
       <check-valid-connection-sql>select 1</check-valid-connection-sql>
      
       </local-tx-datasource>
      </datasources>
      

      I obviously have a missing link there deploying the payroll-test-ds.xml to the embedded container. Because I get the following:

      [testng] FAILED CONFIGURATION: @BeforeClass init
       [testng] org.hibernate.HibernateException: Could not find datasource
       [testng] at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
       [testng] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
       [testng] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
       [testng] at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397)
       [testng] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
       [testng] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2006)
       [testng] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1289)
       [testng] at org.jboss.seam.persistence.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:165)
       [testng] at org.jboss.seam.persistence.HibernateSessionFactory.startup(HibernateSessionFactory.java:79)
       [testng] at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       [testng] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
       [testng] at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
       [testng] at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
       [testng] at org.jboss.seam.Component.newInstance(Component.java:1968)
       [testng] at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
       [testng] at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
       [testng] at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:95)
       [testng] at org.jboss.seam.init.Initialization.init(Initialization.java:555)
       [testng] at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:939)
       [testng] at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
       [testng] Caused by: javax.naming.NameNotFoundException: payrollDatasource not bound
       [testng] at org.jnp.server.NamingServer.getBinding(NamingServer.java:542)
       [testng] at org.jnp.server.NamingServer.getBinding(NamingServer.java:550)
       [testng] at org.jnp.server.NamingServer.getObject(NamingServer.java:556)
       [testng] at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
       [testng] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:628)
       [testng] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:590)
       [testng] at javax.naming.InitialContext.lookup(InitialContext.java:351)
       [testng] at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
       [testng] ... 45 more
       [testng] ... Removed 26 stack frames
      


        • 1. Re: configuration question
          Levent Aksu Newbie

          I have added the following to bootstrap-beans.xml

          <bean name="payrollDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
           <property name="driverClass"><value>org.postgresql.Driver</value></property>
           <property name="connectionURL"><value>jdbc:postgresql://192.168.10.79:5432/payroll_levent</value></property>
           <property name="userName"><value>postgres</value></property>
           <property name="jndiName"><value>java:/payrollDatasource</value></property>
           <property name="minSize"><value>0</value></property>
           <property name="maxSize"><value>10</value></property>
           <property name="blockingTimeout"><value>1000</value></property>
           <property name="idleTimeout"><value>50000</value></property>
           <property name="transactionManager"><inject bean="TransactionManager"/></property>
           <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
           <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
           </bean>
          
           <bean name="payrollDatasource" class="java.lang.Object">
           <constructor factoryMethod="getDatasource">
           <factory bean="payrollDSBootstrap"/>
           </constructor>
           </bean>


          I now get :

          [testng] FAILED CONFIGURATION: @BeforeClass init
           [testng] org.jboss.deployers.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
           [testng]
           [testng] *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
           [testng]
           [testng] payrollDSBootstrap
           [testng] -> TransactionManager{Configured:** NOT FOUND **}
           [testng] -> InitialContextProperties{Configured:** NOT FOUND **}
           [testng] -> CachedConnectionManager{Configured:** NOT FOUND **}
           [testng]
           [testng] payrollDatasource
           [testng]
           [testng]
           [testng] *** CONTEXTS IN ERROR: Name -> Error
           [testng]
           [testng] InitialContextProperties -> ** NOT FOUND **
           [testng]
           [testng] TransactionManager -> ** NOT FOUND **
           [testng]
           [testng] CachedConnectionManager -> ** NOT FOUND **
           [testng]
           [testng]
           [testng] at org.jboss.embedded.Bootstrap.checkIncomplete(Bootstrap.java:144)
           [testng] at org.jboss.embedded.Bootstrap.bootstrapURL(Bootstrap.java:169)
           [testng] at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:201)
           [testng] at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:214)
           [testng] at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:11)
           [testng] at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1006)
           [testng] at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:931)
           [testng] at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
           [testng] ... Removed 22 stack frames
          


          This way it seems like transactionManager and other stuff does not get injected for some reason. I cannot tell why. Also in the documentation it says, seam-gen generates "jboss-beans.xml" file but I cannot seem to find it.
          It would be great if someone said I am barking at the correct tree.



          • 2. Re: configuration question
            Pete Muir Master

            This way it seems like transactionManager and other stuff does not get injected for some reason. I cannot tell why. Also in the documentation it says, seam-gen generates "jboss-beans.xml" file but I cannot seem to find it. It would be great if someone said I am barking at the correct tree.

            This is a bug in the docs which I fixed (a hangover from an older test container).

            You should just need to copy the ds to the bootstrap folder for it to be picked up. Have you tried that? By default, seam-gen projects use the default datasource.