Tasos P.
Tasos P.

Reputation: 4114

Glassfish: modify deployment descriptors for EAR during deployment

After several days of searching, trying and head-banging, I post this question to SO although it seems to be answered already.

Here is the scenario: I have an EAR application containing (for the moment) one WAR and one EJB module. The EJB module uses JPA (persistence.xml) and some Stateless Session Beans are exposed via Web Services. The web services use Basic authentication with a jdbc realm. The web module uses form authentication with the same realm.

The requirement: I need to be able to deploy this application either on different servers (dev/test/prod) or on the same server (or cluster) with different deployment descriptors. The deployment settings that need to be different in each application instance are:

During my research, I managed the following:

So far so good. This leaves me with the following problems:

By easily I mean during deployment or using something similar to a deployment plan jar. Maintaining multiple copies of ejb.jar or war just with a modified .xml file is not an option.

Just to be clear, the need is to have different databases (either in different stages of development or for different customers) using the same application. The application uses one persistence-unit but it needs to point to different databases (hence the jta-data-source). The realm is a jdbc realm (on the same database) that also needs to be different per application instance.

Any help or pointer would be greatly appreciated.

Upvotes: 2

Views: 1526

Answers (2)

vkraemer
vkraemer

Reputation: 9892

You can do all those things with a deployment plan jar.

It looks like the content of the deployment plan jar is pushed into archive/directory tree of the application BEFORE any of the heavy lifting associated with deployment happens.

See

http://java.net/projects/glassfish/sources/svn/content/trunk/main/appserver/deployment/javaee-core/src/main/java/org/glassfish/javaee/core/deployment/DolProvider.java

and

http://java.net/projects/glassfish/sources/svn/content/trunk/main/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/archivist/Archivist.java

Upvotes: 0

Pradeep Pati
Pradeep Pati

Reputation: 5919

Have you thought about preparing templates for the deployment descriptors, and populating them with value from property file during build? If you are using ant, you can use the expandproperties filter.

Upvotes: 1

Related Questions