Glassfish SunOne Toplink Postgresql

Administration of Glassfish and SunOne

Glassfish is the “open source release” of the SunOne application server. The administration interface is available on a different port.
The default user and password is admin and admin.

Setting up a PostgreSQL connection pool.

Copy the database driver to SERVER_HOME/domains/domain/lib/ext and restart the server.

In the administration area click on resources → jdbc.
First you must set up a connection pool and then a datasource referencing the pool.
I created a ConnectionPoolDatasource and used org.postgresql.ds.PGPoolingDataSource. Don’t forget to add properties add the end of the dialog.

Toplink issues

The Toplink version coming with SunOne 9 and Glassfish 1 has issues with PostgreSql.
You can find a newer version at .
After running the installation script you can find two jars in a subdirectory. Replace the old versions of these files in the SERVER_HOME/lib directory.

Informations about configuration options can be found at the following website.

Deployment issues

I used log4j in my EJB 3 project. As this jar was not available I got a large stacktrace. Allthough I have some experience with stacktraces and other application server, I managed to overlook the actual reason for the problem.
Read the stacktrace of this server carefully and don’t forget to scroll to the right end of the stacktrace ;-)

Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment descriptors for module [JpaSandcastle] — Invalid ejb jar [JpaSandcastleEJB.jar]: it contains zero ejb.
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(
at com.sun.enterprise.deployment.backend.AppDeployerBase.loadDescriptors(
Referencing EJBs from a Web project
The JBoss application server does allow to reference a Session Bean from a Web project without any further configuration. This is not possible in other application server including Glassfish and SunOne.
To access the Session Bean by the local interface, I had to declare a local name for my EJB in the web.xml of the web project.



Now, I could get a refernce to the bean by calling.
Context context = new InitialContext();
sandcastleServiceLocal = (SandcastleServiceLocal) context

Alternatively you can use the following annotation in front of a class.
@EJB(name=“sandcastleServiceName”, beanInterface=SandcastleServiceLocal.class)


You will find the complete example in my German book and a little bit later in the english version available at