jAPS JBoss Deploy

Do It The jAPS Way

Eugenio Santoboni

First and complete version in Italian 
Chief Solution Engineer
AgileTec s.r.l.

Giovanni Cocco

First and complete version, English translation 
Software Engineer
Tzente s.r.l.

Legal Notice

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the Appendix entitled "GNU Free Documentation License".

The copyright holders make no representation about the suitability of this Document for any purpose. It is provided “as is” without expressed or implied warranty. If you modify this Document in any way, identify your resulting Document as a variant of this Document.

2011-03-03

Revision History
Revision 1.22011-03-03MEM

Update for jAPS 2.0 entando, version 2.0.10

Revision 1.12010-03-18MEM

Revision for the release of jAPS 2.0.10

Revision 1.02009-11-30GC

English translation

Abstract

Deploy on JBoss AS for applications based on jAPS.


Chapter 1. Scope of the document

Introduction

Deploy on JBoss AS for applications based on jAPS.

Target

The document is aimed to those developers who need to deploy a jAPS 2.0 entando based application on JBoss AS.

Prerequisites

In order to take the maximum advantage of the present document, it is necessary to have basic knowledge about: the Java platform, the Eclipse IDE, the JBoss Application Server, the PosgreSQL DBMS.

Resources

Additional informations may be obtained through the official mailing-lists:

Is it also possible to refer to the documentation found in the:

jAPS 2.0 entando Project - Developer Website

Chapter 2. Deploy on JBoss AS for an application based on jAPS.

Introduction

The following paragraph is about the deploy on JBoss AS for an application based on jAPS.

Application Server Installation

Download the package of JBoss application server http://www.jboss.org/jbossas/downloads/. This documentation referes to version 5.1.0.GA. Extract archive and move file to installation folder.

Application Server configuration

To obtain a correct configuration for the Application Server you need to set on the trim white spaces functionality to remove line-break in excess in rendered JSP. Open the file <PATH_DI_INST>/jboss-5.1.0.GA/server/default/deployers/jbossweb.deployer/web.xml. Add the following lines:

<init-param>
         <param-name>trimSpaces</param-name>
         <param-value>true</param-value>
      </init-param>
      
		

between initialization parameters for the servlet:

<servlet>
      <servlet-name>jsp</servlet-name>
      <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
      .....
    </servlet>

Or alternatively in the web.xml of the webapp insert in to the block <jsp-config>

<!-- Trim With Space -->
      <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <trim-directive-whitespaces>true</trim-directive-whitespaces>
      </jsp-property-group>

Web App Configuration

JBoss manages in a different way from Tomcat the context file. This file is default used in jAPS for configuration of system parameters. To resolve this problem the configuration parameters are defined in the file web.xml for the deploy on JBoss. Add into the file web.xml of the application the following definitions (after the block for <servlet-mapping>). In the example the Application Server is installed in /opt/jboss-5.1.0.GA/, the application is call PortalExample and is used the configuration default of JBoss. The data directory of the server instance is used for cache files and files from search engine. Customize the parameters if necessary for your environment, tipically for server installation path.

<env-entry>
    <env-entry-name>logName</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>PortalExample</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>logFilePrefix</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/opt/jboss-5.1.0.GA/server/default/log/PortalExample_log</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>logLevel</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>ALL</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>logFileSize</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>200000</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>logFilesCount</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>10</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>configVersion</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>production</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>applicationBaseURL</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>http://localhost:8080/PortalExample/</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>resourceRootURL</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/PortalExample/resources/</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>protectedResourceRootURL</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/PortalExample/protected/</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>resourceDiskRootFolder</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/opt/jboss-5.1.0.GA/server/default/deploy/PortalExample.war/resources/</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>protectedResourceDiskRootFolder</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/opt/jboss-5.1.0.GA/server/default/deploy/PortalExample.war/protected/</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>indexDiskRootFolder</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/opt/jboss-5.1.0.GA/server/default/data/PortalExample/indexdir</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>cacheDiskRootFolder</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/opt/jboss-5.1.0.GA/server/default/data/PortalExample/cache</env-entry-value>
</env-entry>
		

Data Sources definition and installation of the JDBC driver

Define data-source as DataSourceName-ds.xml in <PATH_DI_INST>/jboss-5.1.0.GA/server/default/deploy/jdbc. Create folder jdbc, if not exist (is not strictly necessary is only for order).

Starting from template on <PATH_DI_INST>/jboss-5.1.0.GA/docs/examples/jca/postgres-ds.xml Define two files for datasources as standardly required by jAPS and others eventually needed by the web app.

Example for database port the file is named portDataSource-ds.xml , and it contains:

<datasources>
  <local-tx-datasource>
    <jndi-name>portDataSource</jndi-name>
    <connection-url>jdbc:postgresql://localhost:5432/PortalExamplePort</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>agile</user-name>
    <password>agile</password>
        <!-- sql to call when connection is created. It can be anything, select 1 is valid for PostgreSQL
        <new-connection-sql>select 1</new-connection-sql>
        -->

        <!-- sql to call on an existing pooled connection when it is obtained from pool.  Can be anything, select 1 is valid for PostgreSQL
        <check-valid-connection-sql>select 1</check-valid-connection-sql>
        -->

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>PostgreSQL 7.3</type-mapping>
      </metadata>
  </local-tx-datasource>

</datasources>
		

Fix names for datasources on the WEB-INF/conf/systemConfig.xml whit names used for datasources definitions in the preceding step. For example if the two data source have been defined with the names portDataSource and servDataSource, the lines for the file will be identical to those reported:

<jee:jndi-lookup id="portDataSource" jndi-name="java:portDataSource"/>
	
	<jee:jndi-lookup id="servDataSource" jndi-name="java:servDataSource"/>
	
		

This is because JBoss does not accept the syntax comp/env/jdbc/portDataSource.

Add the Postgres JDBC driver, postgresql-8.3-603.jdbc4.jar, in the folder <PATH_DI_INST>/jboss-5.1.0.GA/server/default/lib if server configuration in use is default.

Deployment

To simply deploy the application use ANT tasks defined on file build.xml of the project jAPS 2.0 entando. Execute the task with name WAR build, the folder <NomeWebApp> will be generated in <NomeProgetto>/build/ rename its to <NomeWebApp>.war for deploy as unpacked webapp in <PATH_DI_INST>/jboss-5.1.0.GA/server/default/deploy

Chapter 3. Dynamic Web Project on JBoss AS

Table of Contents

Introduction

Introduction

The following paragraph is about the use of JBoss AS for the development of an application based on jAPS 2.0 entando whit the dynamic web project functionality of the eclipse IDE.

From the server view define a new server: right click, new, Server, select JBoss, JBoss v5.0 (could be necessary to define a new server runtime), associate eclipse project to server.

JBoss startup time may be greater than startup timeout configured for the server. To manage this situation double click on the server. Select the timeout config and increase the value of the entry start, by default equal to 50.

Follow the instructions from the preciding paragraph for the configuration of the datasources, the JDBC driver, the trim white spaces and the configuration parameters definitions in the file web.xml.

Customize configuration parameters in web.xml file for your environment.

Now it is possible to execute the webapp as an eclipse Dynamic Web Project: right click on project, Run As, Run on Server, select the JBoss server previously defined, click on Finish. The web application will be started and its homepage opened on the browser.

Chapter 4. Tips

Table of Contents

Clean folder work

Clean folder work

In some situations may be necessary clean the folder work (like that of Tomcat) to resume correctly the application. To do it remove the folder <PATH_DI_INST>/jboss-5.1.0.GA/server/default/work/jboss.web