Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Here is some simple steps to handle a set of parameters for your seam project, using the ant file. Our goal was to create some multiple instances of the same seam application, named differently but running on the same JBoss server.

The application was generated using seam-gen, using the exploded ear mode; but the concept remains for other modes.

In this example, our main project name is ResourcesManager. We want to keep this as codename for development and demonstration purpose and market the application under the name FitnetManager.

In a more general way, we will parametrize for a new customer:

  • The application display-name
  • A specific datasource
  • A mailing configuration


  • In

Add two new entries to handle the display-name and the development codename

  • In build.xml:


<property name="" value="ResourcesManager" />


<property name="" value="${fitnetBranch}" />
<property name="project.trunk" value="ResourcesManager" />

In the target war, add in the filterset element:

<filter token="fitnetBranch" value="${}" />

The @fitnetBranch@ parameter is now usable in all files in the WEB-INF directory

Same operation in the ear target. add these lines in copy todir=${ear.dir}/META-INF

	<filter token="fitnetBranch" value="${}" />

You can now use the parameter in both WEB-INF and META-INF directories. Now, let's apply the parameter in the configuration files.

In META-INF/application.xml, replace all occurences of your project name using the parameter. The file should now look like this:

   <!-- Seam and EL -->

Same thing in META-INF/jboss-app.xml:


And, voila! The @fitnetBranch@ parameter now controls the display name and the ear/jar/war filename, allowing to deploy multiple instances.

Specific Datasource

Our next goal is to create a specific datasource for every project instance, named after the instance. For the moment all the instances refers to a single datasource file named [yourtrunkname]-ds-prod.xml.

First, add the three parameters to and build.xml:

<!-- database connection properties -->
<property name="db.url" value="${db.url}" />
<property name="db.username" value="${db.username}" />
<property name="db.password" value="${db.password}" />

In the target datasource


		<copy todir="${deploy.dir}">
			<fileset dir="${basedir}/resources">
				<include name="${}-${profile}-ds.xml" />


		<copy todir="${deploy.dir}">
			<fileset dir="${basedir}/resources">
				<include name="${project.trunk}-${profile}-ds.xml" />				
				<!-- filters added for FitnetApplication-->
				<filter token="fitnetBranch" value="${}" />
				<filter token="db.url" value="${db.url}" />				
				<filter token="db.username" value="${db.username}" />
				<filter token="db.password" value="${db.password}" />
			<!-- rename -->
			<globmapper from="${project.trunk}-${profile}-ds.xml" to="${}-${profile}-ds.xml"/>

As you can see, the Datasource file is renamed during the copy process, according to your new display-name, and the new attributes are applied.

Now we just have to change components.xml, persistence-dev.xml and persistence-prod.xml:


	name="entityManager" auto-create="true"	persistence-unit-jndi-name="java:/@fitnetBranch@EntityManagerFactory"/>


   <persistence-unit name="@fitnetBranch@">
         <property name="" value="validate"/>
         <property name="hibernate.cache.use_query_cache" value="true"/>
         <property name="hibernate.jdbc.batch_size" value="20"/>
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
         <property name="" value="java:/@fitnetBranch@EntityManagerFactory"/>

Same thing in resources/ResourceManager-*-ds.xml:


Now during deployment, a specific datasource with his own configuration will be generated. Multiple independant instances of the application can coexist on the server.


We applied the same recipe to parametrize mail sending in the application:


	<!-- mailer properties -->
	<property name="" value="${}" />
	<property name="mail.port" value="${mail.port}" />
	<property name="mail.username" value="${mail.username}" />
	<property name="mail.password" value="${mail.password}" />
	<target name="war" depends="compile" description="Build the distribution .war file">
		<copy todir="${war.dir}/WEB-INF">
				<filter token="fitnetBranch" value="${}" />
				<filter token="" value="${}" />
				<filter token="mail.port" value="${mail.port}" />
				<filter token="mail.username" value="${mail.username}" />
				<filter token="mail.password" value="${mail.password}" />


 <mail:mail-session host="" password="@mail.password@" port="@mail.port@" username="@mail.username@"/>


These three configuration elements represents today a customer profile to us but the same concept can be applied to handle lots of other configuration elements. Feel free to enhance or correct the present document; as I'm not a ant power-user, some steps above might be useless.