Portlet Unit Testing with Liferay 6

>> Tuesday, June 8, 2010

My Test Obsession
I must admit, I am a bit obsessed with automated tests. Whenever I approach the development of a new project with a new system, one of my main concerns is how can we implement and run unit tests? So when I tackled the development of a Liferay portlet I assumed that a unit testing framework or practice was a given, Surely someone (if not the Liferay folks) had mastered and documented this aspect of portlet development. Well, Googling and searching for this revealed that no one seemed to have documented a simple and elegant solution to this need. It is easy to test the base Liferay portlets that can be found in the Liferay SDK and source. However, running Unit tests for a portlet in a separate Eclipse project poses a few challenges as mentioned in the following Liferay forum article: http://www.liferay.com/community/forums/-/message_boards/message/3827878.

The solution proposed in that article did not satisfy me and appeared too complex. There had to be a better and simpler way. After some tinkering and reverse engineering using the Eclipse debugger and changing the log4j settings, I can now run a suite of unit tests for my Liferay service including persistence. The following describes how to achieve this and the general approach. You will probably need to adapt the example to your own situation/portlet but the general approach should be applicable. I am still somewhat green when it comes to Liferay and my understanding of the inner workings of the solution is far from complete so there may be better ways of doing this. Please let me know if you find something missing or incorrect so I can improve this documentation.

The main difficulty with portlet unit testing, from what I observed, is due to the fact that portlets are meant to run inside (or alongside) a portal which provides a number of resources and contexts that are not de facto present when running unit tests. Fortunately, Liferay is based on Spring and the Liferay folks did a good job of making it easy for us to extend or override the context in which code is executed.

In the following example, we have a relatively simple portlet in which Java code was essentially generated with the "build-service" Ant script based on a WEB-INF/service.xml file. What we basically need to do to run the unit tests is create a new source folder for the project that will contain the test resources. This folder contains resources such as Java classes, property and Spring context files that are used exclusively for unit testing and must not be included in the WAR bundle to be deployed in the portal container.

My JUnit test class extends com.liferay.portal.service.persistence.BasePersistenceTestCase and implements the following methods:

public abstract void testCreate() throws Exception;
public abstract void testRemove() throws Exception;
public abstract void testUpdateNew() throws Exception;
public abstract void testUpdateExisting() throws Exception;
public abstract void testFindByPrimaryKeyExisting() throws Exception;
public abstract void testFindByPrimaryKeyMissing() throws Exception;
public abstract void testFetchByPrimaryKeyExisting() throws Exception;
public abstract void testFetchByPrimaryKeyMissing() throws Exception;
public abstract void testDynamicQueryByPrimaryKeyExisting()
      throws Exception;
public abstract void testDynamicQueryByPrimaryKeyMissing() throws Exception;

I am a lazy type so I simply copied an existing subclass of BasePersistenceTestCase and changed the implementation so it refers to my own services.

In the root of the source test folder, put a file called portal-test.properties containing the following (substitute $TOKEN$ to reflect your context):

jdbc.default.driverClassName=$DRIVER_CLASS_NAME$
jdbc.default.url=$DB_URL$
jdbc.default.username=$USER_NAME$
jdbc.default.password=$USER_PASSWORD$

# Disable the scheduler for Unit testing
ehcache.portal.cache.manager.jmx.enabled=false

value.object.listener.com.liferay.portal.model.LayoutSet=

resource.repositories.root=$RESOURCE_REPOSITORIES_ROOT$

# Disable the scheduler for Unit testing
scheduler.enabled=false

hibernate.configs=\
META-INF/mail-hbm.xml,\
META-INF/portal-hbm.xml,\
META-INF/ext-hbm.xml,\
META-INF/portlet-hbm.xml

One of the basic principles in Liferay is that you can override base properties and Spring configs with your own. In the above file, we define properties that override the base ones that come from the portal project.

In the same fashion, I created a "ext-spring.xml" file in the META_INF subfolder of the source test folder that overrides the bean definitions found in the portlet or portal spring contexts. As an example, the content of the "ext-spring.xml" file I use is the following (substitute type names to reflect your service/portlet):

<beans default-destroy-method="destroy" default-init-method="afterPropertiesSet"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
 xsi:schemalocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

 <bean
  class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
  id="liferayDataSource">
  <property name="targetDataSource">
   <bean class="com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean">
    <property name="propertyPrefix" value="jdbc.default.">
    </property>
   </bean>
  </property>
 </bean>

 <bean class="com.opnworks.portlet.iamhere.service.impl.MyLocalServiceImpl"
  id="com.opnworks.portlet.service.MyLocalService">
  <bean class="com.opnworks.portlet.service.MyLocalServiceUtil" id="com.opnworks.portlet.service.MyLocalServiceUtil">
   <property name="service"
    ref="com.opnworks.portlet.service.GeoCampaignLocalService">
   </property>
  </bean>
  <bean
   class="com.opnworks.portlet.iamhere.service.persistence.MyEntityPersistenceImpl"
   id="com.opnworks.portlet.service.persistence.MyEntityPersistence"
   parent="basePersistence">

   <bean
    class="com.liferay.portal.spring.transaction.TransactionManagerFactory"
    factory-method="createTransactionManager" id="liferayTransactionManager">
    <constructor-arg ref="liferayDataSource">
     <constructor-arg ref="liferayHibernateSessionFactory">
     </constructor-arg>
    </constructor-arg>
   </bean>
   <bean
    class="com.opnworks.portlet.iamhere.service.persistence.PortletHibernateTestConfiguration"
    id="liferayHibernateSessionFactory">
    <property name="dataSource" ref="liferayDataSource">
    </property>
   </bean>
   <bean class="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil"
    id="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil">
    <property name="dynamicQueryFactory">
     <bean
      class="com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl">
     </bean>
    </property>
   </bean>
   <bean class="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil"
    id="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil">
    <property name="restrictionsFactory">
     <bean
      class="com.liferay.portal.dao.orm.hibernate.RestrictionsFactoryImpl">
     </bean>
    </property>
   </bean>
   <bean class="com.liferay.portal.kernel.util.InfrastructureUtil"
    id="com.liferay.portal.kernel.util.InfrastructureUtil">
    <property name="dataSource" ref="liferayDataSource">
     <property name="transactionManager" ref="liferayTransactionManager">
     </property>
    </property>
   </bean>
  </bean>
 </bean>
</beans> 
                                                     

In the above file, the main trick that I pulled is to redefine the bean called liferayHibernateSessionFactory and to specify the following class implementation:

package com.opnworks.portlet.iamhere.service.persistence;

import com.liferay.portal.spring.hibernate.PortletHibernateConfiguration;

public class PortletHibernateTestConfiguration extends
  PortletHibernateConfiguration {
 protected ClassLoader getConfigurationClassLoader() {
  return this.getClass().getClassLoader();
 }
}

This was needed because the PortletHibernateConfiguration implementation throws a NPE on the getConfigurationClassLoader() method invocation due to the fact that we are not running inside a container. I also put the above class definition in my test source folder. If anybody can suggest a more elegant solution, I would be delighted to hear about it.

Another useful trick is to put a copy of portal-log4j.xml in the META-INF subfolder of your test source folder. That way, you can change the logging strategy used for unit testing.

If using Eclipse, you can simply run your unit test classes or suite as a JUnit configuration.

Have fun in the Liferay lane...

Read more...

Developing in the Liferay Lane

>> Monday, February 22, 2010

I have been studying the Liferay portal  system in the past few weeks and I must admit I am quite impressed with this JSR-168 implementation. I will have the chance to discuss this solution some other time but for now, I want to share some tips and tricks to setup an environment to develop Liferay "plugins".

In fact, setting up a development environment to work with Liferay can be quite challenging and time consuming. It is very easy to mess up and things can go wrong in many areas. Furthermore, the instructions are not always clear or complete and there a few tricks one can pull when working with Eclipse and Tomcat that will make things  more fluid. After a lot of suffering and trial and error, here is a recipe to setup a development environment with  Eclipse 3.5.x, MySQL, Liferay 5.2.3 and Apache Tomcat 6.0.x. I just hope I did not forget anything since after the fact, we sometimes miss out or omit a step. Let me know if corrections are needed. My system is running Ubuntu 9.1 but the recipe should be easy to adapt to a Windows box. So here we go.

  • Install (if needed) MySQL (I use MySQL 5.1.37).
  • Create a new MySQL database called "lportal" and test the connection parameters.
  • Install Eclipse 3.5 (Galileo) JEE Edition. You will need JEE edition for some of the tricks below.
  • Download and install Apache Tomcat 6.x somewhere and make sure it is setup properly and working (probably best to have a dedicated Tomcat installation).
  • Create a Tomcat server profile in Eclipse (JEE perspective/Servers view/Add server).
  • Download liferay-portal-src-5.2.3.zip and unzip it in the folder of your choice ( you will end up with a liferay-portal-src-5.2.3 subfolder)
  • Import the contents of liferay-portal-src-5.2.3 as an Eclipse project (it already has the ".project "and ".classpath" files). A "portal" project should appear in your list of Eclipse project.
  • Create a "release.[USERNAME].properties" file in the root of the portal project where [USERNAME] is your Windows or Linux user name.
  • Add the following lines to the release.[USERNAME].properties file. Replace [ECLIPSE_PROJECTS_ROOT] and [ECLIPSE_WORKSPACE_ROOT] with the full paths for your setup The first folder is where you want to put the Liferay "ext" Eclipse project content.

    lp.ext.dir=[ECLIPSE_PROJECTS_ROOT]/liferay-ext
    lp.eclipse.dir=[ECLIPSE_WORKSPACE_ROOT]
    lp.eclipse.project.name=ext
  • Open an ANT view in Eclipse and drag the portal/build.xml file onto the view.
  • Launch (doubleclick) the "clean" task in the ANT view (should be optional the first time).
  • Launch the ANT "start" task followed by the ANT "build-ext" task.
  • Import the "ext" project into Eclipse (use "Import existing project" wizard). You should find it in [ECLIPSE_PROJECTS_ROOT]/liferay-ex.
  • In Eclipse, create a new file:  /ext/ext-impl/src/portal-ext.properties
  • Add the following lines to this file and make sure you set the proper paths and values for all the properties.
auto.deploy.dest.dir=${auto.deploy.tomcat.dest.dir}
auto.deploy.tomcat.conf.dir=[TOMCAT_HOME]/conf/Catalina/localhost

#
# MySQL
#
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=

#
# Mail
#
mail.session.mail.pop3.host=opnworks.com
mail.session.mail.pop3.password=
mail.session.mail.pop3.port=110
mail.session.mail.pop3.user=lgauthier
mail.session.mail.smtp.auth=false
mail.session.mail.smtp.host=relais.videotron.ca
#mail.session.mail.smtp.password=
mail.session.mail.smtp.port=25

resource.repositories.root=[HOME]/liferay
  • Add the following file to the Eclipse "ext" project root: app.server.[username].properties. Make sure all the properties have the proper values.
app.server.type=tomcat

app.server.tomcat.version=6.0
app.server.tomcat.dir=[TOMCAT_HOME]
app.server.tomcat.bin.dir=${app.server.tomcat.dir}/bin
app.server.tomcat.classes.global.dir=${app.server.tomcat.dir}/lib
app.server.tomcat.classes.portal.dir=${app.server.tomcat.portal.dir}/WEB-INF/classes
app.server.tomcat.deploy.dir=${app.server.tomcat.dir}/webapps
app.server.tomcat.lib.endorsed.dir=${app.server.tomcat.dir}/lib/ext
app.server.tomcat.lib.global.dir=${app.server.tomcat.dir}/lib/ext
app.server.tomcat.lib.portal.dir=${app.server.tomcat.portal.dir}/WEB-INF/lib
app.server.tomcat.lib.support.dir=${app.server.tomcat.dir}/lib/ext
app.server.tomcat.portal.context=ROOT
app.server.tomcat.portal.dir=${app.server.tomcat.deploy.dir}/${app.server.tomcat.portal.context}
app.server.tomcat.log.dir=${app.server.tomcat.dir}/logs
app.server.tomcat.temp.dir=${app.server.tomcat.dir}/temp
app.server.tomcat.work.dir=${app.server.tomcat.dir}/work
app.server.tomcat.zip.name=liferay-portal-tomcat-6.0-${downloads.version}.zip
app.server.tomcat.zip.url=${sourceforge.mirror}/${app.server.tomcat.zip.name}
  • In Eclipse, add the ext/build.xml file to your ANT view and launch the "deploy" task.
  • In Eclipse, configure a Tomcat server that refers to the Tomcat that you are using for Liferay and make sure it is configured to "Use Tomcat Installation". Also, change the timeouts to give enough time for Liferay to start (I specified 120 secs).
  • Start Tomcat from Eclipse. You should be getting a trace of Liferay starting up and if you look at your MySQL database, you should see the tables appear.
  • If everything goes well, the Liferay home page will automagically appear in your browser.
Creating and deploying a plugin

Now the interesting part for your portlet or theme development.
  • Download and install the Liferay portlet SDK (liferay-plugins-sdk-5.2.3.zip)
  • Follow instruction to create a new portlet or theme.
  • For a theme, lets assume we created a new theme called "jazz-theme". Create a new static web project in Eclipse, name it "jazz-theme" and set the project contents to the [liferay_sdk]/themes/jazz-theme folder created with the SDK.
  • Add a file called "jazz-theme.xml" to root of the "mirasol-theme" Eclipse project and set its content as follows (replace [liferay_sdk] with the full path of the sdk):
[context
antijarlocking="true">
antiResourceLocking="true"
path="jazz-theme"
docBase="[liferay_sdk]/themes/jazz-theme/docroot"
/]
  • Add the following task to the "build.xml" ANT file for the jazz-theme project ([resource.repositories.root]/deploy" is the folder used by liferay for hot deployment) :
[target name="redeploy"]
[copy file="[liferay_sdk]/themes/mirasol-theme/mirasol-theme.xml"
todir="[resource.repositories.root]/deploy"/]
  • Using the ANT view, launch the "redeploy" task for the mirasol-theme project. You should see somehting like this in the Tomcat console:
19:40:40,987 INFO [ThemeHotDeployListener:90] Registering themes for mirasol-theme
19:40:41,020 INFO [ThemeHotDeployListener:114] 1 theme for mirasol-theme is available for use
  • From the Liferay web page, you should be able to access the new theme and is you change an image, CSS or other resource, simply launch the "redeploy" task and liferay will pickup the changes without having to copy all the files since the "docbase" attribute points to the Eclipse project folder.
  • The same idea applies to portlet projects.

Have fun and let me know if this works (or does not work) for you.

Notes
A good part of this "How-to" is based on information from this blog.

Read more...

What is a Methodology?

>> Saturday, December 12, 2009

Since the beginning of my IT career some 25 years ago, I have entertained a sound reserve towards software development methodologies. I have always found it ironic that in our industry we label "methodology" a checklist of documents and a set of document templates that must be produced or filled in at different stages of a project. Such "methodologies" are very good at specifying what "deliverable" must be produced and when they should be deposited but usually very silent on how exactly do we produce the ultimate deliverable, i.e. the software system itself. It is true, that traditional methodologies also describe a series of software development phases and how should be doing what at each phase. But again, how exactly do we work within each phase was/is often left to the imagination.

For this reason, I was always more attracted by the literature that describes and discusses how to effectively and efficiently design software and how to write and manage code and systems. Strangely, this literature tended to shy away from the term methodology and preferred to use expressions such as "software engineering".

It was therefore refreshing for me when the Agile movement came into light. For once, I was hearing and reading about a "methodology" that corresponds to my own experience and inclinations. One that I could relate to. One that talked about practices, techniques, systems and tools. That puts the emphasize on the delivery of software instead of the delivery of documentation. An approach that prescribes the use of tests, of continuous refactoring, that talks about team organization, work habits, and human interactions. Those were the early days of the Agile movement with a lot of talk about extreme programming and unit testing.

However, methodologists at heart were not to be left on the sidelines. They woke up and smelled the coffee and had the intuition that there might be something for them in this new trend. Since it was difficult to sell the idea of a list of documents for each of the different stages of an agile project (agile is lean and iterative remember?) they instead invented a new religion with priests (scrum masters) and ceremonies (dailys, retros, demos etc). I am not arguing that all this is B.S. but I do see a dubious trend when people consider they are agile because they are holding SCRUM ceremonies. I may be naive, but to me, ceremonies are meant to be (or should be) a means to help teams and organizations increase their agility. If ceremonies become an obstacle to agility, then we should get rid of them and invent something else. 

On the same basis, we now find "agile" tools on the market that help organizations follow the SCRUM way of doing things. Considering yourself agile because you use such a tools is completely fallacious. I personally consider it much more important, for the sake of agility, to use automated testing tools and build systems then to use a SCRUM compliant project management tool.

So long,

Laurent

Read more...

Accumulating Technical Debt: A Costly Proposition

I just the passed couple of weeks doing some very technical work with Maven on a large (above 50K person-day) project. Essentially, our dedicated team of three engineers spent a total of approx 30 days to realign the build configuration and process for this  project. We already had a pretty good idea of what was wrong and how to fix it but what we found amazing is the extent and severity of the problems and anomalies that this project had been dragging for many many months and how little control over the whole build process the teams had. I won't get into the technical details here (maybe in a follow-up article), but imagine a project where daily builds take a few hours, where the result of the build is extremely messy on top of being somewhat unpredictable, where the deployed applications are plagued by failures due to conflicting jar versions and by different compile and runtime dependencies. In addition, the build process, although based on Maven, relied heavily on homegrown Maven plugins to do all sorts of "magic" (albeit unnecessary) tricks. I just described a recipe for problems and problems they had. The comforting news is that it was possible to turn the project around and realign it so we now have a controlled build and release configuration that relies almost exclusively on generic Maven plugins.

The real question is how do projects get into such a predicament and how come they tolerate the negative consequences for such a long time period? In this particular program, external audits were conducted on at least two occasions and each time, strong and concrete recommendations were made and warnings were issued but things continued as is. The direct result of this is that a lot of fuel was wasted on attempting to alleviate and compensate for the negative effects of the fundamentally flawed build and release process and configuration. I like to compare the situation to traveling in a luxury sedan with half deflated tires and a wobbly steering. You are burning too much fuel and rubber and you are a catastrophe in waiting but instead of taking the time to stop and fix (or replace) your slow leaking tires and steering you prefer to just add air from time to time and put up with the steering problems because your are in a hurry to complete your 5000 km journey. I mentioned a luxury sedan because the tool set for this project is top notch: Maven, Nexus, Hudson, Eclipse, Accurev. All the right tools, but most of them not being used properly.

Officially, this particular initiative is using the "Agile Methodology". In reality, it is applying the SCRUM approach to managing teams and projects. In many ways, the project is not compliant with the agile software development principles. Dragging for months and months a technical debt and paying interest at every detour is not, in my book, an agile strategy. In fact, the SCRUM discourse of focusing on client functionality and of managing a backlog of "User Stories" that are prioritized by the product owner and that must fit within the sprint can have  perverse effects that we must be aware of.  Organizations that adopt this approach should put some mechanism in places so that unjustified technical debt does not accumulate and reach crippling proportions.

Many methodologists like to present the so-called "Toyota approach" as a model to follow. I do not consider myself an expert in the subtleties of one method versus another but my understanding of the Toyota way is that if a problem in the assembly line jeopardizes product quality, we stop the assembly line immediately and fix the problem before we pursue. Even if that means that 20 or 30 people might be idle for a few minutes or a few hours. Software development is not an automobile assembly line but when the process is broken, taking the time to fix it always pays off.

Following our intervention and the extensive refactoring of build configurations, the builds are easier to manage, the build process is faster, lighter, transparent, predictable and flexible, they can be performed by different individuals (not just by one "specialist" know-it-all) the deployments are more stable and overall, teams are more productive. I am convinced that refusing to make this change earlier did not allow the project to deliver more functionality. Quite the contrary, it has delayed and slowed down the whole development process, it has poisoned the work atmosphere, it has distracted everybody from their core tasks and has entertained the impression of a semi-controlled chaos which most people and organizations do not appreciate.

So drive carefully and keep your vehicle in good repair,

Until next time,

Laurent

Read more...

WAS 6.1 Profile Creation

>> Monday, November 2, 2009

This article is very technical and describes how to create a Websphere Application Server (WAS) 6.x profile that can be reused on different developer workstations. After searching the net for the recipe and not finding a complete one, we had to devise our own. The following has worked for us but may need adaptation depending on your own needs and situation.

In the following procedure, it is assumed that WAS 6.1. is installed on the workstation. The name WAS_HOME refers to the path where WAS is installed (ex: C:\IBM\WAS6.1\AppServer).

We also assume that the following folders were created:
   C:\
     WAS6.1 
       jdbcDrivers
       logs
       profiles
       sharedLibs

1) Launch the profile management tool from
              [WAS_HOME]\bin\ProfileManagement\pmt.bat

2) In the Profile Management Tool wizard:
  • Select the Advanced profile creationoption
  • Select Deploy the administrative console & Deploy the default application
  • Set the profile name and directory to WASDev[0n] and C:\WAS6.1\profiles\WASDev[0n] where [0n] is the profile number
  • Select Create the server using the development template
  • Unselect Make this profile the default
  • Specify the following Node name: localhostDevNode[0n]
  • Specify the following Host name: localhost
  • DO NOT enable administrative security
  • Specify Default Port Values
  • Uncheck Run the application server process as a Windows service
  • DO NOT Create a web server definition
  • Wait until the Profile Management Tool wizard has completed
  • Do not run the First Steps Console

3) Verify the content of C:\WAS6.1\profiles\WASDev[0n]\logs\AboutThisProfile.txt. It should contain something similar to this:

Application server environment to create: Application server
Location: C:\WAS6.1\profiles\WASDev02
Disk space required: 200 MB
Profile name: WASDev02
Make this profile the default: False
Node name: localhostDevNode02
Host name: localhost
Enable administrative security (recommended): False
Administrative console port: 9060
Administrative console secure port: 9043
HTTP transport port: 9080
HTTPS transport port: 9443
Bootstrap port: 2809
SOAP connector port: 8880
Run application server as a service: False
Create a Web server definition: False

4) Edit the file C:\ibm\was6.1\profiles\profiles\WASDev[0n]\config\cells\[host]Node[0n]Cell\nodes\localhostWASNode\variables.xml and substitute the following:
<entries xmi:id="VariableSubstitutionEntry_9" symbolicName="JAVA_HOME" 
  value="C:/PATH_TO_WAS_INSTALLATION/java" />
With:
<entries xmi:id="VariableSubstitutionEntry_9" symbolicName="JAVA_HOME" 
  value="${WAS_INSTALL_ROOT}/java" />

In the same file, set the value of ORACLE_JDBC_DRIVER_PATH and other JDBC drivers paths if necessary to C:\WAS6.1\jdbcDrivers

5) Add the following files from an existing development profile to the root directory of the new profile:

readme.html
startWAS61.bat
stopWAS61.bat
WAS 6.1 Console

6) Edit the content of the file bin\setupCmdLine.bat to replace absolute references to WAS_HOME with the %WAS_HOME% expression. Alternatively, copy the bin\setupCmdLine.bat files from an existing development profile. As a reference, the bin\setupCmdLine.bat should contain something close to the following:

SET WAS_USER_SCRIPT=C:\WAS6.1\profiles\TDADev02\bin\setupCmdLine.bat
SET USER_INSTALL_ROOT=C:\WAS6.1\profiles\TDADev02
SET JAVA_HOME=%WAS_HOME%\java
SET WAS_CELL=qcdev584Node05Cell
SET WAS_NODE=localhostDevNode02

REM Set the default OSGI -X and -D java ARGS.
SET OSGI_INSTALL=-Dosgi.install.area="%WAS_HOME%"
SET OSGI_CFG=-Dosgi.configuration.area="%USER_INSTALL_ROOT%"\configuration

REM SET ITP_LOC=%WAS_HOME%\deploytool\itp
REM SET CONFIG_ROOT=%WAS_HOME%\config
SET CONFIG_ROOT=%USER_INSTALL_ROOT%\config
SET CLIENTSAS=-Dcom.ibm.CORBA.ConfigURL=file:%USER_INSTALL_ROOT%/properties/sas.client.props
SET CLIENTSOAP=-Dcom.ibm.SOAP.ConfigURL=file:%USER_INSTALL_ROOT%/properties/soap.client.props
SET CLIENTSSL=-Dcom.ibm.SSL.ConfigURL=file:%USER_INSTALL_ROOT%/properties/ssl.client.props
SET JAASSOAP=-Djava.security.auth.login.config=%USER_INSTALL_ROOT%/properties/wsjaas_client.conf
SET WAS_EXT_DIRS=%JAVA_HOME%\lib;%WAS_HOME%\classes;%WAS_HOME%\lib;%WAS_HOME%\installedChannels;%WAS_HOME%\lib\ext;%WAS_HOME%\web\help;%ITP_LOC%\plugins\com.ibm.etools.ejbdeploy\runtime
REM SET WAS_BOOTCLASSPATH=
REM SET CLIENT_CONNECTOR_INSTALL_ROOT=%WAS_HOME%\installedConnectors
SET CLIENT_CONNECTOR_INSTALL_ROOT=%USER_INSTALL_ROOT%\installedConnectors

SET WAS_CLASSPATH=%WAS_HOME%\properties;%WAS_HOME%\lib\startup.jar;%WAS_HOME%\lib\bootstrap.jar;%WAS_HOME%/lib/j2ee.jar;%WAS_HOME%/lib/lmproxy.jar;%WAS_HOME%/lib/urlprotocols.jar;%JAVA_HOME%\lib\tools.jar
SET WAS_PATH=%WAS_HOME%\bin;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%PATH%

SET WAS_LOGGING=-Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager -Djava.util.logging.configureByServer=true

SET QUALIFYNAMES=

7) Replace all occurrences of absolute paths to WAS_HOME appearing in C:\WAS6.1\*.bat files by the following variable %WAS_HOME%. For example, the file startServer.bat should contain the following:

@echo off
SETLOCAL
set WAS_USER_SCRIPT=C:\WAS6.1\profiles\TDADev02\bin\setupCmdLine.bat
call "%WAS_HOME%\bin\startServer.bat" %*
ENDLOCAL & set MYERRORLEVEL=%ERRORLEVEL%
if defined PROFILE_CONFIG_ACTION (exit %MYERRORLEVEL%) else exit /b %MYERRORLEVEL%


Alternatively, copy the bin\*.bat files from an existing development profile.

8) Make sure the profile is functional by going through the following steps:
  • Start the WAS server by launching startWAS61.bat
  • Open the WAS console by launching "WAS 6.1 Console"

9) Copy the required JDBC drivers (jar files) to C:\WAS6.1\jdbcDrivers

10) OPTIONAL: Configure the profile by defining the required resources (Data Sources, Mail Session, Message Queues, JAAS J2C Authentication aliases etc). Alternatively, it is possible to copy a resources.xml file from an existing WAS profile to the following folder:

C:\WAS6.1\profiles\TDADev[0n]\config\cells\[host]Node[0n]Cell\nodes\localhostDevNode[0n]\servers\server1

For Data sources, it is important to perform a "Test connection" on each defined data source.

11) OPTIONAL: Configure (define) shared libraries for apps that point to a subfolder of C:\WAS6.1\sharedLibs (ex: C:\WAS6.1\sharedLibs\mysharedlib)

12) Test your configuration by deploying the desired target applications.

OPTIONAL

13) If the above tests are conclusive, uninstall the applications and delete the files from C:\WAS6.1\profiles\WASDev02\logs

14) Create a ZIP file using the following procedure:
- Make sure the WAS instance is stopped
- Zip the contents of the C:\WAS6.1\profiles\TDADev[0n] folder

Have fun,

Laurent

Read more...

  © Blogger template Webnolia by Ourblogtemplates.com 2009

Back to TOP