Version 6

    How to configure PostgreSQL for JBoss Mail Server

     

    versions: 1.0M4,1.0M5-pre1

     

    Easy way

     

    The easy way to configure PostgreSQL for JBMS is to use the graphical installer and select "generate datasource", put in your server/user information and allow the installer to automatically install the PostgreSQL JDBC driver into your $JBOSS_HOME/server/$CONFIG/lib directory. 

     

    Hard way

     

    The harder way to configure PostgreSQL for JBMS is to copy the datasource descriptor example from $JBOSS_HOME/docs/examples/jca/postgresql-ds.xml to the $JBOSS_HOME/server/$CONFIG/deploy directory.  Edit this replacing the user and server information with the information related to your database.  Following this you need to ensure that some additional information is in the JBMS jboss-service.xml descriptor.

     

     

     

    Adding PostgreSQL specific parts to the descriptor

     

    In the jboss-service.xml you need to ensure that the following is defined.  (You may also want to remove

    any alternatively defined "Store" implementations.)

     

            <!--
                    PostgreSQL base store that uses the LargeObjectAPI
                    in order to store data.
            -->
            <mbean code="org.jboss.mail.store.postgresql.PostgreSQLStore"
                    name="jboss.mail:type=MailServices,name=PostgreSQLStore">
                    <attribute name="Disconnected">true</attribute>
                    <attribute name="DataSource">java:/YOUR_DATASOURCE_NAME</attribute>
                    <attribute name="PageSize">131072</attribute>
            </mbean>
    
            <!-- Mail Body Manager -->
            <mbean code="org.jboss.mail.message.MailBodyManager"
                    name="jboss.mail:type=MailServices,name=MailBodyManager">
                    <attribute name="UseStore">true</attribute>
    
                    <depends optional-attribute-name="Store"
                            proxy-type="attribute">jboss.mail:type=MailServices,name=PostgreSQLStore</depends>
    
            </mbean>
    

     

    There is also an addition descriptor that you must change called $JBOSS_HOME/server/$CONFIG/deploy/mail.ear/mail.par/META-INF/persistence.xml.  Ensure it reads as follows:

     

    <persistence>
      <persistence-unit name="mail">
      <jta-data-source>java:/YOUR_DATA_SOURCE_NAME</jta-data-source>
      <properties>
        <property name="jboss.entity.manager.jndi.name"
                  value="java:/EntityManagers/mail"></property>
       <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"></property>
        <property name="hibernate.hbm2ddl.auto"
                  value="update"></property>
      </properties>
      </persistence-unit>
    </persistence>
    

     

    Be sure and replace all of the YOUR_DATASOURCE_NAME strings above with the name you defined in your postrgesql-ds.xml.

     

    That's basically it.  You will need to restart the underlying JBAS instance after making this change.