Thursday, October 8, 2009

Developing Java EE applications for WebSphere AS with NetBeans

Chances are that if you're developing a Java EE application for IBM WebSphere Application Server, sometimes you'll need to use some IBM APIs to get the job done. If you're not using IBM's integrated development environment, you will have to add to your compilation classpath all the required libraries.

I'm a NetBeans fan and unless the customer explicitly prohibits this IDE, I always try to evangelize the developers working with me and switch to NetBeans. Lately, we've been developing a custom user registry and some login modules to plug into WebSphere Application Server: I definitely needed to link to WebSphere libraries.

To ease the switch to NetBeans from Rational Software Architect, I defined the library in my NetBeans and then distributed the definition of the NetBeans library, which simply is an XML file.

As you can see in this screenshot, the required libraries to work with WAS 6.1 are a good number and find themselves in a bunch of different WAS installation directories. In this case, I'm using the libraries of the WebSphere Application Server which is bundled with Rational Software Architect v. 7.0.

To distribute this definition to your fellow developers, you can just give them the library definition which you can find in the following directory (modulo NetBeans version number):

~/.netbeans/6.7/config/org-netbeans-api-project-libraries/Libraries

Since this library has been labeled WAS-6.1, the file name is WAS-6.1.xml.

The structure of such file is pretty intuitive, as you can see from this excerpt:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library PUBLIC "-//NetBeans//DTD Library Declaration 1.0//EN" "http://www.netbeans.org/dtds/library-declaration-1_0.dtd">
<library version="1.0">
    <name>WAS-6.1</name>
    <type>j2se</type>
    <volume>
        <type>classpath</type>
        <resource>jar:file:/C:/Archivos%20de%20programa/IBM/SDP70/runtimes/base_v61/lib/WMQ/java/lib/com.ibm.mq.jar!/</resource>
        <resource>jar:file:/C:/Archivos%20de%20programa/IBM/SDP70/runtimes/base_v61/lib/WMQ/java/lib/com.ibm.mqjms.jar!/</resource>
        <resource>jar:file:/C:/Archivos%20de%20programa/IBM/SDP70/runtimes/base_v61/lib/bootstrap.jar!/</resource>
        <resource>jar:file:/C:/Archivos%20de%20programa/IBM/SDP70/runtimes/base_v61/lib/j2ee.jar!/</resource>

Should you need it, you can process it with a program, or even with grep and sed, and batch-apply any change you'd need. For example, since my development platform of choice is Solaris whilst my client's is Windows, I frequently have to modify such files to adjust the library paths.

I'm now developing flawlessly in NetBeans and deploying our applications, or even our plugin modules, on WebSphere Application Server. NetBeans hasn't any plugin, as far as I know, to produce IBM-specific deployment descriptors but we're not experiencing any problems: we just apply deployment customization using WAS' excellent administration console.

2 comments:

யாத்ரீகன் said...

how do you add Webshpere 6.x/7.0 server to your Netbeans IDE.

I am using NetBeans 6.8 but most of blogs i see say that it does not have support for Websphere and even plugins were available only for older server & ide versions. even these are no longer available.

any help is appreciated.

thanks

Grey said...

Hi.

What I've done is simply defining a library in NetBeans so that my Java EE modules could use proprietary, non-portable APIs. That, incidentally, are just what you find in IBM Rational Software Architect.

Since the client I'm working for mandates that Java EE applications be bundled and manually deployed, I'm not affected by the missing plugins problem.

Nevertheless, I'll investigate it and if I come out with some idea, I'll gladly blog about it.

Cheers,
Grey