Hi Andrew,

WebObjects is clever because it uses the standard EOModel database connection in development and then when you deploy (and <resource-ref></resource-ref> is uncommented in web.xml.template) EOF ignores the EOModel connection string and automatically uses the jboss data source connection which of course could be to a different database.

For development I am using XCode 2.3 WebObjects 5.3.1 
When starting the project I selected true WAR (frameworks must be built as jars)
I built an EOModel which matched the data structure in the postgresql 8.1.3 database.  
I am using the postgresql-8.0-310.jdbc3.jar jdbc driver in /Library/Java/Extensions.  
I am using the Project wonder PostgresqlPlugin.framework in /Library/Frameworks. 
I am using case sensitive field names so I had to set the property in Application.java constructor
   System.setProperty("com.webobjects.jdbcadaptor.PostgresqlExpression.enableIdentifierQuoting","true");

For deployment I am using jboss 4.0.3SP1 on a debian system with 2.6 kernel and java 1.5.0_06. To prepare my app for deployment 
I used a WebObjects 5.3 licence key in SERVLET_DEPLOY_LICENSE in main project target.

My jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
<jboss-web>
  <resource-ref>
    <res-ref-name>jdbc/DefaultDataSource</res-ref-name>
    <jndi-name>java:/PostgresDS</jndi-name>
  </resource-ref>
</jboss-web>


  <resource-ref>
    <description>The data source to be used by EOF. If there are multiple data sources,
                 then the definition below must be used to configure which JDBC URL (Model) should
                 use which data source. If EOF should use a JDBC driver directly, this section must be commented out</description>
    <res-ref-name>jdbc/DefaultDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>


From postgres-ds.xml in jboss deploy directory
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>PostgresDS</jndi-name>
    <connection-url>jdbc:postgresql://192.168.0.1:5432/my_database</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>my_username</user-name>
    <password>my_password</password>
    <metadata>
        <type-mapping>PostgreSQL 8.0</type-mapping>
    </metadata>
  </local-tx-datasource>
</datasources>


To ensure the PostgresqlPlugin.framework was built as a jar I ran the following command
/Developer/Makefiles/java_makefiles/CoaxBundleIntoJar.sh /Library/Frameworks/PostgresqlPlugin.framework /Library/WebObjects/lib

I also had issues with primary key generation because the sequences in the database didn't match the sequence names that the framework was expecting.  For each eogenerated model subclass class I overrode the method awakeFromInsertion with the following:

    public void awakeFromInsertion(com.webobjects.eocontrol.EOEditingContext ec) {
        if ( ec != null && idEnquiry() == null ) {       
            String sql = "select nextval('my_schema.\"Enquiry_EnquiryNumber_seq\"'::text);";
            NSArray ar = com.webobjects.eoaccess.EOUtilities.rawRowsForSQL(ec, "my_eomodel", sql, new NSArray("id")); 
            if ( ar.count() > 0 ) {
                NSDictionary nsd = (NSDictionary) ar.objectAtIndex(0);
                setIdEnquiry((Number) nsd.objectForKey("id"));
            }
        }        
    }


I hope this helps.

D Tim Cummings
Triptera Pty Ltd

On 30/06/2006, at 13:49, Andrew Madu wrote:
Hi D,
I am using postgresql within jboss 4.0.x in exactly the same way, using postgres-ds.xml, with my current cocoon/hibernate project. As I am now going to move the project over to webobjects framework could you let know how to reference the jndi connection from within your webobject project?

regards

Andrew

On 29/06/06, D Tim Cummings <[EMAIL PROTECTED]> wrote: We are using jboss 4.  We are letting jboss handle the connections
using the jndi by putting a datasource xml file in the deployment
directory (in our case postgres-ds.xml)  that was referenced from
jboss-web.xml

D Tim Cummings




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to