Showing posts with label netbeans. Show all posts
Showing posts with label netbeans. Show all posts

Thursday, 8 October 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.

Thursday, 9 July 2009

Setting up the right umask when installing NetBeans

This isn't a problem I encounter so often when installing software on the Solaris platform. The strange thing is that NetBeans is a Sun-sponsored project! But hey, a bug's just a bug.

Solaris default umask (file mode creation mask) for user is 022. That means that during file creation the write bit is filtered away from group and other permission bits. So, if you touch a file, you'll end up with these permissions set:
$ touch test
$ ls -l test
-rw-r--r--   1 enrico   staff          0 Jul  9 23:45 test
This basically means that everybody is granted access for reading your file. That may not be an issue for you because that file is hanging from a directory hierarchy which is otherwise protected. Solaris though, if the umask is not changed when creating home directories, will create a home directory for you with world readable flags set.

To cope with such situations, a good practice could be changing the default umask to a more restrictive value, such as 077. That's the umask I use and, as you see, it filters away all the permission bits for group and others. The previous test will end up with such a result:
$ touch test2
$ ls -l test2
-rw-------   1 enrico   staff          0 Jul  9 23:49 test2
This is not a problem unless the software you're using relies on a particular umask values (such as 022). That appears to be the case for the NetBeans installer. I just installed NetBeans 6.7, replacing my "venerable" NetBeans 6.5, and I ended up with the same problem I encountered during the installation of the earlier version. If you install NetBeans with a more restrictive umask set, the installation will result in an unusable set of files.

So, remember: if you're planning to install NetBeans 6.x onto your Solaris box and you plan to install it as root to provide an installation for all of your users, don't miss (re-)setting your umask to 022:
# umask 022
# ./netbeans-6.x-ml-solaris-x86.sh