1 Reply Latest reply on Dec 17, 2007 9:34 AM by Pete Muir

    test configuring joss embedded

    Levent Aksu Newbie

      Hi,
      I am trying to convert a seam-gen generated project to use hibernate instead of jpa. I am almost done except getting testing work. In the reference documentation it is stated that "jboss-beans.xml" file is generated by seam-gen, but I cannot seem to find it. And creating one like the following does not help configuring the data source:

      <deployment xmlns="urn:jboss:bean-deployer:2.0">
       <bean name="TransactionManagerFactory" class="org.jboss.seam.microcontainer.TransactionManagerFactory"/>
       <bean name="TransactionManager" class="java.lang.Object">
       <constructor factoryMethod="getTransactionManager">
       <factory bean="TransactionManagerFactory"/>
       </constructor>
       </bean>
       <bean name="payrollDatasourceFactory" class="org.jboss.seam.microcontainer.DataSourceFactory">
       <property name="driverClass">org.postgresql.ds.PGSimpleDataSource</property>
       <property name="connectionUrl">jdbc:postgresql://192.168.10.79:5432/payroll_levent</property>
       <property name="userName">postgres</property>
       <property name="password">postgres</property>
       <property name="jndiName">java:/payroll</property>
       <property name="minSize">0</property>
       <property name="maxSize">10</property>
       <property name="blockingTimeout">1000</property>
       <property name="idleTimeout">100000</property>
       <property name="transactionManager">
       <inject bean="TransactionManager"/>
       </property>
       </bean>
       <bean name="payrollDatasource" class="java.lang.Object">
       <constructor factoryMethod="getDataSource">
       <factory bean="payrollDatasourceFactory"/>
       </constructor>
       </bean>
      </deployment>

      Either I have the file above or not 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
      

      Here is my 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}"/>
      
      

      and payroll-test-ds || payroll-dev-ds.xml
      <?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>
      


      How do I configure the embedded container?