Introduction
In this Two part of the article i shall explain how to build a simple J2EE Console Client to run on Windows XP platform using Java 1.5 SDK to talk to J2EE (EJB Component) on Websphere Application Server Version 6.1. Eclipse 3.2.1 as well as XDoclet 1.2.3.
The Article assumes Websphere 6.1 has been installed on a Windows 2003 platform. Though other OSs should not make any difference.
The article will follow a simple approach to write a Stateless Session bean and a Console based J2EE client with minimum amount of code required then deploy the EJB Component to Websphere as well as the Client package Both manually, I shall focus mainly on how to setup an Ideal Development Environment for the pieces of software technologies above to work together in Harmony without any automated tools for deployment or packaging.
In Part I i shall explain how to setup the Java development Environment as well as generate the J2EE Classes using Eclipse XDocLet Support. Then In Part II of the Article i shall explain the Packaging, Deployment and running of the solution on Websphere Server and Client.
Note: Installing and Administering IBM Web Sphere 6.1 as well as how J2EE is programmed or does work is out of the scope of this article.
Background (optional)
I didn't expect to to write a Java Article here at the time at all, Having stopped writing Java code for the Past 3 Years! and spending almost all the past 3 Years writing .NET Code ..However, I came across an exceptional Task at my work place to have a Batch Scheduling Product communicating with an EJB that is hosted within the latest version of IBM Web Sphere Application Server Version 6.1.
To complete this -Daunting- task i needed to go through a complete Development Life-cycle for a simple Windows console based Client for J2EE on Websphere. Before i start i wishfully thought that the Java communities by now would have established enough programming resources repository and Web Forums that would make my life so perfect. To my amazement and disappointment i could NOT put my hand on a single source of information that describes how to compose a J2EE development Environment for Websphere 6.1 using the latest Eclipse / XDoclet IDE technology!
Hence, i shall put here my experience achieving the above. Hopefully, it might help others.
Setting Up the Development Environment.
First The list of pre-requisites :-
Second. Start by installing Java JDK Version 5.0 above on the Client Machine. Then XCOPY the Application Client for web sphere application server 6.1 under any folder on the client machine.(For Example: c:\Websphere6.1Client)
Now. It is time to install the Eclipse WTP. Extra t / Unzip the complete file/folder list to any folder on the Client Machine (For Example: c:\eclipse). And for the XDoclet Extract / Unzip the complete file/folder to any directory on the Client machine (For Example: c:\XDocLet)
Finally start Eclipse and apply the following Configuration Changes:
- Change the Eclipse Project Perspective : Window/Open Perspective/other/J2EE
-
- Point Eclipse to the current JDK. Window/preferences/Installed JREs/Add your JDK path for example c:\program files\java\jdk1.5.0_10
-
- Point Eclipse to the Run-time of the Web Sphere Application Server 6.1. Window/preferences/Server/Installed Runtimes where the physical folder on the Websphere Application Server 6.1 C:\Program Files\IBM\WebSphere\AppServer\lib is mapped to a Network share for the WebSphere Folder such as \\your machine\WebSphere_6.1\AppServer\lib
-
- Point eclipse to the XDoclet library. Window/preferences/XDocLet
-
- The Set the Tree Node ejbdoclet under the path above to the values:
-
- Finally, set the Tree Node webdoclet to the values:
-
Creating the Session Bean
We need first to tell Eclipse to Create a J2EE Project Skeleton for us, then we use XDoclet to Fill that Skeleton with the java Bean componenents' classes.
From the Eclipse menu File/New/Project...
Then From the Eclipse menu start the XDocLet Java bean Wizard File/New/Other choose from the List Folder EJB/XDocLet Enterprise JavaBean.
Choose Session Bean
Then Fill the Class Information below after selecting the Project we created above from the List in the Project Drop Down List. (Remember to choose lower case simple names for the package and Indented informative Names for the classes)
Complete the Wizard above with your own values for the generated J2EE classes and the Client.
Points of Interest
Now, before concluding this Part (Part I) of the article let us have a look at the generated code at this stage:
If we have a quick look at the Project explorer (right top pane) we can identify the following items (Assuming my own Project name Prefix ControlM)
- The J2EE Project which mainly contain the The EAR XML Project file with all Modules listed.
- The J2EE Client Project which contain the Main.java console application Under the appClietntModule Folder in the tree. this will be our J2EE Client. along with the tree nodes for the
public class Main {
public static void main(String[] args) {
}
public Main() {
super();
}
The discussion of the Implementation of the Client is left to the next part of this Article.
- The J2EE Classes under the Project EJB Tree Node and under the EJB Module tree node.
- The Java Package tree node.
- The Bean Class where the J2EE Create Method(s) and Business methods are implanted.
- The Remote Interface for the EJB.
- The Home Interface for the EJB.
- The Local and LocalHome. (Not used in the Console based Client J2EE solution)
- The Session Been Class where container actions during EJB Instance life cycle can be triggered and implemented here.
- The utility Java Class for the EJB solution that has standard generated code for JNDI lookup.(No implementation required here)
We will have a close look at some the classes above when we implement our simple J2EE Component and Client in the next and final part of this article.
History
N/A.