OpenSubsystems

Business Components for Java Applications

Documentation :: EJB Support Implementation

Overview

This document describes how to implement stateless session beans (EJB) for OpenSubsystems security module, that can be applicable also for JOnAS and JBoss application servers. Particular ejb stuff is generated by using XDoclet tool. Here is described what sources should be changed and how to change them for generating particular ejb sources and deployment descriptors. This document also describes how to install and configure JOnAS, JBoss, BEA WebLogic and IBM WebSphere application servers and how to deploy JAR/EAR appllication for them.

1. Adding required libraries

There is used XDoclet tool For EJB implementation. XDoclet is an open source code generation engine. It enables Attribute-Oriented Programming for java. In short, this means that there is possible to add more significance to the code by adding meta data (attributes) to the java sources. This is done in special JavaDoc tags. XDoclet in Action XDoclet will parse source files and generate many artifacts such as XML descriptors and/or source code from it. These files are generated from templates that use the information provided in the source code and its JavaDoc tags. XDoclet documentation and product download is available at:
http://xdoclet.sourceforge.net/xdoclet/index.html

First there is important to download (we are using XDoclet version 1.2.2) and add XDoclet tool into the 'OpenSubsystems/external' directory. Convention is copy all libraries to the one directory with the name 'xdoclet' and then compress this directory into the 'xdoclet.zip' file. Name should not contains version number.

For example:
    OpenSubsystems/external/xdoclet.zip


Also there should be unpacked directory with particular libraries present in the 'OpenSubsystems/external' directory.

There is convention ignore by CVS specified directory located in the 'OpenSubsystems/external' directory, because there is already particular compressed file stored in this directory. Ignoring of the specified directory can be done by adding name of the directory into the file 'OpenSubsystems/external/.cvsignore'.

For example:
    file 'OpenSubsystems/external/.cvsignore':
    xdoclet - directory with this name will be ignored by CVS


2. Setting up classpath for added libraries

There is important to add classpaths to new added libraries the Java can found and use them. Classpaths to be added into the file 'OpenSubsystems/.classpath'. We have added here also J2EE libraries required by JOnAS and JBoss.

For example:
    <classpathentry kind="lib" path="external/xdoclet/lib/xdoclet-1.2.2.jar"/>
    <classpathentry kind="lib" path="external/xdoclet/lib/jboss-j2ee.jar"/>
    <classpathentry kind="lib" path="external/xdoclet/samples/lib/jboss-j2ee.jar"/>

3. EJB implementation within the OpenSubsystems

There is possibility easy to implement stateless session beans into the OpenSubsystems Security module. Sources XXXController.java located in org.opensubsystems.security.logic represent local interface for stateless session beans and sources XXXControllerImpl.java located in org.opensubsystems.security.logic.impl represent stateless session bean classes. It means we are missing home and remote interface and deployment descriptor (xml file). For generating all this missing stuff we will use XDoclet tool described above. Implementation sequence:

  1. Create new class org.opensubsystems.security.logic.StatelessController interface that represents base interface for all stateless controllers. This interface will be base interface for all derived controller interfaces. It is created because we don't want to have all the J2EE dependent stuff within the derived classes and it will be concentrated just here.

    For example:
    public interface StatelessController extends EJBLocalObject
    {
    }
                         
  2. Create new class org.opensubsystems.security.logic.impl.StatelessControllerImpl that represents implementation of StatelessController. This controller will be base class for all derived controller implementation classes. It is created because we don't want to have all the J2EE dependent stuff within the derived classes and it will be concentrated just here.

    For example:
    public abstract class StatelessControllerImpl implements StatelessController, SessionBean
    {
       ... ejb stuff
    }
                         
  3. Add special JavaDoc tags that will be parsed by XDoclet tool and used for generating all ejb stuff. We will add more types of these tags:

    1. common ejb tags applicable for all application servers (@ejb.tag)
      @ejb tag reference is vailable at: http://xdoclet.sourceforge.net/xdoclet/tags/ejb-tags.html

      We want to generate particular ejb stuff for all XXXControllerImpl classes except of the base implementation class StatelessControllerImpl. We will add xdoclet tags into these XXXControllerImpl classes located in org.opensubsystems.security.logic.impl.

      At the class level we will use @ejb.bean, @ejb.interface and @ejb.ejb-ref tags:
      • The @ejb.bean tag provides information about the EJB. It is the one compulsory tag for all EJBs, however not all parameters are applicable for all types of beans, and some parameters apply differently for different types of beans. We will specify following parameters for this tag:

        • type defines the bean's "type". We will use Stateless type.
        • name provides the name of the bean that will be used in the ejb-jar.xml deployment descriptor
        • jndi-name provides the JNDI name of the bean that will be used in the vendor specific deployment descriptors
        • local-jndi-name provides the JNDI name of the bean that will be used in the vendor specific deployment descriptors. It's the JNDI name for the local EJB.

        For example:
        /**
         * Implementation of DomainController interface to manage domains.
         *
         * @ejb.bean type="Stateless"
         *           name="DomainController"
         *           jndi-name="org.opensubsystems.security.logic.DomainControllerRemote"
         *           local-jndi-name="org.opensubsystems.security.logic.DomainController"
         */
        								   
      • The @ejb.interface tag provides information about an Entity or Session Bean's component interfaces (remote and/or local and/or service-endpoint). It is not applicable to Message-driven beans. The view-type "service-endpoint" is restricted to EJB2.1 Session beans. All parameters are applicable to both Entity and Session beans. We will specify following parameters for this tag:

        • local-extends declares which interface the generated local interface should extend. Default value(s): javax.ejb.EJBLocalObject
        • extends declare which interface the generated remote interface should extend. Default value(s): javax.ejb.EJBObject

        For example:
        /**
         * @ejb.interface local-extends="javax.ejb.EJBLocalObject, org.opensubsystems.security.logic.DomainController"
         *                extends="javax.ejb.EJBObject, org.opensubsystems.security.logic.DomainController"
         */
        								   
      • The @ejb.ejb-ref tag defines an EJB-reference to the bean with EJB-name [ejb-name]. ref-name is optional and if not specified then the reference name is [ejb-name] prefixed by "ejb/". Attention: you have to import the referred class (the ejbdoclet one) even your EJB does not need it. We will specify following parameters for this tag:

        • ejb-name defines the name of the EJB being referenced
        • ref-name defines the name that the referenced bean will be referred to by. For example, to refer to the bean Customer as java:comp/env/ejb/Customer name should be ejb/Customer. Default value(s): ejb/[ejb-name], where [ejb-name] is the name of the referenced bean.

        For example:
        /**
         * @ejb.ejb-ref ejb-name="AuthorizationController"
         *              ref-name="org.opensubsystems.security.logic.AuthorizationController"
         */
        								   
      At the method level we will use @ejb.interface-method and @ejb.transaction tags:
      • The @ejb.interface-method tag declares in which interface (local/remote) this method must appear. If the view-type parameter is absent then the method will be added to whatever component interfaces are defined in @ejb.bean.

        For example:
        /**
         * @ejb.interface-method
         */
        								   
      • The @ejb.transaction tag defines the transactional behaviour for this method. Applicable to methods with @ejb.create-method and @ejb.interface-method tags. If used on class level applies to all interface methods unless overridden. We will specify type parameter as following:

        • type="Supports" will be specified for read only methods
        • type="Required" will be specified for methods that modifies data

        For example:
        /**
         * @ejb.transaction type="Supports"
         */
        								   
    2. specific JOnAS tags (@jonas.tag)
      @jonas tag reference is vailable at: http://xdoclet.sourceforge.net/xdoclet/tags/objectweb-tags.html

      At the class level we will use @jonas.bean and @jonas.ejb-ref tags:
      • The @jonas.bean tag declares the JOnAS specific information for an enterprise bean. We will specify following parameters for this tag:
        • ejb-name defines the enterprise bean's name specified in the standard EJB deployment descriptor
        • jndi-name provides the JNDI name of the enterprise bean's home. Concerns only the Entity and Session beans. Mandatory if version < 2.5, but optional for Session beans for 2.5 onwards.

        For example:
        /**
         * @jonas.bean ejb-name="DomainController"
         *             jndi-name="org.opensubsystems.security.logic.DomainControllerRemote"
         */
        								   
      • The @jonas.ejb-ref tag declares the JOnAS specific information for a reference to another enterprise bean's home. We will specify following parameters for this tag:

        • ejb-ref-name defines the name of the ejb reference specified in the standard EJB deployment descriptor
        • jndi-name provides the JNDI name of the ejb

        For example:
        /**
         * @jonas.ejb-ref ejb-ref-name="org.opensubsystems.security.logic.AuthorizationController"
         *                jndi-name="org.opensubsystems.security.logic.AuthorizationControllerRemote"
         */
        								   
    3. specific JBoss tags (@jboss.tag)
      @jboss tag reference is vailable at: http://xdoclet.sourceforge.net/xdoclet/tags/jboss-tags.html

      At the class level we will use only @jboss.ejb-ref-jndi tag:
      • The @jboss.ejb-ref-jndi tag sets the JNDI name of a referenced bean. There must be an @ejb.ejb-ref tag too which points to the referenced bean. We will specify following parameters for this tag:

        • ref-name defines the name of the bean reference
        • jndi-name provides the JNDI name of the ejb

        For example:
        /**
         * @jboss.ejb-ref-jndi ref-name="org.opensubsystems.security.logic.AuthorizationController"
         *                     jndi-name="org.opensubsystems.security.logic.AuthorizationControllerRemote"
         */
        								   
    4. specific BEA WebLogic tags (@weblogic.tag)
      @weblogic tag reference is vailable at: http://xdoclet.sourceforge.net/xdoclet/tags/bea-tags.html

      At the class level we will use only @weblogic.ejb-reference-description tag:
      • The @weblogic.ejb-reference-description tag specifies a reference to an EJB external to the current deployment-package. There must be an @ejb.ejb-ref tag too which points to the referenced bean. We will specify following parameters for this tag:

        • ejb-ref-name defines the EJB reference name, this is the reference that you put in the tag @ejb.ejb-ref with ref-name parameter
        • jndi-name provides the jndi-name element gives the JNDI name where the bean or resource will be bound in WebLogic Server. References the tag @ejb.bean with "jndi-name" property

        For example:
        /**
         * @weblogic.ejb-reference-description 
         *               ejb-ref-name="org.opensubsystems.security.logic.AuthorizationController"
         *               jndi-name="org.opensubsystems.security.logic.AuthorizationControllerRemote"
         */
        								   
    5. specific IBM WebSphere tags (@websphere.tag)
      @weblogic tag reference is vailable at: http://xdoclet.sourceforge.net/xdoclet/tags/ibm-tags.html

      There is not necessarry to add specific @websphere XDoclet tags.


  4. Define the XDoclet task for Ant. This is provided by changing of the build.xml file. Here the compile target depends on the ejbdoclet target. This means that before compiling anything all home/local/remote interfaces, primary key, data-objects and deployment descriptors are generated. The first thing you have to do is define the ejbdoclet task for Ant. To do so you use taskdef, where you specify xdoclet.modules.ejb.EjbDocletTask as the class implementing ejbdoclet task. Note that the classpathref points to the path with id "project.class.path". This path should have all XDoclet jar files and commons-logging.jar.
    Next you declare ejbdoclet task, with a set of configuration parameters and nested elements. For example, destdir specifies where to put generated files. As you can see there's an inheritance mechanisms also, you can override this destdir parameter for each nested element (or as we call it sub-task).
    <deploymentdescriptor/> does exactly that; put the generated ejb-jar.xml file somewhere else than where generated java sources for home/remote/pk/etc are placed. For a complete list of configurable parameters consult the Ant Task Reference for each task and sub-task.
    By default each task has some built-in sub-tasks. Some of them are mandatory, for example <remoteinterface/> and <localinterface/>, can you imagine an EJB without a remote or local (EJB 2.0 only) interface? Some other tasks may be optional, for example <jonas/>, <jboss/> <weblogic/> are optional if you're not using JOnAS, JBoss, BEA WebLogic or IBM WebSphere Application Servers.

    For example:
    <taskdef name="ejbdoclet"
             classname="xdoclet.modules.ejb.EjbDocletTask" 
             classpathref="externalxdocletjars"//>
    
    <taskdef name="weblogic" 
             classname="xdoclet.modules.bea.wls.ejb.WebLogicSubTask" 
             classpathref="externalxdocletjars"//>  
    
    <target name="compile-ejb" 
            description="Generate and compile ejb related classes">
    
    <!-- Generate ejb classes --> 
    <ejbdoclet ejbspec="2.0" ejbClassNameSuffix="Impl"  
               destdir="${generated_home}/${projectname}/${build_home}/generated-ejb/"
               excludedtags="@version,@author"
               addedtags="@xdoclet-generated at ${TODAY}">
               <!-- verbose="true" -->
    
       <fileset dir="${generated_home}/${projectname}/${buildsrc_home}/${code_home}">
          <include name="**/*ControllerImpl.java"/>  
       </fileset>
     
       <!-- This will generate remote ejb interface for the controller interface -->  
       <remoteinterface pattern="{0}Remote"/>
       <!-- This will generate local ejb interface for the controller interface -->  
       <localinterface pattern="{0}Local"/>  
       <!-- This will generate remote home ejb interface for the controller interface -->  
       <homeinterface pattern="{0}RemoteHome"/>
       <!-- This will generate home ejb interface for the controller interface -->  
       <localhomeinterface pattern="{0}Home"/>
       <!-- This will generate session ejb for the controller impl class-->
       <session pattern="{0}Ejb"/>
             
       <deploymentdescriptor validateXML="false"/>
       <jonas version="${jonas.version}" validateXML="false"/>
       <jboss version="${jboss.version}" validateXML="false"/>
       <weblogic version="${weblogic.version}" validateXML="false" createtables="Disabled"/>
       <webSphere/>
    
    </ejbdoclet>          
                           

    Code above is part of the build-generic.xml file and it will generate security-ejb.jar file included particular deployment descriptor.

4. JOnAS installation, configure and application deploying

  1. Server installation

    Download the binary version of JOnAS (we are using JOnAS version 4.2.3) with Tomcat or Jetty from the JOnAS download page.
    Choose a location for the JOnAS installation. Be aware that if you have already installed a previous version of JOnAS in this location, the new installation will overwrite the existing files, thus customized configuration files may be lost. Therefore, it is prudent to save these files before starting the installation process.
    The installation process consists of untaring the downloaded file. Change to the directory in which JOnAS will be installed and untar this file, using the tar -zxvf jonas.tgz command. Note that this file can be opened with winzip on Windows. After installing the JOnAS product, set the following environment variable:
    export JONAS_ROOT = <Installation Directory>
    PATH = $JONAS_ROOT/bin/unix:$PATH (on Windows: PATH=%JONAS_ROOT%/bin/nt;%PATH%)

    For more information read installation guide.

    Full documentation is available at JOnAS documentation pages.

  2. Configuring and starting server

    IMPORTANT: For ejb there is neccessary to set up Jeremie protocol within the particular configuration file. You have to configure file $JONAS_ROOT/conf/carol.properties. Here you have to set up property carol.protocols=jeremie. For more help you can see documentation about choosing the protocol.
    Except of protocol changing there is not neccessary to change default server configuration for its running. If you want to reconfigure default settings you can follow JOnAS configuration guide.
    Use the command jonas check to verify that the environment is correct. If the environment is correct, JOnAS is ready to use.
    Do a jonas start, then use a browser to go http://localhost:9000/. (Modify this url with the appropriate hostname.) From the root context in which JOnAS was deployed, you can execute the earsample, access the JOnAS administration application, as well as perform other functions. Stopping JOnAS server is possible by command jonas stop.

  3. JOnAS datasource configuration

    If you want to run application against specified database there is necessary to configure particular datasources. For OpenSubsystems datasource configuration you have to follow next steps:

    1. Copy particular JDBC driver into the directory $JONAS_ROOT/lib/commons/jonas

    2. Define particular DB property file in the $JONAS_ROOT/conf directory. For example: $JONAS_ROOT/conf/MySQL.properties
      Set up these properties using values specified by application you want to run. For running OpenSubsystems application you have to get property values from osstestXXX.properties (where XXX is the name of particular database - e.g. if XXX = mysql => property file = osstestmysql.properties ).
      Property files are located within the test_module.jar file (e.g. security.jar). This jar file is located in the root of EAR package or in WEB-INF/lib of the WAR package.
      IMPORTANT: datasource.name property must be set to OSSDS . This is because we are allways looking for JNDI datasource with the OSSDS name. This is described at J2EE connection pools support
      For example:
      Setting up properties within the MySQL.properties:
      datasource.name OSSDS
      datasource.url jdbc:mysql://localhost:3306/OSS
      datasource.classname com.mysql.jdbc.Driver
      datasource.username root
      datasource.password
      If you want to define your own property settings you should modify also osstestXXX.properties file and set up there your property values (where XXX is the name of particular database - e.g. if XXX = mysql => property file = osstestmysql.properties ).

    3. OBSOLETE: Define $JONAS_ROOT/conf/jonas.properties file, attribute jonas.service.dbm.datasources. Set the jonas DataSources. This enables the JOnAS server to load the data dources, to load related jdbc drivers, and to register the data sources into JNDI. This property is set with a coma-separated list of Datasource properties file names (without the '.properties' suffix).
      For example: Oracle1,InstantDB1 (while the Datasources properties file names are Oracle1.properties and InstantDB1.properties)

      NEW INFO: Due to bug #1473820 you cannot user property files to configuration of datasources and you have to user resource adapters instead. Make sure the minimal connection constant is set to 0. The convert the property file to resource adapter using command

      C:\JOnAS-4.6.6\conf>RAConfig -dm -p ossds-hsqldb %JONAS_ROOT%/rars/autoload/JOnAS_jdbcDM ossds-hsqldb_dm
                                 

      The copy the newly created resource adapter ossds-hsqldb_dm.rar into C:\JOnAS-4.6.6\rars\autoload.

    For more information refer to JOnAS JDBC DataSources configuration guide

    If you don't want to use property files (osstestXXX.properties) included within the WAR/EAR file (e.g. in the security.jar file located in the root of EAR package or in the WEB-INF/lib of WAR package), you can locate own external property files into the directory $JONAS_BASE/conf.

  4. Deployment and installation process

    There is possible deployment and installation of Enterprise Beans, Web and J2EE applications.
    1. To deploy the Enterprise Beans in JOnAS, the deployer must add the interposition classes interfacing the EJB components with the services provided by the JOnAS application server.
      The GenIC tool supplied in the JOnAS distribution provides the capability of generating interposition classes and updating the ejb-jar file.
      Other possibility is to define Ant task for generating interposition classes and updating the ejb-jar file. For OpenSubsystems there are generated particular EJB files using ant task as described bellow. Following stuff will be generated by ant task:

      1. generated ejb source classes and xml files will be located at directory OpenSubsystems/generated/<projectname>/build/generated-ejb/. <projectname> is name of the project (For example: security | core | patterns ).
      2. compiled ejb classes will be located at directory OpenSubsystems/generated/<projectname>/build/ejb-compiled/. and xml files will be located at directory OpenSubsystems/generated/<projectname>/build/ejb-compiled/META-INF/. <projectname> is name of the project (For example: security | core | patterns ).
      3. packaged ejb-jar file will be located at OpenSubsystems/generated/<projectname>/build/<projectname>-ejb.jar. <projectname> is name of the project (For example: security | core | patterns ).

      For more information read Build Process and Building Web Application.

      Following code is part of the build-generic.xml file.

      For example:
      <!-- Build jonas jar -->
      <target name="build-jonas-jar" if="jonas.jar.exists">
      
        <taskdef name="jonasejbjar"
                 classname="org.objectweb.jonas.ant.EjbJar"
                 classpath="${jonas_home}/lib/common/ow_jonas_ant.jar"/>
      
        <delete file="${generated_home}/${projectname}/${build_home}/${projectname}-ejb.jar"/>
        <jonasejbjar basejarname="${projectname}-ejb"
                     srcdir="${generated_home}/${projectname}/${build_home}/ejb-compiled"
                     descriptordir="${generated_home}/${projectname}/${build_home}/generated-ejb">      
          <classpath>
             <fileset dir="${generated_home}/${projectname}/${external_home}">
                <include name="**/*.jar"/>
             </fileset>
             <pathelement path="${generated_home}/${projectname}/${build_home}/code"/>
          </classpath>   
          <include name="**/ejb-jar.xml"/>
          <exclude name="**/jonas-ejb-jar.xml"/>
          <!-- Change the keepgenerated to true, the java files will be placed 
               inside of the ear file
          -->  
          <jonas jonasroot="${jonas_home}"
                 destdir="${generated_home}/${projectname}/${build_home}/"
                 keepgenerated="false"
                 protocols="jeremie"/>
        </jonasejbjar>  
      
      </target>
                                   

      The application deployer may also need to customize the deployment descriptors in order to adapt it to a specific operational environment. This must be done before using GenIC.
      The deployer may choose to deploy the Enterprise Beans as stand-alone application components. For this case particular ejb-jar must be installed. There are two possibilities how to install ejbstand-alone applications:

      • automatically deployed and loaded ejb application after JOnAS application server is started - you have to copy particular ejb file (for example: security-ejb.jar) into the $JONAS_ROOT/ejbjars/autoload directory
        Or the name of the jar file can be added in the jonas.service.jar.descriptors section.
      • manually deployed and loaded ejb application from JOnAS web admin console - first you have to copy particular ejb file (for example: security-ejb.jar) into the $JONAS_ROOT/ejbjars directory. Then start JOnAS application server. Run JOnAS web application console from your browser at http://localhost:9000/jonasAdmin. Administration console login page will be shown. Type usename jonas, password jonas and click Login button to log in to the administration console. Choose EJB Modules (JAR) from left pane tree Server JOnAS -> Deployment. There will be shown two lists on the Deployment tab. Choose particular ejb-jar file (for example: security-ejb.jar) from the Deployable list. Click to button >>> and selected ejb-jar sources will be added to the Deployed list. Click to Apply button to confirm ejb-jar stand-alone applications that will be deployed.
      The deployer may also choose to include them in war or ear packaging, which is presented in the following sections.

    2. Before deploying a J2EE application in the JOnAS application server, first package its components in an ear file as explained in the EAR packaging guide.
      Ear packaging is possible to process by Ant task. For OpenSubsystems there is generated particular EAR file using ant task as described bellow. Following stuff will be generated by ant task:

      1. generated ear package will be located at directory OpenSubsystems/generated/<projectname>/build/<projectname>.ear. <projectname> is name of the project (For example: security | core | patterns ).

      Following code for ant task is also included within the our build-generic.xml file:

      For example:
      <!-- Generate ejb deployment package with ejb server dependent file generation -->
      <target name="package-app" unless="ignoreejbdeploy"
              description="Package the application file for this project">
      
         <delete file="${generated_home}/${projectname}/${build_home}/${projectname}.ear"/>
         <ear destfile="${generated_home}/${projectname}/${build_home}/${projectname}.ear"
              appxml="${generated_home}/${projectname}/${buildsrc_home}/${config_home}/application.xml"
              compress="true" update="false" duplicate="fail">
            <fileset dir="${generated_home}/${projectname}/${build_home}">
               <include name="*.jar"/> 
               <include name="*.war"/> 
               <!-- Exclude the tests and junitee since they are already included
                    in war file, we still have to include the testutils  since
                    they needs to be loaded by the same classloader as the rest
                    of the classes -->
               <exclude name="${projectname}-tests.jar"/>
            </fileset>
            <fileset dir="${generated_home}/${projectname}/${external_home}/runtime">
               <exclude name="junitee.jar"/>  
               <exclude name="*-tests.jar"/>  
            </fileset>
         </ear> 
      </target>
                                   

      There are two possibilities how to install EAR applications:

      • automatically deployed and loaded ear application after JOnAS application server is started - you have to copy particular ear file (for example: security.ear) into the $JONAS_ROOT/apps/autoload directory
        Or the name of the ear file can be added in the jonas.service.ear.descriptors section.
      • manually deployed and loaded ear application from JOnAS web admin console - first you have to copy particular ear file (for example: security.ear) into the $JONAS_ROOT/apps directory.
        Then start JOnAS application server. Run JOnAS web application console from your browser at http://localhost:9000/jonasAdmin. Administration console login page will be shown. Type usename jonas, password jonas and click Login button to log in to the administration console. Choose Applications (EAR) from left pane tree Server JOnAS -> Deployment. There will be shown two lists on the Deployment tab. Choose particular ear file (for example: security.ear) from the Deployable list. Click to button >>> and selected ear sources will be added to the Deployed list. Click to Apply button to confirm ear applications that will be deployed.

       

    3. Before deploying a web application in the JOnAS application server, first package its components in a war file as explained in the WAR packaging guide.

      War packaging is possible to process by Ant task. For OpenSubsystems there is generated particular WAR file using ant task as described bellow. Following stuff will be generated by ant task:

      1. generated war package will be located at directory OpenSubsystems/generated/<projectname>/build/<projectname>.war. <projectname> is name of the project (For example: security | core | patterns ).

      Following code for ant task is also included within the our build-generic.xml file:

      For example:
      <!-- Webui without libraries -->  
      <delete file="${generated_home}/${projectname}/${build_home}/${projectname}.war"/>
      <war destfile="${generated_home}/${projectname}/${build_home}/${projectname}.war" 
           webxml="${webui.directory}/WEB-INF/web.xml"
           compress="true"
           update="false"
           duplicate="fail"
           index="true">
         <fileset dir="${webui.directory}">
            <!-- Exclude the web.xml since it is explicitely specified above using webxml -->
            <exclude name="**/web.xml"/>
         </fileset> 
         <!-- Always include tests and junitee in web-inf lib since thats
              the only way how to run tests in war file --> 
         <lib dir="${generated_home}/${projectname}/${build_home}">
            <include name="${projectname}-tests.jar"/>
         </lib>
         <lib dir="${generated_home}/${projectname}/${external_home}/runtime"> 
            <include name="*-tests.jar"/>  
         </lib>
         <lib dir="${generated_home}/${projectname}/${external_home}/runtime">
            <include name="junitee.jar"/>  
         </lib>
      </war>   
                                   

      There are two possibilities how to install WAR applications:

      • automatically deployed and loaded war application after JOnAS application server is started - you have to copy particular war file (for example: security.war) into the $JONAS_ROOT/webapps/autoload directory
        Or the name of the ear file can be added in the jonas.service.web.descriptors section.
      • manually deployed and loaded war application from JOnAS web admin console - first you have to copy particular war file (for example: security.war) into the $JONAS_ROOT/webapps directory.
        Then start JOnAS application server. Run JOnAS web application console from your browser at http://localhost:9000/jonasAdmin. Administration console login page will be shown. Type usename jonas, password jonas and click Login button to log in to the administration console. Choose Web Modules (WAR) from left pane tree Server JOnAS -> Deployment. There will be shown two lists on the Deployment tab. Choose particular ear file (for example: security.war) from the Deployable list. Click to button >>> and selected ear sources will be added to the Deployed list. Click to Apply button to confirm war applications that will be deployed.
      •  

  5. Running JUnitEE tests

    JUnitEE tests is possible to run from web browser at the location: http://servername:9000/test_module/TestServlet, where test_module is particular generated WAR/EAR file:
    For example: for security.war (security.ear) there will be used location: http://servername:9000/security/TestServlet

  6. Debugging tests running under JOnAS application server

    For allowing to debug application there is neccessary to modify $JONAS_ROOT/bin/nt/jonas.bat file. Add following option definition at the end of particular JAVA_OPTS section in the jonas.bat file:
    set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
    For more information about particular options read the Java application launcher documentation.
    You can use Eclipse IDE to debug application running under JOnAS that was started in the debug mode. Follow Debugging Remote Application for instructions.

Whole process described above (generating interposition classes and updating the ejb-jar file, ear and war packaging) is provided by our build-<projectname>.xml file. You can just run build-<projectname>.xml - update target and there will be generated all necessary stuff. <projectname> represents name of the project (for example: security | core | patterns )

For more information read deployment and Installation Guide

5. JBoss installation, configure and application deploying

  1. Server installation

    Download the binary version of the free JBoss application server (we are using JBoss version 3.2.6 and version 4.0.1) from the location http://www.jboss.org/downloads/index
    The binary versions are available as either .zip, .tar.gz, .bz2 files. The contents are the same so grab whichever flavor is most convenient for the platform you’re running on. Once it's downloaded, unpack the archive to a suitable location on your machine. It should all unpack into a single directory named for example jboss-4.0.1. Of course the version number suffix will be different if you are running a later release. Make sure you don't use a directory which has any spaces in the path (such as the Program Files directory on Windows) as this may cause problems.
    The only additional requirement to run JBoss is to have an up-to-date version of Java on your machine. JBoss 4.0.1 requires at least a 1.4 JDK to run. Make sure to get the JDK and not the JRE. Although JBoss will startup with the JRE only, you'll experience problems compiling JSPs with it. You should also make sure the JAVA_HOME environment variable is set to point to your JDK installation.

    For more information read installation guide

  2. Configurind and starting server

    There is not neccessary to change default server configuration for its running.
    You'll find a bin directory inside the main JBoss directory which contains various scripts. Execute the run script (run.bat if you're on Windows, run.sh if you're on Linux, OS X, or another UNIX-like system). You should then see the log messages from all the JBoss components as they are deployed and started up. The last message (obviously with different values for the time and start-up speed) should look like the following.

    11:29:39,944 INFO [Server] JBoss (MX MicroKernel) [4.0.0 (build: CVSTag=JBoss_4_0_0 date= 200409200418)] Started in 1m:18s:941ms

    You can verify that the server is running by going the JBoss web server, which is running on port 8080. (Make sure you don't have anything else already on your machine using that port) The default page has links to a few useful JBoss resources.
    You can get a live view of the server by going to the JMX console application at http://localhost:8080/jmx-console

  3. JBoss datasource configuration

    If you want to run application against specified database there is necessary to configure particular datasources. For OpenSubsystems datasource configuration you have to follow next steps:

    1. Copy particular JDBC driver into the directory $JBOSS_ROOT/server/{all|default|minimal}/lib
    2. To use particular data source, copy /docs/examples/jca/XXX-ds.xml to the $JBOSS_ROOT/server/{all|default|minimal}/deploy directory, where XXX is particular database (e.g. for MySQL it will be file mysql-ds.xml). Then modify the XXX-ds.xml configuration file by setting particular attributes. Set up these properties using values specified by application you want to run. For running OpenSubsystems application you have to get property values from osstestXXX.properties (where XXX is the name of particular database - e.g. if XXX = mysql => property file = osstestmysql.properties ).
      Property files are located within the test_module.jar file (e.g. security.jar). This jar file is located in the root of EAR package or in WEB-INF/lib of the WAR package.
      For example:
      Setting up properties within the mysql-ds.xml:
      <jndi-name>OSSDS</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/OSS</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>root</user-name>
      <password></password>

      IMPORTANT: <jndi-name> property must be set to OSSDS . This is because we are allways looking for JNDI datasource with the OSSDS name. This is described at J2EE connection pools support
      There is not important to have configuration file present, the configuration information will be read from our application property file. There is neccessary to have particular JDBC driver present within the $JBOSS_ROOT/server/{all|default|minimal}/lib directory.

    For more information refer to Using other Databases for JBoss

    If you don't want to use property files (osstestXXX.properties) included within the WAR/EAR file (e.g. in the security.jar file located in the root of EAR package or in the WEB-INF/lib of WAR package), you can locate own external property files into the directory on the JBoss classpath. This classpath is defined by variable %JBOSS_CLASSPATH% and can be modified within the $JBOSS_ROOT/bin/run.bat file for Windows OS or $JBOSS_ROOT/bin/run.sh file for Linux OS.
    Another possibility is to specify particular property files within the file $JBOSS_ROOT/server/{all|default|minimal}/deploy/properties-service.xml. This JBoss configuration file allows the setting of global system properties (as returned by System.getProperties). You can specify usingof external properties as following:

                         
       <attribute name="osstestproperties">
          ./conf/osstestXXX.properties, ./conf/osstestYYY.properties
       </attribute>
                         
                    

  4. Deployment and installation process

    There is possible deployment and installation of Enterprise Beans, Web and J2EE applications.
    1. For deployment there is necessary to create deployment descriptor named as jboss.xml. This can be automatically generated by XDoclet. We should modify build-generic.xml file by adding particular tag into the part for <ejbdoclet> tag. It is described in the section 'd.' of the part 3. EJB implementation

      For example:
         <jbosss version="3.2" validateXML="false"/>
                                   

      Generated deployment descriptor jboss.xml must be placed within the same directory META-INF as other particular deployment descriptors (ejb-jar.xml, jonas-ejb-jar.xml). After generating this file Ant will copy it to the specified directory:

      For example:
      <!-- Add jboss.xml file into the META-INF directory 
              of the generated ${projectname}-ejb.jar file -->
      <jar destfile="${generated_home}/${projectname}/${build_home}/${projectname}-ejb.jar" 
              update="true">
         <fileset dir="${generated_home}/${projectname}/${build_home}/ejb-compiled">
            <include name="META-INF/jboss.xml"/>
            <include name="META-INF/weblogic-ejb-jar.xml"/>
         </fileset>  
      </jar>
                                   
    2. Before deploying a J2EE application in the JBoss application server, first package its components in an ear file the same way as explained in the particular JOnAS part EAR packaging guide.
      Ear packaging is possible to process by Ant task and this is also included within the our build-generic.xml file - also described in JOnAS Deployment and installation process.
      Next, install the ear file into the $JBOSS_ROOT/server/<server_config>/deploy directory. <server_config> is actual JBoss configuration (all | default | minimal | standard).
      Finally, run the JBoss application Server (described in the part Starting server above).
      The application components are deployed in EJB and web containers created during the startup. The application components can be dynamically deployed by adding j2ee application to the particular deploy directory.

    3. Before deploying a web application in the JBoss application server, first package its components in a war file the same way as explained in the particular JOnAS part WAR packaging guide.
      War packaging is possible to process by Ant task and this is also included within the our build-generic.xml file and it is provided the same way as described for JOnAS Deployment and installation process.
      Next, install the ear file into the $JBOSS_ROOT/server/<server_config>/deploy directory. <server_config> is actual JBoss configuration (all, default, minimal, standard).
      Finally, run the application Server (described in the part Starting server above)
      The web components are deployed in a web container created during the startup. The web components can be dynamically deployed by adding web application to the particular deploy directory.

  5. Server configuration for running JUnitEE tests

    JUnitEE tests is possible to run from web browser at the location: http://servername:8080/test_module/TestServlet, where test_module is particular generated WAR file:
    For example: for security.war there will be used location: http://servername:8080/security/TestServlet

  6. Debugging tests running under JBoss application server

    For allowing to debug application there is neccessary to modify $JBOSS_ROOT/bin/run.conf file. Uncomment following option for allowing debug mode. For example:
    JAVA_OPTS="-classic -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n $JAVA_OPTS"
    For more information about particular options read the Java application launcher documentation.
    You can use Eclipse IDE to debug application running under JBoss that was started in the debug mode. Follow Debugging Remote Application for instructions.

6. BEA WebLogic installation, configure and application deploying

  1. Server installation

    Download the binary version of the free BEA WebLogic application server (we are using WebLogic version 7.0 SP5 and version 8.1 SP4) from the location http://commerce.bea.com/showallversions.jsp?family=WLS
    Run downloaded installation file and choose Complete Installation type and follow instruction.
    For more information read installation guide

    Creating and Extending Domains Using the Configuration Wizard
    Before you can develop and run a WebLogic Platform application, you must first create a WebLogic Server domain. You can create a domain quickly and easily by using a configuration template that provides domain configuration information as input to the Configuration Wizard. The Configuration Wizard, shown in the following figure, is a stand-alone Java application that can be run independently of WebLogic Server to simplify the creation of domains.
    To create a domain using the Configuration Wizard, select the configuration template that best meets your requirements and use it to build your domain.
    The Configuration Wizard provides two options for creating domains:

    • Express configuration — This option allows you to create a domain quickly, using the default settings from the configuration template of your choice. Keep in mind that in this mode you cannot modify template settings (for example, server port numbers) while you are creating your domain.

    • Custom configuration — This option allows you to modify configuration information as appropriate for your particular requirements. Once you decide to customize your domain, you have the option of specifying the following components and parameters:

      • Infrastructure components, including Managed Servers, clusters, and physical host machines
      • Database and messaging services — Java Database Connectivity (JDBC) and Java Message Service (JMS)
      • Targets (servers and clusters)
      • Security parameters
      • General environment and operating system parameters

    Setting up JAVA_HOME variable for WebLogic 7.0
    After WebLogic 7.0 server installing there is used JDK 1.3 as default. OpenSubsystems sources are compiled under JDK 1.4 and therefore we have to set up this version for WebLogic 7.0. We have to set up following:

    • Modify file $BEA_HOME/user_projects/workshopDomain/startWebLogic.cmd
      set JAVA_HOME=path_to_jdk14
    • Modify file $BEA_HOME/weblogic700/server/bin/startWLS.cmd
      set JAVA_HOME=path_to_jdk14
    • Modify file $BEA_HOME/weblogic700/common/bin/commEnv.cmd
      set COMM_JAVA_HOME=path_to_jdk14
      set COMM_JAVA_VERSION=1.4.1

  2. Starting WebLogic 8.1 server

    When you install WebLogic Platform on a Windows system, the installation program automatically creates shortcut files on the Start Menu. Options on the Start Menu vary, according to the components you choose to install.
    The WebLogic Platform 8.1 folder (Start—>Programs—>BEA WebLogic Platform 8.1) contains the shortcut files shown in the following figure.

    • Examples—contains a folder for each component installed on your system and the WebLogic Server MedRec example. The component folders contain shortcuts for launching the samples and associated tools for the component.

    • Other Development Tools—contains shortcuts for launching the Configuration Template Builder, DbVisualizer, Node Manager, Format Builder and the WebLogic Builder development tools.

    • Configuration Wizard—starts the Configuration Wizard to help you create user domains. For information about using the Configuration Wizard, see the online help available with the software or Creating WebLogic Configurations Using the Configuration Wizard at http://e-docs.bea.com/platform/docs81/confgwiz/index.html.

    • Online Documentation—provides a link to the BEA WebLogic Platform online documentation on the e-docs Web site.

    • QuickStart—starts the WebLogic Platform QuickStart application designed to assist first-time users in evaluating, learning, and using WebLogic Platform.

    • Smart Update—launches the Smart Update program, which checks for any updates available for installed BEA products, and installs the updates as required.

    • Uninstall WebLogic Platform 8.1—launches the WebLogic Platform 8.1 uninstallation program. For more information, see Uninstalling WebLogic Platform.

    • WebLogic Workshop 8.1—contains a shortcut for launching WebLogic Workshop. For details about using WebLogic Workshop, see the WebLogic Workshop documentation set at http://e-docs.bea.com/workshop/docs81/index.html.


    Starting WebLogic 8.1 server is possible (after creating domain):
    • from Windows Start menu (User Project -> Portal Domain -> Start WLS Server for Portal Domain)
    • from command line run $BEA_HOME/user_projects/domains/portalDomain/{startWebLogic.cmd | startWebLogic.sh}

    Stopping WebLogic 8.1 server is possible (after creating domain):
    • from Windows Start menu (User Project -> Portal Domain -> Stop WLS Server for Portal Domain)
    • from command line run $BEA_HOME/user_projects/domains/portalDomain/{stopWebLogic.cmd | stopWebLogic.sh}

  3. Starting WebLogic 7.0 server

    When you install WebLogic Platform on a Windows system, the installation program automatically creates shortcut files on the Start Menu. Options on the Start Menu vary, according to the components you choose to install.
    The WebLogic Platform 7.0 folder (Start—>Programs—>BEA WebLogic Platform 7.0) contains the shortcut files shown in the following figure.

    • User Projects-contains a folder for each domain that you create using the Configuration Wizard. The domain folders contain shortcuts for launching the server if you chose to create a start menu option when you created the domain. If you configured a domain for WebLogic Integration, a shortcut for the Integration Database Wizard is installed. For details about creating domains using the Configuration Wizard, see Using the Configuration Wizard.

    • WebLogic Integration 7.0-contains shortcuts to launch the WebLogic Integration Tools and examples. For details about using WebLogic Integration, see the WebLogic Integration documentation set at the following URL:
      http://e-docs.bea.com/wli/docs70/index.htm

    • WebLogic Portal 7.0-contains shortcuts to launch the WebLogic Portal tools and examples. For details about using WebLogic Portal, see the WebLogic Portal documentation set at the following URL:
      http://e-docs.bea.com/wlp/docs70/index.htm

    • WebLogic Server 7.0-contains shortcuts to launch the Examples and Pet Store servers, the WebLogic Builder, and a page containing introductory information about WebLogic Server. For details about using WebLogic Server, see the WebLogic Server documentation set at the following URL:
      http://e-docs.bea.com/wls/docs70/index.html

    • WebLogic Workshop-contains shortcuts to launch the WebLogic Workshop and examples. For details about using WebLogic Workshop, see the WebLogic Workshop documentation set at the following URL:
      http://e-docs.bea.com/workshop/docs70/index.html

    • Domain Configuration Wizard-starts the Configuration Wizard to assist you in creating user domains. For information about the Configuration Wizard, see Using the Configuration Wizard at the following URL:
      http://e-docs.bea.com/platform/docs70/confgwiz/index.html

    • Online Documentation-provides a link to the BEA WebLogic Platform online documentation on the e-docs Web site.

    • QuickStart-starts the WebLogic Platform QuickStart application designed to assist first-time users in evaluating, learning, and using WebLogic Platform.

    • Smart Update-launches Smart Update to check for updates available for installed BEA products, and installs the updates as required.

    • Uninstall WebLogic Platform 7.0-launches the WebLogic Platform 7.0 uninstallation program. For more information, see Uninstalling WebLogic Platform.


    For starting WebLogic 7.0 you can use shortcut to default created server: -> from Windows Start menu (userProjects -> workshopDomain -> Start Server)
    Or you can use command line run $BEA_HOME/user_projects/workshopDomain/{startWebLogic.cmd | startWebLogic.sh}
    You can define own domain, run Domain Configuration Wizzard from Start menu, choose WebLogic Workshop and specify domain name, username and password. Finally create shortcut for server starting.

    For stopping WebLogic 7.0 you can use shortcut to default created server: -> from Windows Start menu (userProjects -> workshopDomain -> Stop Server)
    Or you can use command line run $BEA_HOME/user_projects/workshopDomain/{stopWebLogic.cmd | stopWebLogic.sh}

  4. WebLogic datasource configuration

    If you want to run application against specified database there is necessary to configure particular datasources. For accessing to the various DB systems we have to configure Connection Pools and particular Data Sources. We will be using standard J2EE ways to access the database, this means: creating a DataSource for the Database, so we are able to access it from JSP, Servlets and Enterprise Java Beans (EJBs) doing a simple JNDI lookup - so, no DriverManager stuff, just plain Application Server configuration and JNDI:

    1. Put the JDBC Driver on the classpath
      Before you can make a connection to database from within the virtual machine in which your WebLogic runs, the JDBC Driver must be on the classpath. You can do this by adding a line before the actual server startup in the startWebLogic.sh (unix) or startWebLogic.cmd (script) script. For Example:

      Unix:
      export CLASSPATH = /path/to/mysql-connector-java-2.0.14-bin.jar:$CLASSPATH
      Windows:
      set CLASSPATH = c:\path\to\mysql-connector-java-2.0.14-bin.jar;%CLASSPATH%

      In WebLogic 7, add this right BEFORE the line containing:
      /path/of/your/bea/installation/server/bin/startWLS.sh

      When you will start the Weblogic server again, the database driver class and all other classes needed will be available to weblogic.

    2. Start the BEA WebLogic server
      You start the server with the startWeblogic.sh (unix) or startWebLogic.cmd (windows) script. After the server has started, move on to step 3. It could be that you are asked for your system password (weblogic 6) or administrator username and password (weblogic 7), if this information is not present in the startup script. In this case, provide this information and the startup will proceed.

    3. Open the Configuration Console
      Go to your Weblogic configuration console. Direct your web browser to the weblogic host, on the port you installed it. (by default this is 7001). eg: http://localhost:7001/console. Use the parameters that you need (other host, other port, ...).
      You will be prompted to give your administration password to enter the console.

    4. Configure a ConnectionPool
      When you're in the configuration panel, go to 'Services > JDBC > Connection Pools.' Choose 'Configure a new JDBC Connection Pool' Now you are presented a blank form where you have to put in all needed data. Use these values:

      • Name: MyConnectionPool (unique name of the pool - you can use what you want)
      • URL: jdbc:mysql://mysqlhost/database (where mysqlhost is the host on which MySQL is running, database is the name of the database) eg: jdbc:mysql://localhost/testdb
      • Driver ClassName: com.mysql.jdbc.Driver
      • Properties: user=youraccount (use the name of your account on database eg: root)
      • Password: ... (type in your database account password)
      Set up properties URL, Driver ClassName, Properties and Password - using values specified by application you want to run. For running OpenSubsystems application you have to get property values from osstestXXX.properties (where XXX is the name of particular database - e.g. if XXX = mysql => property file = osstestmysql.properties ).
      Property files are located within the test_module.jar file (e.g. security.jar). This jar file is located in the root of EAR package or in WEB-INF/lib of the WAR package. If you want to define and use your own property values, change also all values defined within the osstestXXX.properties files. It means properties must be the same for WebLogic connection pool properties definition and osstestXXX.properties files.
      Leave all other fields as they are. Now, click 'Apply' and your Connection Pool is created.
      Click on the 'Targets' tab, select your weblogic server, click the right arrow to add it and click apply to deploy the pool to your server.
      If there are any errors reported, consult the console window from which you started the weblogic server for details in the stacktrace. If something goes wrong at this point, the most likely reason is a type in the classpath, resulting in a ClassNotFoundException.

    5. Configure a DataSource
      Now we've configured a connection pool with JDBC connections to the database, we're going to create a DataSource that we'll use from our J2EE components.
      In the console panel, go to 'Services > JDBC > DataSources'. Choose 'Configure a new JDBC DataSource' Use these properties in the form:

      • Name: MyDataSourceName (Unique name to identify your datasource, you can use name as you want)
      • JNDI Name: OSSDS (You'll use this name to look up the datasource in JNDI from code)
      • Pool Name: MyConnectionPool (Use the unique name you gave to your connection pool in step 4)
      IMPORTANT: JNDI Name property must be set to OSSDS . This is because we are allways looking for JNDI datasource with the OSSDS name. This is described at J2EE connection pools support
      Click apply, choose the 'Targets' tab and deploy the DataSource to your server just as you did with the connection pool. Restart your server and now you're ready to test the datasource.

  5. Deployment and installation process for WebLogic 8.1

    There is possible deployment and installation of Enterprise Beans, Web and J2EE applications. Deployment is privided by web Administration Console available at:
    https://servername:7002/console/login/LoginForm.jsp or http://servername:7001/console/login/LoginForm.jsp
    where servername is name of the machine the WebLogic server is installed on.

    1. For deployment there is necessary to create deployment descriptor named as weblogic-ejb-jar.xml. This can be automatically generated by XDoclet. We should modify build-generic.xml file by adding particular tag into the part for <ejbdoclet> tag. It is described in the section 'd.' of the part 3. EJB implementation

      For example:
         <weblogic version="8.1" validateXML="false" createtables="Disabled/>   ... used for version 8.1
                                   

      Generated deployment descriptor weblogic-ejb-jar.xml must be placed within the same directory META-INF as other particular deployment descriptors (ejb-jar.xml, jonas-ejb-jar.xml, jboss.xml). After generating this file Ant will copy it to the specified directory:

      For example:
      <!-- Add weblogic.xml file into the META-INF directory 
              of the generated ${projectname}-ejb.jar file -->
      <jar destfile="${generated_home}/${projectname}/${build_home}/${projectname}-ejb.jar" 
              update="true">
         <fileset dir="${generated_home}/${projectname}/${build_home}/ejb-compiled">
            <include name="META-INF/jboss.xml"/>
            <include name="META-INF/weblogic-ejb-jar.xml"/>
         </fileset>  
      </jar>
                                   
    2. Before deploying a J2EE application in the WebLogic application server, first package its components in an ear file the same way as explained in the particular JOnAS part EAR packaging guide.
      Ear packaging is possible to process by Ant task and this is also included within the our build-generic.xml file - also described in the JOnAS Deployment and installation process. IMPORTANT: Before using ant build script make sure if there is set up property weblogic.version=8.1 within the build.properties file.
      Next, run the WebLogic application Server (described in the part Starting server above) and start web administration console at: https://servername:7002/console/login/LoginForm.jsp
      Log in to the console, default username/password is: weblogic/weblogic.
      Select Deployments->Applications from the left menu or click to Application link on the main window. Then click to Deploy a new Application... and then upload your file(s). Choose particular file and click to upload button. This file will be uploaded into the directory: $BEA_ROOT/weblogic81/samples/domains/workshop/cgServer/upload. After that select uploaded file and click to Continue button. Then enter a name to be used to identify this application and click to Deploy button. After page reloading you should wait untill doploy status will have value 'true' (wait for about 2 next page refreshes).

    3. Before deploying a web application in the JBoss application server, first package its components in a war file the same way as explained in the particular JOnAS part WAR packaging guide.
      War packaging is possible to process by Ant task and this is also included within the our build-generic.xml file and it is provided the same way as described in JOnAS Deployment and installation process.
      Next, run the WebLogic application Server (described in the part Starting server above) and start web administration console at: https://servername:7002/console/login/LoginForm.jsp
      Log in to the console, default username/password is: weblogic/weblogic.
      Select Deployments->Applications from the left menu or click to Application link on the main window. Then click to Deploy a new Application... and then upload your file(s). Choose particular file and click to upload button. This file will be uploaded into the directory: $BEA_ROOT/weblogic81/samples/domains/workshop/cgServer/upload. After that select uploaded file and click to Continue button. Then enter a name to be used to identify this application and click to Deploy button. After page reloading you should wait untill doploy status will have value 'true' (wait for about 2 next page refreshes).

  6. Deployment and installation process for WebLogic 7.0

    There is possible deployment and installation of Enterprise Beans, Web and J2EE applications. Deployment is privided by web Administration Console available at:
    https://servername:7002/console/login/LoginForm.jsp or http://servername:7001/console/login/LoginForm.jsp
    where servername is name of the machine the WebLogic server is installed on.

    1. For deployment there is necessary to create deployment descriptor named as weblogic-ejb-jar.xml. This can be automatically generated by XDoclet. We should modify build-generic.xml file by adding particular tag into the part for <ejbdoclet> tag. It is described in the section 'd.' of the part 3. EJB implementation

      For example:
         <weblogic version="7.0" validateXML="false"/>   ... used for version 7.0
                                   
      Note: There is working also <weblogic .../> tag used for version 8.1

      Generated deployment descriptor weblogic-ejb-jar.xml must be placed within the same directory META-INF as other particular deployment descriptors (ejb-jar.xml, jonas-ejb-jar.xml, jboss.xml). After generating this file Ant will copy it to the specified directory:

      For example:
      <!-- Add weblogic.xml file into the META-INF directory 
              of the generated ${projectname}-ejb.jar file -->
      <jar destfile="${generated_home}/${projectname}/${build_home}/${projectname}-ejb.jar" 
              update="true">
         <fileset dir="${generated_home}/${projectname}/${build_home}/ejb-compiled">
            <include name="META-INF/jboss.xml"/>
            <include name="META-INF/weblogic-ejb-jar.xml"/>
         </fileset>  
      </jar>
                                   
    2. Before deploying a J2EE application in the WebLogic application server, first package its components in an ear file the same way as explained in the particular JOnAS part EAR packaging guide.
      Ear packaging is possible to process by Ant task and this is also included within the our build-generic.xml file - also described in JOnAS Deployment and installation process. IMPORTANT: Before using ant build script make sure if there is set up property weblogic.version=7.0 within the build.properties file. Also you have to comment property precompile_webui=perform in the build.properties file.
      Next, run the WebLogic application Server (described in the part Starting server above) and start web administration console at: https://servername:7002/console/login/LoginForm.jsp
      Log in to the console, using username/password specified by Domain Configuration Wizzard.
      Select Deployments->Applications from the left menu or click to Application link on the main window. Then click to Configure a new Application... and then upload application using link upload it through your browser. Choose particular file and click to upload button. Then select uploaded file and then press Configure and Deploy to configure and deploy the application. After page reloading you should wait untill doploy status will have value 'true' (wait for about 2 next page refreshes).

    3. Before deploying a J2EE application in the WebLogic application server, first package its components in an ear file the same way as explained in the particular JOnAS part WAR packaging guide.
      War packaging is possible to process by Ant task and this is also included within the our build-generic.xml file - also described in JOnAS Deployment and installation process.
      Next, run the WebLogic application Server (described in the part Starting server above) and start web administration console at: https://servername:7002/console/login/LoginForm.jsp
      Log in to the console, using username/password specified by Domain Configuration Wizzard.
      Select Deployments->Applications from the left menu or click to Application link on the main window. Then click to Configure a new Application... and then upload application using link upload it through your browser. Choose particular file and click to upload button. Then select uploaded file and then press Configure and Deploy to configure and deploy the application. After page reloading you should wait untill doploy status will have value 'true' (wait for about 2 next page refreshes).


  7. Server configuration for running JUnitEE tests

    JUnitEE tests is possible to run from web browser at the location: http://servername:7001/test_module/TestServlet, where test_module is particular web module root defined when WAR application has been installed (described above):
    For example: for security.war there will be used location: http://servername:7001/security/TestServlet

  8. Debugging tests running under WebLogic application server

    WebLogic Server is default run in debug mode. You can read more information about startWebLogic Command. Java options allowing debugging application are configured in $BEA_HOME/user_projects/workshopDomain/{startWebLogic.cmd | startWebLogic.sh} file. For example following options can be defined here:
    JAVA_OPTS="-classic -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8453,server=y,suspend=n $JAVA_OPTS"
    For more information about particular options read the Java application launcher documentation.
    You can use Eclipse IDE to debug application running under WebLogic that was started in the debug mode. Follow Debugging Remote Application for instructions.

You can read BEA WebLogic 8.1 documentation or BEA WebLogic 7.0 documentation for more details.

7. IBM WebSphere installation, configure and application deploying

  1. Server installation

    Download the binary version of the free IBM WebSphere v 6 application server from the location http://www-106.ibm.com/developerworks/websphere/downloads/
    Run downloaded installation file and choose Complete Installation type and follow instruction.
    For more information read documentation

  2. Configuration and starting server

    There is not neccessary to change default server configuration for its running.
    When you install WebSphere Platform on a Windows system, the installation program automatically creates shortcut files on the Start Menu.
    The IBM WebSphere 6 Application Server is possible to start from Windows Start Menu:
    IBM WebSphere -> Application Server v6 -> Profiles -> default -> Start the server
    The IBM WebSphere 6 Application Server is possible to stop from Windows Start Menu:
    IBM WebSphere -> Application Server v6 -> Profiles -> default -> Stop the server

  3. Configure a DataSource

    If you want to run application against specified database there is necessary to configure particular datasources. For accessing to the various DB systems we have to configure Connection Pools and particular Data Sources. We will be using standard J2EE ways to access the database, this means: creating a DataSource for the Database, so we are able to access it from JSP, Servlets and Enterprise Java Beans (EJBs) doing a simple JNDI lookup - so, no DriverManager stuff, just plain Application Server configuration and JNDI:

    1. Put the JDBC Driver on the classpath
      Before you can make a connection to database from within the virtual machine in which your WebSphere runs, the JDBC Driver must be on the classpath. You can do this by copying particular JDBC driver into the directory $WEBSPHERE_ROOT/lib directory.

    2. Configure JDBC provider
      Select Resources -> JDBC Providers from left side menu. Click New button.

      • Step 1: Select the database type
      • Step 2: Select the provider type
      • Step 3: Select the implementation type
      Click Next button.
      Configure JDBC provider under section General Properties by setting properties:
      Name - name of the resource provider
      Class path - list of paths of JAR file names. If you specify classpath for JDBC driver, you have to also locate driver on this classpath.
      For example:
      ${UNIVERSAL_JDBC_DRIVER_PATH}/mysql.jar - variable ${UNIVERSAL_JDBC_DRIVER_PATH} is specified in the part Environment -> WebSphere Variables
      Implementation class name - java class name of the JDBC driver implementation
      For example:
      - for SapDB: com.sap.dbtech.jdbcext.ConnectionPoolDataSourceSapDB
      - for MySQL: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
      Click Apply button.

    3. Configure Data sources
      Select Resources -> JDBC Providers from left side menu. Click particular provider the data source will be configured for. Click link Data sources under the section Additional Properties. Click New button.
      Configure Data sources under section General Properties by setting properties:
      Name - set whatever you want
      JNDI Name - must be defined jdbc/OSSDS
      Data store helper class name - set Generic data store helper
      Use this Data Source in container managed persistence (CMP) - uncheck this checkbox
      Click OK button.

      Then you should configure also Custom properties. These is possible configure by clicking on link Custom properties in the part Additional Properties.
      You have to add/configure properties that are depended on Implementation class name defined in particular JDBC Provider part.
      For example configuration for MySQL can be following:

      • Add property user = <username> as following:
        Click New button for adding custom property. Into Name field write user, Into Value field write your specified <username>. Select java.lang.String for Type field. Click OK button.

      • Add property password = <password> as following:
        Click New button for adding custom property. Into Name field write password, Into Value field write your specified <password>. Select java.lang.String for Type field. Click OK button.

      • Add property serverName = localhost as following:
        Click New button for adding custom property. Into Name field write serverName, Into Value field write your specified localhost. Select java.lang.String for Type field. Click OK button.

      • Add property portNumber = 3306 as following:
        Click New button for adding custom property. Into Name field write portNumber, Into Value field write your specified 3306. Select java.lang.String for Type field. Click OK button.

      • Add property databaseName = OSS as following:
        Click New button for adding custom property. Into Name field write databaseName, Into Value field write your specified OSS. Select java.lang.String for Type field. Click OK button.

      Finally save all changes by clicking on link Save. After Data Source configuration you can test connection by selecting checkbox for particular data source and then click Test connection button.

  4. Deployment and installation process

    There is possible deployment and installation of Enterprise Beans, Web and J2EE applications. Deployment is provided by web Administration Console available at:
    https://servername:9043/ibm/console or http://servername:9080/ibm/console
    where servername is name of the machine the WebSphere server is installed on.

    1. For deployment there is necessary to create deployment descriptors named as ibm-ejb-jar-ext.xmi and ibm-ejb-jar-bnd.xmi. This can be automatically generated by XDoclet. We should modify build-generic.xml file by adding particular tag into the part for <ejbdoclet> tag. It is described in the section 'd.' of the part 3. EJB implementation

      For example:
         <websphere/>
                                   

      Generated deployment descriptors ibm-ejb-jar-ext.xmi and ibm-ejb-jar-bnd.xmi must be placed within the same directory META-INF as other particular deployment descriptors (ejb-jar.xml, jonas-ejb-jar.xml, jboss.xml). After generating this file Ant will copy it to the specified directory:

      For example:
      <!-- Add websphere files into the META-INF directory 
              of the generated ${projectname}-ejb.jar file -->
      <jar destfile="${generated_home}/${projectname}/${build_home}/${projectname}-ejb.jar" 
              update="true">
         <fileset dir="${generated_home}/${projectname}/${build_home}/ejb-compiled">
            <include name="META-INF/ibm-ejb-jar-ext.xmi"/>
            <include name="META-INF/ibm-ejb-jar-bnd.xmi"/>
         </fileset>  
      </jar>
                                   
    2. Whole process described above (generating interposition classes and updating the ejb-jar file, ear and war packaging) is provided by our build-generic.xml file. You can just run build-security.xml - update target and there will be generated all necessary stuff. Using and location of ant build script is the same as described in JOnAS Deployment and installation process.
      IMPORTANT: Before using ant build script make sure if there is commented property precompile_webui=perform in the build.properties fie. Also there is problematic for WebSphere App Server 6 to use handlers = java.util.logging.ConsoleHandler in the osslog.properties. It means there has to be used only handlers= java.util.logging.FileHandler.

      J2EE, WAR and EAR application deployment is possible provide from web administration console. Log in to the console writing User ID (user existing within the Windows OS).
      For deploying EAR package first click Applications->Install New Application from left side menu.

      1. Section Preparing for the application installation will be shown in the main page. Browse for ear application (eg. security.ear) that has to be deployed. Then enter Context root (eg: security) to the particular field. And click Next button. On the following page you don't make changes just click Next button.

      2. Section Install New Application will be shown in the main page.

        • Step 1: Don't make changes just click Next button.

        • Step 2: Select all listed checkboxes to map modules to server and click Next button.

        • Step 3: Don't make changes just click Next button.

        • Step 4: Enter JNDI name for each listed EJB. The JNDI name shold be the same as specified for EJB column. Click Next button.

        • Step 5: Enter JNDI name for each listed EJB. The JNDI name shold be the same as specified for EJB column. Click Next button.

        • Step 6: Select checkbox to map virtual hosts for Web modules and click Next button.

        • Step 7: Select checkbox to ensure all unprotected 2.x methods have the correct level of protection and click Next button.

        • Step 8: In the last step just click Finish button.

      3. After successfull deploying and installation click Save to Master Configuration link and then Save button.
        At this point ear application has to be installed and started. Check it selecting Applications->Install New Application from left side menu. You will see all installed enterprise applications. Green arrow in the Status column represents started application and red arrow not started. If enterprise application is not started, select particular checkbox for application you want to start an click Start button.

      4. If you want uninstall installed ear application, select Applications-> Enterprise Applications from left side menu. You will see all installed enterprise applications. Select particular checkbox for application you want to uninstall an click Uninstall button.

      For deploying WAR package first click Applications->Install New Application from left side menu.
      1. Section Preparing for the application installation will be shown in the main page. Browse for war application (eg. security.war) that has to be deployed. Enter Context root (eg: security). Click Next button. On the following page you can do no changes just click Next button.

      2. Section Install New Application will be shown in the main page.

        • Step 1: Don't make changes just click Next button.

        • Step 2: Select listed checkboxes to map modules to server and click Next button.

        • Step 3: Select checkbox to map virtual hosts for Web modules and click Next button.

        • Step 4: In the last step just click Finish button.

      3. After successfull deploying and installation click Save to Master Configuration link and then Save button.
        At this point war application has to be installed. Check it selecting Applications->Install New Application from left side menu. You will see all installed enterprise applications. Green arrow in the Status column represents started application and red arrow not started. If enterprise application is not started, select particular checkbox for application you want to start an click Start button.

      4. If you want uninstall installed war application, select Applications-> Enterprise Applications from left side menu. You will see all installed enterprise applications. Select particular checkbox for application you want to uninstall an click Uninstall button.


      For more information read IBM Websphere Information Center

  5. Server configuration for running JUnitEE tests

    JUnitEE tests is possible to run from web browser at the location: http://servername:9080/test_module/TestServlet, where test_module is particular Context root defined when WAR application has been installed (described above):
    For example: for security.ear there will be used location: http://servername:9080/security/TestServlet

  6. Server logs

    WebSphere Application Server 6 stores all its activity to the log files. These logs are located within the directory $WEBSPHERE_ROOT/profiles/<profile_name>/logs/<server_name> or $WEBSPHERE_ROOT/profiles/<profile_name>/logs/ffdc where <profile_name> is the name of profile (default profile name is called 'default') and <server_name> is name of the server (default server name is called 'server1').
    During normal processing, the SystemOut.log will not have any further information unless a significant error has occurred. If tasks are not executing as they should, this log, as well as the SystemErr.log activity.log and FFDC logs, should be consulted to determine the cause of the failure.

  7. Debugging tests running under WebSphere Application Server

    For enabling debugging mode within WebSphere Application Server you have to set up properties in the administration console: Servers -> Application servers -> <servername> -> Debugging Service.

    • Check checkbox for 'Enable service at server startup'
    • Set up 'JVM debug port', e.g. 8787
    • Set up 'JVM debug arguments', e.g. -Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
    For more information about particular debug arguments read the Java application launcher documentation.
    You can use Eclipse IDE to debug application running under WebSphere Application Server that was started in the debug mode. Follow Debugging Remote Application for instructions.