1 Reply Latest reply on May 11, 2011 8:03 PM by nraf

    Issues with data source

    nraf

      Hello, I've created a new project from Maven using the recommended J2EE Maven archetype.


      I'm trying to set it up now to connect to a Postgresql database. I'm actually just starting on porting an existing Seam 2 application to Weld and Seam 3, and am still in the very early stages.


      I've never actually set up a data source before so I'm a bit lost. If there's a step by step guide on how to set up the data source, that will be helpful because I'm currently a bit lost.


      Persistence.xml:



      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="
              http://java.sun.com/xml/ns/persistence
              http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
          <persistence-unit name="postgres" transaction-type="JTA">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
      
              <jta-data-source>java:/PostgresDS</jta-data-source>
             <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/socialFactory"/>
      
                <!-- Logging -->
                <property name="hibernate.show_sql" value="false"/>
                <property name="hibernate.use_sql_comments" value="false"/>
                <property name="hibernate.format_sql" value="false"/>
      
                <!-- Search engine -->
                <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
      
                <!-- use a file system based index -->
                <property name="hibernate.search.default.directory_provider"
                         value="org.hibernate.search.store.FSDirectoryProvider"/>
                <!-- directory where the indexes will be stored -->
                <property name="hibernate.search.default.indexBase" value="/app/bsiteapps/social/data/store"/>
                <property name="hibernate.search.worker.batch_size" value="500"/>
      
            </properties>
            
          </persistence-unit>
      </persistence>



      Regarding the property with the value 'java:/socialFactory', I'm not entirely sure what to do with that. In the Seam 2 project, I had the following in components.xml:



          <core:init jndi-pattern="@jndiPattern@" debug="false"/>
          <persistence:entity-manager-factory name="socialDS" installed="false"/>
          <persistence:managed-persistence-context name="em" auto-create="true"
                          entity-manager-factory="#{socialDS}" persistence-unit-jndi-name="java:/socialFactory"/>



      There doesn't seem to be any components.xml in Weld, though, so I don't know where those settings should go.


      postgres-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>
      
        <no-tx-datasource>
          <jndi-name>PostgresDS</jndi-name>
          <connection-url>jdbc:postgresql://REMOVED.COM:3835/DBNAME</connection-url>
          <driver-class>org.postgresql.Driver</driver-class>
          <user-name>REMOVED</user-name>
          <password>REMOVED</password>
         <min-pool-size>5</min-pool-size>
         <max-pool-size>200</max-pool-size>
         <idle-timeout-minutes>5</idle-timeout-minutes>
        </no-tx-datasource>
      </datasources>