Meet the experts: Roland Barcia on developing J2EE and Web services applications on Rational Application Developer V6

This question and answer article features WebSphere consultant Roland Barcia on developing J2EE and Web services applications on IBM Rational Application Developer V6.

Roland Barcia, Certified IT Specialist, EMC

Photo: Roland BarciaRoland Barcia is a Consulting IT Specialist for IBM Software Services for WebSphere. He is a co-author of IBM WebSphere: Deployment and Advanced Configuration.


developerWorks Master author level
        2

03 August 2005

Introduction

In this article, WebSphere® consultant Roland Barcia answers questions on developing J2EE and Web services applications on IBM® Rational® Application Developer V6 and deploying and testing those applications on WebSphere Application Server V6. Topics include using the various wizards, perspectives, and tools in Rational Application Developer to develop different types of J2EE™ applications, using the new Service Integration Bus Messaging Platform in WebSphere Application Server V6, differences from V5 of WebSphere Studio or WebSphere Application Server, using the default WebSphere Application Server V6 in Rational Application Developer, and deploying to full WebSphere Application Server V6 Network Deployment.

Question: We have the WebSphere 5.0 server only. I started to move our IDE from WebSphere Studio Application Developer 5.1.2 (hereafter called Application Developer) to Rational Application Developer (RAD) V6 to take advantage of some new features in RAD 6. I set the J2EE level to 1.3 and worked out a few issues: the EAR file generated from RAD 6 works fine in WebSphere Application Server 5 (hereafter called Application Server). But, we still have problems in RAD 6. For example, some error messages show up in the JSP fragment files. It seems the JSP compiler or validator in RAD 6 tries to compile those fragment files like a standalone files. I just wonder if it is a right choice to use RAD 6 to develop J2EE application running on a V5 server? Is it possible to make the JSP compiler in RAD 6 work the same way as in Application Developer 5.1.2 since we are targeting the V5 server?

Answer: WebSphere Studio Application Developer V 5.1.2 had the same issue, but the validation was probably off by default. I always tell people that validation should be off by default and executed on demand when needed. This improves the speed of your builds dramatically. You can turn off JSP validation at the Project level by right clicking the project and selecting properties.

Figure 1. JSP validation
JSP validation

Or, you can turn it off at the workspace level by selecting Windows -> Preferences.

Figure 2. Preferences
Preferences

For more tips on performance, see Rational Application Developer Performance Tips.

Question: How do we specify in WebSphere annotations if we want composers to be used for custom mappings of user types in CMP 2.x beans?

Answer: Currently, there are no annotations for composers in the current version.

Question: How to handle top down WSDL to Java™ round tripping? Now using iRAD so when modifying WSDL, I don't want to lose code in the service endpoint skeleton (where first level user code goes in Java). Don't want to use java2WSDL so as to maintain interoperable WSDL, given top down WSDL to Java is recommended.

What are the options? Modifying/enhancing WSDL should be supported as a basic service lifecycle requirement. Have large number of teams requiring standards/guidance on how to manage changing service interfaces.

Can iRAD provide support? Past initial Java service class generation?

Are there any tools available? Should be able to track and not lose non-generated code.

Answer: Currently, there are no annotations or tools that you can use to avoid changes from not being overridden. You can use certain strategies:

  • After the initial generation, use the bottom-up approach after that. Changes on an interface are usually driven by changes needed in the implementation.
  • If you want to use top-down, make sure your generated skeleton code is just a pass through to another class. This way, all you have are minimal changes that are made through re-generation. You could probably write an ANT task or use the Design Pattern Toolkit to generate the call to the class.
  • If you use the Service Integration Bus, you can use Inbound Services to expose destinations as Web services and have Mediations service the request. The Mediation Code will not be re-generated because they interact with Service Data Objects (SDO). For more information, see Service Integration Bus article series and Deploying JMS Applications and MDBs into the Service Integration Bus.

Question: Is it possible to apply WebSphere Application Server Refreshment Pack onto WebSphere Application Server 6 test enviromnent within RAD6? I've applied RAD6 6.0.0.1 interim fix 3 to RAD6, but the test environment seems to stay at the original level (6.0.0.0), according to the \Rational\SDP\6.0\runtimes\base_v6\profiles\default\bin\versioninfo command.

Answer: Yes, going forward, you need to apply WAS fixpacks and refresh packs to the WebSphere Application Server Test Environment separately, as documented in Technote: Upgrading the WebSphere Test Environment V6 in Rational Application or Web Developer.

The test environment in RAD is a full WebSphere Application Server Base edition. When installing WebSphere updates, WebSphere Application Server's root will be C:/<RAD_INSTALL_ROOT>/runtimes/base_v6.

Question: I am now looking into the features of RAD 6 and trying to test EJBs using the EJB component Test. But til now, I am not successful and getting into lot of issues. Do you have any document that explains how to test EJBs?

Answer: You can check the following resources:

Question: Is there a mechanism to maintain data/record locking in the backend database when the end-user is working on the data accessed through a JSF/SDO (Service Data Objects) based Web client? If not, is there a mechanism to at least inform the client that the data he/she has accessed has changed while he/she was working on it.

Answer: Yes, you can supply an optimistic concurrency control (OCC) integer column to a given table, and specify that this column is to be used for OCC in the metadata. The defined OCC collision column is reserved for the exclusive use of the mediator. For more details, see JDBC mediator transactions.

Question:

  1. Is it possible to use Crystal Reports with WebSphere Portal 5.0? If not, what other reporting software would be suggested?
  2. Is it possible to use MySQL to develop CMP EJBs in RAD v6?
  3. Is it possible to use Crystal Reports with Cloudscape?

Answer:

  1. Business Objects provides solutions for IBM WebSphere Portal by providing various portlets. For more information, see Business Objectives Enterprise Portlets.
  2. As long as you have a compliant JDBC driver, it could work. However, IBM provides support for the JDBC drivers listed in the Information Center. If your DB is not listed, you may want to talk to your IBM Representative.
  3. You need to check with Business Objects who makes Crystal Reports, for their official supported list of databases. For more information, see Crystal Report Features.

Question: Can we use Rational Software Architect 6.0 in place of RAD V6 for all the requirements, right from developing UML designs to other J2EE-based solutions?

Answer: Rational Software Architect (RSA) is a superset of Rational Application Developer. So yes, you can use it in place of RAD. RSA is the next generation of modeling tools. You can import Rational XDE and Rose models and do full design to implementation development.

A product like Rational Rose has years of maturity, so not all functionality in Rose will be immediately part of RSA. However, over time RSA is the strategic direction for design and modeling. In addition, RSA contains support for UML 2 and transformations (some specific for J2EE) that do not exist in any of its predecessors.

Question: Agent.jar and apc.jar are specified for the BOOTCLASSPATH system property. What role do these jar files perform while the server is getting initialized?

Answer: I'm not exactly sure what product you are referring to. These jars are not part of WebSphere Application Server or Rational Application Developer. It is possible this is a jar that is part of an older version of the IBM Agent Controller used for profiling. It could possibly be something to do with a third party product that integrates with WebSphere Application Server, such as Site Minder. Use caution when adding and removing jars from your classpath without knowledge of their use.

Question: How is it possible for RAD in WebSphere 6.0? What is FFDC? FFDC works for Windows®.

Answer: I'm not exactly sure what you mean by the first part of the question. RAD is an acronym for Rational Application Developer, which is the main IDE to support development for Rational Application Developer V6. RAD is also an acronym for rapidly developing applications. It is possible to support several styles of development with WebSphere Application Server. You can support automated development with a combination of ANT and build scripts. You can use any J2EE IDE. We also have WebSphere Rapid Deploy, which is a hot deployment tool and annotation processor. See the question on hot deployment for more issues.

FFDC stands for First Failure Data Capture. It preserves the information that is generated from a processing failure and returns control to the affected engines. The captured data is saved in a log file for analyzing the problem. FFDC is intended primarily for use by IBM Service. FFDC instantly collects events and errors that occur during the WebSphere Application Server runtime. The information is captured as it occurs and is written to a log file that is analyzed by an IBM Service representative. For more information, see the Information Center.

Question: As I am new to WebSphere, I want to know the following:

  1. What is the file structure of WebSphere?
  2. How will I deploy EJBs in WebSphere?
  3. Can I directly copy *.ejb to WebSphere, or do I need to make *.war for that?

Answer: I suggest you pick up our book, IBM WebSphere: Deployment and Advanced Configurations, which answers all these questions directly.

  1. WebSphere Application Server is designed to try to shield developer and administrators. The Admin Console and scripting language give you a full range of coverage. There are several underlying files and directories that get updated for various actions. In addition, if you use WebSphere Application Server Network Deployment, multiple sets of directory structures get replicated. Figure 3 illustrates some of the important elements to keep in mind.

    Probably the most interesting portion of the WebSphere Application Server directory structure is the config directory under a specific profile. WebSphere Application Server supports various scopes of configuration visibility relative to where the application is deployed. The configuration for the scope is defined within several XML files under the directory of the scope. Update the configuration through one of the WebSphere Application Server administrative tools and not by hand editing XML files. XML file editing should only happen if there is some configuration that has caused severe errors. If anyone makes any changes, that person should have a deep understanding of WebSphere Application Server. WebSphere also has a backup and restore capability of configuration that allows you to restore configurations. Use these features religiously instead of hand editing.

    Figure 3. Directory structure
    Directory structure
  2. The J2EE specification requires that you package EJB applications in an EJB jar file and follow the EJB directory structure. In addition, J2EE applications are packaged into EAR files that can contain several EJB Jar files. You can deploy EJB applications as EAR files or as standalone EJB jar files, although the EAR approach is recommended for portability. WebSphere Application Server supports several tools for deploying applications:
    • WebSphere Application Server admin console
    • Wsadmin scripting language
    • Specialized ANT tasks
    • Rational Web Developer, Rational Application Developer, Rational Software Architect, or the Application Server Toolkit
    • WebSphere Rapid Deploy (allows the deployment of unpackaged annotated java classes directly into WAS)
  3. I am not sure what you mean by *.ejb. EJB applications are made up of several Java files and XML deployment descriptors that are packaged into an EJB jar file and deployed as a module.

Question: I have installed WebSphere Application Server 6 and now I want to change the hostname (and IP address) for deployment. How do I do that?

Answer: There are several places where the hostname and IP need to be updated. We provide scripts that enable you to do this. You can download the sample scripts.

Question: How is it possible for hot deployment in WebSphere 6.0? Is there any ANT task that supports hot deployment for WebSphere 6.0?

Answer: Yes, we provide a new feature in version 6 of WebSphere Application Server called WebSphere Rapid Deploy (WRD). WebSphere Rapid Deploy enables you to setup a special directory for automatic deployment of J2EE modules or loose annotated Java classes. There are two modes supported:

  • AuotAppInstall: Deployment of J2EE modules
  • Free Form: Deployment of annotated Java files

AutoAppInstall: You can use WRD to create a style that automates the installation, modification, and de-installation of J2EE compliant applications or modules. Instead of taking an EAR file and using wsadmin or the Web Admin UI to install that application through a multi-step wizard, you can use WRD to create a monitored directory in which you can simply place the EAR. Upon placing the EAR in the directory, WRD detects the addition of the new file and builds of the project Of course, WRD would, in addition to handling EAR files, consume individual J2EE modules (WARs, EJB jars, RARs) and construct EARs as part of its execution.

Figure 4. WebSphere Rapid Deploy
WebSphere Rapid Deployment

There is also the option of enhancing the EAR file. This enhanced EAR file contains information to allow WRD to automatically create the resources. Here is an example of using AutoAppInstall:

  • Configure the WRD workspace
    1. export WORKSPACE= C:\WRDAutoInstall
    2. $WAS_HOME/bin//wrd-config -project DeployProject -style AutoAppInstall -runtime "was60" -runtimePath "D:/WebSphere_60/AppServer" -monitor
  • Start the WRD daemon: $WAS_HOME/bin/wrd -monitor
  • Copy EAR into directory

Free form: You can also use WRD to reduce the complexity of application construction. In this scenario, instead of providing a fully-constructed J2EE application, you place in a directory the individual parts of the application, such as Java Source files that represent Servlets or EJBs, static resources, XML files, and so on. You then configure WRD to construct a J2EE compliant application and deploy that application on a target server. Free form is ideal for initial prototyping of applications or development of library code. However, use caution when using free form development for enterprise applications. Developers can quickly lose control of their build and deployment process. Here is an example of using free form:

  • Configure the WRD workspace:
    1. export WORKSPACE=D:/WRDWorkSpace
    2. $WAS_HOME/bin//wrd-config -project "MyProject" -style "freeform" -runtime "was60" -runtimePath "D:/WebSphere_60/AppServer" -monitor
  • Start the WRD daemon: $WAS_HOME/bin/wrd -monitor
  • Create a Java Servlet or EJB class in the directory using any editor.

For more information on WRD, see the WebSphere V6 Information Center.

Here is an example of the code. These were the only artifacts developed.

HelloServlet.java

package com.wrdtest;

import java.io.*; 

import javax.naming.InitialContext;

import javax.servlet.http.*; 
import javax.servlet.*;

public class HelloServlet extends HttpServlet { 

  public void doGet (HttpServletRequest req,
HttpServletResponse res) throws ServletException, IOException { 

    PrintWriter out = res.getWriter();
    try {
		InitialContext ctx = new InitialContext();
	HelloHome helloHome = (HelloHome)ctx.lookup("ejb/Hello");
	HelloRemote hello = helloHome.create();
    out.println("Hello, world!"); 
    out.println(hello.getMessage());
    out.close(); 
    
    } catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace(out);
		out.close();
	}

  }


MyService.java

package com.wrdtest;

/**
 * @author Admin
 *
 *@ejb.session name="Hello" type="Stateless" 
 *jndi-name="ejb/Hello"
 *              local-jndi-name="ejb/Hello"
 */
public class MyService {
	
	/**
     * 
     * @param symbol
     * @return
     * @throws StockException
     * 
     * @ejb.interface-method view-type="both"
     * @ejb.transaction type="Required"
     * 
     * 
     * 
     */
    public String getMessage()
    {
    	return "Hello EJB";
    }

}

Question: I am working with RAD and WebSphere 6.0. I want to deploy an EAR file with log4j, but an error appears during deployment. What is wrong? The log4j.xml is in the ear file.

[7/25/05 17:39:54:269 CEST] 00000062 ResourceMgrIm I   
WSVR0049I: Binding ENT13000 as jdbc/ENT13000
[7/25/05 17:39:54:284 CEST] 00000062 EJBContainerI I   
WSVR0207I: Preparing to start EJB jar: TDSLRechercheEJB.jar
[7/25/05 17:39:54:312 CEST] 00000062 EJBContainerI I   
WSVR0037I: Starting EJB jar: TDSLRechercheEJB.jar
[7/25/05 17:39:54:904 CEST] 00000062 MDBListenerIm I   
WMSG0058I: Listener Port ListenerPortNI will attempt to 
restart in 60 seconds
[7/25/05 17:39:54:937 CEST] 00000062 ApplicationMg E   
WSVR0101W: An error occurred starting, TDSLRechercheJ2EE
[7/25/05 17:39:54:945 CEST] 00000062 ApplicationMg A   
WSVR0217I: Stopping application: TDSLRechercheJ2EE
[7/25/05 17:39:54:988 CEST] 00000062 EJBContainerI I   
WSVR0041I: Stopping EJB jar: TDSLRechercheEJB.jar
[7/25/05 17:39:55:034 CEST] 00000062 ApplicationMg A   
WSVR0220I: Application stopped: TDSLRechercheJ2EE
[7/25/05 17:39:54:770 CEST] 00000062 SystemErr     
R log4j:ERROR Could not open [./log4j.xml].
[7/25/05 17:39:54:773 CEST] 00000062 SystemErr     
R java.io.FileNotFoundException: ./log4j.xml (No such 
file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at org.apache.log4j.xml.DOMConfigurator.doConfigure
(DOMConfigurator.java:583)
at org.apache.log4j.xml.DOMConfigurator.configure
(DOMConfigurator.java:687)
at com.tsystems.blt.j2ee.log.TDSLRechercheLogger.<clinit>
(TDSLRechercheLogger.java:17)
at com.tsystems.blt.j2ee.jms.MP_MessageListenerBean.<clinit>
(MP_MessageListenerBean.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance
(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at com.ibm.ejs.container.EJSContainer.loadBeanMetaData
(EJSContainer.java:1596)
at com.ibm.ejs.container.HomeOfHomes.loadBeanMetaData
(HomeOfHomes.java:659)

Answer: I assume you are packaging the log4j.jar at the EAR level. It seems you are trying to load your logging configuration directly from the file system. I usually tell people to load the log4j configuration file as a classpath resource. This way, you can put it in a WebSphere Application Server shared library or package it in the EAR. You can use something like:

ClassLoader.getSystemResourceAsStream()

Or, you can load a system property with the location of the configuration file.

Acknowledgements

The author would like to thank the following people for their help in preparing this article: Kyle Brown, Keys Botzum, Leigh Williamson, Tom Alcott, and Greg Flurry

About Meet the experts

Meet the experts is a monthly feature on the developerWorks WebSphere Web site. We give you access to the best minds in IBM WebSphere, product experts who are waiting to answer your questions. You submit the questions, and we post answers to the most popular questions.

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=91080
ArticleTitle=Meet the experts: Roland Barcia on developing J2EE and Web services applications on Rational Application Developer V6
publish-date=08032005