Tips on Sun ONE App Server 7 and Postgres 7.2

Поиск
Список
Период
Сортировка
Искать

Tips on Sun ONE App Server 7 and Postgres 7.2

От:
Joe Howes <joeh@guild1.com>
Дата:
I got Sun ONE Application Server (SOAS) 7 talking to Postgres this 
morning and since I had a heck of a time finding anyone else on the net 
who's done it, here's what I discovered.

Coming from JBoss, the following things needed to be done to my application:


1) SOAS is way more picky about all your DAOs implementing 
java.io.Serializable. Although it won't tell you this directly, it will 
solve runtime problems when you find the app server has trouble passing 
some filled out DAO around.


2) If you are using Struts Tiles, SOAS is more picky about the paths you 
refer to. So, if your layout and other pages exist in the same 
directory, you still need to enter their absolute paths. Instead of:






you need:







3) JBoss is very forgiving about not having resource-ref settings in the 
DDs, SOAS is not. Put them EVERYWHERE you will have DB access.



SOAS and Application Settings
=============================

SOAS Admin Interface (Under server1 | JDBC):
--------------------------------------------

JDBC Resources:
- JNDI Name: jdbc/jdbc-fooDS
- Pool Name: FooPool

Connection Pools:
- JNDI Name: FooPool
- Datasource Classname: org.postgresql.jdbc3.Jdbc3SimpleDataSource
(You can choose a Type 2 or pooling implementation here...see 
www.postgresql.org)
- Properties:
- serverName: localhost
- portNumber: 0
- user: foo
- password: foo
- databaseName: foo
(Having used 'createdb foo' and 'createuser foo')


Deployment Descriptor Excerpts:
-------------------------------

ejb-jar.xml:


Test Controller Bean
TestControllerEJB
TestControllerEJB
ca.joehowes.soastest.ejb.TestControllerHome
ca.joehowes.soastest.ejb.TestController
ca.joehowes.soastest.ejb.TestControllerBean
Stateless
Bean

jdbc/jdbc-fooDS
javax.sql.DataSource
Container
Shareable




Foo Bean
FooEJB
FooEJB
ca.joehowes.soastest.ejb.TestHome
ca.joehowes.soastest.ejb.Test
ca.joehowes.soastest.ejb.TestBean
Bean
java.lang.Integer
False

jdbc/jdbc-coachds
javax.sql.DataSource
Container
Shareable




sun-ejb-jar.xml:


TestControllerEJB
ejb/soastest/TestControllerEJB

jdbc/jdbc-fooDS
jdbc/jdbc-fooDS

false

20
5
100
3600




TestEJB
ejb/soastest/TestEJB

jdbc/jdbc-fooDS
jdbc/jdbc-fooDS

false

20
5
100
3600




Code to lookup the resource and connect:
----------------------------------------

javax.naming.InitialContext ic = new javax.naming.InitialContext();
javax.sql.DataSource ds = 
(javax.sql.DataSource)ic.lookup(java:comp/env/jdbc/jdbc-coachds);
con = ds.getConnection();
if (con == null) {
throw new RemoteException("Unable to establish a connection to the 
database.");
}




This should save some of you some time...


- Joe

FAQ