Sun Java System Application Server 

Java BluePrints Build System

Java BluePrints Build system is a collection of build scripts based on ant. It provides for building, packaging, deploying and running different types of Java EE modules including ejb, war, ear, rar and par.

Build Environment

  1. Download and install the Java EE 5 SDK bundle along with Java SE. Make sure to use the Java SE which is bundled with Java EE 5 SDK since this has been tested.
  2. Set  JAVA_HOME and JAVA_HOME\bin in PATH
  3. Set ANT_HOME and ANT_HOME\bin in PATH. Make sure to use the 'ant' which came bundled with Java EE 5 SDK.
  4. Make the application server specific properties known to ant by editing build.properties under user's home directory and by adding the following properties.

  5. Property Name Description Examples
    javaee.home The installation directory of the Java EE 5 SDK /home/username/glassfish
    javaee.server.name Host name of the server where the Java EE 5 SDK is installed localhost
    javaee.server.port The port number for the server you chose while installing Java EE 5 SDK 8080
    javaee.server.username The administrator username specified for the serve while installing Java EE 5 SDK admin
    javaee.server.passwordfile The path to a file containing the admin password for the Java EE 5 SDK. The password file needs to be in the following format:

    AS_ADMIN_PASSWORD=<javaeesdk-admin-password>

    Where you will replace <javaeesdk-admin-password> with the admin password for the Java EE 5 SDK.

    /path/to/passwordfile
    javaee.adminserver.port The port number for admin server you chose while installing the Java EE 5 SDK 4848

  6. Start the application server and make sure it is running.

Ant Targets

Following are the commonly used ant targets:
check                        verify the build setup which is common for all modules
clean removes the generated directories like build and dist
compile compiles the project
create-javamail-resource creates javamail resource
create-jdbc-connection-pool creates jdbc connection pool
create-jdbc-resource creates jdbc resource
create-jms-connection creates jms connection
create-jms-resource creates jms resource
create-persistence-resource creates persistence resource
default compiles and packages the archive
delete-javamail-resource deletes javamail resource
delete-jdbc-connection-pool deletes jdbc connection pool
delete-jdbc-resource deletes jdbc resource
delete-jms-resource deletes jms resource
delete-persistence-resource deletes persistence resource
deploy deploys the application
keydel_common delete file-realm user
keygen_common create file-realm user
launch launches the application in a browser
listJmsDestinations lists jms destinations
package packages the archive
package-persistence-unit packages the archive
reconfig reconfigures the application server
run builds, packages and runs the application
runjavaclient run stand-alone java client
start-db starts the databse server.
stop-db stops the database server.
undeploy undeploys the application

Use the following targets to provide sample application specific behavior. The target names are self explanatory.
 -post-compile
-pre-clean
-pre-compile
-pre-deploy
-pre-setup

Java EE Modules/Applications

Using the above targets it is possible to build and run various types Java EE modules and applications as given below.

ear
Application Archive
jar
EJB Module
war
Web Module
rar
Connector Module
par
Persistence Archive
jar
Application Client Archive

Sample Build Files


Application  Project

<?xml version="1.0" encoding="UTF-8"?>
<project name="duke-stateful-ear" default="ear" basedir=".">

<property name="is.ear.module" value="true"/>

<path id="ear-components">
<filelist dir="./duke-stateful-ejb" files="build.xml"/>
<filelist dir="./duke-stateful-appclient" files="build.xml"/>
<filelist dir="./test" files="build.xml"/>
</path>

<import file="../../bp-project/main.xml"/>

<target name="all" depends="ear,deploy,client-stubs">
<antcall target="run"/>
</target>

<target name="run">
<subant target="run-app-client">
<fileset dir="duke-stateful-appclient" includes="build.xml"/>
</subant>
</target>

</project>

EJB Jar Project

<?xml version="1.0" encoding="UTF-8"?>
<project name="hello-stateless-ejb" default="default" basedir=".">

<property name="is.ejb-jar.module" value="true"/>

<import file="../../bp-project/main.xml"/>

<target name="all" depends="default,deploy">
<subant target="default">
<fileset dir="test" includes="build.xml"/>
</subant>
<antcall target="run"/>
</target>

<target name="run">
<subant target="runtest">
<fileset dir="test" includes="build.xml"/>
</subant>
</target>
</project>

Web Project

<?xml version="1.0" encoding="UTF-8"?>
<project name="bp-web-project" default="default" basedir=".">
    <property name="is.war.module" value="true"/> 
    <import file="bp-project/main.xml"/>   
</project>

Java Persistence Unit Project

<?xml version="1.0" encoding="UTF-8"?>
<project name="hello-pu" default="default" basedir=".">
    <description>Builds, tests, and runs the project hello-pu.</description>
    <property name="is.jar.module" value="true"/>
    <property name="is.persistence-unit.module" value="true"/>
    <import file="../../setup/main.xml"/>
</project>

Web Project That Depends on the above Java Persistence Unit Project

<?xml version="1.0" encoding="UTF-8"?>
<project name="hello-servlet" default="default" basedir=".">

    <property name="is.war.module" value="true"/>

    <!-- This project is dependent on the hello-pu project so it is declaring a dependency -->
    <property name="hello-pu.home" value="${home.dir}/../hello-pu"/>

    <!-- extra.classpath property adds to the classpath used for compilation -->
    <property name="extra.classpath" value="${hello-pu.home}/dist/hello-pu.jar"/>

    <!-- include the persistence unit in the Web-app -->
    <target name="-post-compile" depends="init">
        <copy file="${hello-pu.home}/dist/hello-pu.jar" todir="${build.dir}/web/WEB-INF/lib"/>
    </target>

    <!-- Note that this project is sharing the build system with other projects -->
    <import file="../../bp-project/main.xml"/>
</project>

Web Project That Depends on a JSF Component Library

<?xml version="1.0"?>
<project name="bp-slider-navigator" default="default" basedir=".">

  <property name="is.war.module" value="true"/>
  <import file="../../../bp-project/main.xml"/>

  <property name="project.ui" value="../../../components/ui"/>
  <property name="reference.ui.jar" value="${project.ui}/dist/ui.jar"/>

 <target name="-pre-compile" depends="init">
      <copy file="${reference.ui.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
  </target>     
</project>


Copyright © 2006 Sun Microsystems, Inc. All rights reserved.