The Source for Java Technology Collaboration
User: Password:



Dru Devore's Blog

January 2006 Archives


Sun Java Studio Creator 2 Released

Posted by ddevore on January 26, 2006 at 08:05 PM | Permalink | Comments (0)

I have been a part of the Creator 2 EA program for about 3 months now and have loved testing it out. This IDE makes web development using JSF as easy as drawing a page on a white board.

If you have not tried it do what I am doing right now and download it. Give it a try and you will see that it is by far the best IDE for web page design available today.

http://developers.sun.com/prodtech/javatools/jscreator/downloads/

Also, let me know what you think about it and how it works. As I work with it I will be blogging my experiences. If there is something you would like to say comment here.



How To Refresh Web Services in Creator 2

Posted by ddevore on January 26, 2006 at 06:14 AM | Permalink | Comments (0)

If you are developing a front end for Web Services in Creator 2 and need to make a change to the Web Service currently there is no automatic way to tell Creator to refresh the Web Service and regenerate the libs for the service. This document will walk you through refreshing the web service so that you can see the changes made to the Web Service.

Remove the Web Service from the Project
First you must remove all references to the Web Service from the pages which currently use it. To do this you must remove the references to the service from each page which uses it. First select the page and select the Outline tab on the lower half of the left side of the screen. Find the reference to the service and delete it. Then select the Java button to open the Java source for the page. Since the reference for the service has been deleted the references to the service should show as an error, comment out all references to the service. Once you have done this for allpages which reference the service click on the Servers and select the Web Services section and delete the reference to the service from the list of services. Once all references to the service are removed clean the project and shut down Creator.

Remove the libs
Next you must remove the libs from the lib directory. To do this go to the project directory and expand the lib/webservice_clients directory, this is where all generated Web Service libs are held. The libs for the Web Service will begin with the service name for the service I am working with it is ChangeofAddress so my files are named like this:

ChangeofAddress-1133983181995.jar
ChangeofAddress-1133983181995DesignTime.jar

Remove these files.

Remove references from project properties
Next we must remove the references from the projects properties. Go to the project directory and expand the nbproject directory. Edit the project.properties file and search for the lines with the service name. You will find 3 references to the libs. The first is easy simply remove the lines. The second and third you must modify the line above it for the project to properly open. The following is a list of the references and how to modify them to remove them from the project properly.

1. Remove these lines

file.reference.ChangeofAddress-1133983181995.jar
=lib/webservice_clients/ChangeofAddress-1133983181995.jar
file.reference. ChangeofAddress-1133983181995DesignTime.jar
=lib/webservice_clients/ChangeofAddress-1133983181995DesignTime.jar

2. Modify as follows

    ${libs.WEBSVC_SUPPORT_LIB.classpath}:\
    ${file.reference.ChangeofAddress-1133983181995.jar}:\
    ${file.reference.ChangeofAddress-1133983181995DesignTime.jar}
# Space-separated list of extra javac options

Modify like this

    ${libs.WEBSVC_SUPPORT_LIB.classpath}
# Space-separated list of extra javac options

Keep in mind that if there are more services being referenced there may be more jar files listed. The important thing to remember is that if this is the last in the list REMOVE the :\ at the end before the # Space-separated list of extra javac options line.

3. Modify as follows

    ${libs.WEBSVC_SUPPORT_LIB.classpath}:\
    ${file.reference.ChangeofAddress-1133983181995.jar}:\
war.ear.name=LibTest.war


Modify like this

    ${libs.WEBSVC_SUPPORT_LIB.classpath}
war.ear.name=LibTest.war

Once again keep in mind that if there are more services being referenced there may be more jar files listed. The important thing to remember is that if this is the last in the list REMOVE the :\ at the end before the war.ear.name=LibTest.war line.

Next edit the project.xml file and remove the references to the libs there. There are 2 references in this file and can be simply removed. The following is the example for the service I am removing.

The first is a reference to both jar files, remove them with the library files begin and end tags.

                <library files="1">
                    <file>${file.reference.ChangeofAddress-1133983181995.jar}</file>
                </library>
                <library files="1">
                    <file>${file.reference.ChangeofAddress-1133983181995DesignTime.jar}</file>
                </library>

The second is a reference to the actual service client jar file, remove it with the library files begin and end tags.

                <library files="1">
                    <file>${file.reference.ChangeofAddress-1133983181995.jar}</file>
                    <path-in-war>WEB-INF/lib</path-in-war>
                </library>


Resume Development
Once those are removed youcan continue development. Start Creator, add the service back to the Servers | Web Services, add it back to the pages which need it and uncomment the code commented out while removing it from the project. Once this is done you will see the changes. Please note that when you add a service to a page a second time it may change the object reference like this changeofAddressClient2 instead of changeofAddressClient1 so you may need to modify some of the code you commented out to reflect this change.

Notes
I have been told that they are working on this problem but since I have run into it I figured that some other prople would have also and they might want to know how to insure they were working on the latest version.



How to setup JBoss to work with Sun Java Studio Creator

Posted by ddevore on January 23, 2006 at 06:07 AM | Permalink | Comments (2)

This is a guide for setting up JBoss 4.0.1sp1 and JBoss 4.0.3sp1 to work with Sun Java Studio Creator, (referred to as Creator hereafter). By default JBoss does not include JSTL (Java Standard Tag Library) or JSF (Java Server Faces). Hence, to deploy an application to JBoss which is developed in Creator you must modify the default JBoss setup.

JBoss 4.0.1sp1 setup
Creator Release 1
Copy the jstl.jar and standard.jar files from the CREATOR_INSTALL_DIR/modules/autoload/ext directory to the JBOSS_SERVER_DEPLOY_DIR/jbossweb-tomcat50.sar directory.

Creator Release 2
Copy the jstl.jar and standard.jar files from the CREATOR_INSTLL_DIR/enterprise1/config/TagLibraries/JSTL11 directory to the JBOSS_SERVER_DEPLOY_DIR/jbossweb-tomcat50.sar directory.

JBoss 4.0.3sp1 setup
Creator Release 1
Copy the jstl.jar and standard.jar files from the CREATOR_INSTALL_DIR/modules/autoload/ext directory to the JBOSS_SERVER_DEPLOY_DIR/jbossweb-tomcat55.sar directory.

Creator Release 2
Copy the jstl.jar and standard.jar files from the CREATOR_INSTLL_DIR/enterprise1/config/TagLibraries/JSTL11 directory to the JBOSS_SERVER_DEPLOY_DIR/jbossweb-tomcat55.sar directory.

Required for Both JBoss 4.0.1sp1 and JBoss 4.0.3sp1
Since JBoss runs the MyFaces from Apache by default you must remove their libraries. These libraries are in the JBOSS_SERVER_DEPLOY_DIR/jbossweb-tomcat50.sar/jstl-libs or JBOSS_SERVER_DEPLOY_DIR/jbossweb-tomcat55.sar/jstl-libs directory. Remove the jstl-libs directory and the JBOSS_SERVER/tmp and JBOSS_SERVER/work directories. The latter two directories are created when you start JBoss and cache the jstl-libs files.

Run the Application
Start the JBoss application server, deploy an application and navigate to the URL for the application just deployed. The application should run with no errors.



Java with Generics

Posted by ddevore on January 12, 2006 at 12:06 PM | Permalink | Comments (9)

I have been using Generics now for almost a year now and have found a love/hate relationship with them. My introduction to what Generics would do to you was when I compile a project with a UniqueList utility class I have been using for years now. This is a simple extension to the ArrayList which does not allow duplicates, nulls and keeps them in order. I really like this class because it is easy to use and very simple to make. The problem was that when the compiler hit the class I though it was going to hit me over the head with a ball bat. It threw errors everywhere. Since Generics are not going to go away I figured I would start my Generics learning with rewriting my utility class. I started by reading what ever I could find about them then I found this tutorial, nice job Gilad, and went to work.

Modifying UniqueList
In modifying UniqueList I found that Generics were not all bad. It is a little confusing at times but in all it is workable. To get the compiler to put down the ball bat I basically had to add a couple of <E> codes and we were all happy again. I thought Great I am a Generics expert..that didn't take long. Curses that is not all there is to it.

On with Generics
From the start I found Generics easy to use though the implementation of classes/utilities which use Generics can be a little confusing as found in modifying the UniqueList but how often do you really create util classes? Also, if you are planning on using a generic with sub classes don't forget the <? extends String> notation. This blog is not to investigate the full use of Generics. It is to point out a few highs and lows of them.

Dislike
Then I started to do more work with it. Though I understand the Generics concept and know how it works you cannot use them in all conditions. Sometimes you need a list of undefined object types. So you go to the old reliable method of declaring a Collection.

ArrayList al = new ArrayList();

Instead of the new method.

ArrayList<String> al = new ArrayList<String>();

This is not a big deal until you use that variable and the compiler yells at you with ball bat in hand. For some reason the compiler thinks it knows more about Generics than I do which I am sure it does. The problem with this is that sometimes you need a "generic" object list and not a Generics list. There is no way to stop this checking and -Xlint:unchecked will show a detailed list of these warnings. Now I am the type of person who likes to have my code as clean as possible. I don't like turning off checking and I usually have checking for deprecated classes turned on to remind me of things which need to be cleaned up. When I find a warning I usually go fix it if there is any way I can do it be it my warning or someone elses. For me to have a clean command line and have this warning bugs me. This is the big dislike.

Then you have the length of the lines for Generics. As I mentioned above I like clean code. I keep my code within the 80 col marker when possible but like descriptive names for my classes. This creates a problem of long lines when you use Generics. Take for instance a class with the name AccountInformation used in a ArrayList.

ArrayList<AccountInformation> accountList = new ArrayList<AccountInformation>();

This line indented takes you over the 80 col limit so you have to wrap the line

ArrayList<AccountInformation> accountList =
        new ArrayList<AccountInformation>();

Which just isn't the same and if you like your code a certain way this may not be good. I like code on one line but I know that to have the descriptive names like I want you cannot always have the short lines. This is about all the dislikes yes there are only 2 and are very small considering the advantages Generics provide.

Likes
What I do like about the Generics outweighs the 2 minor dislikes considerably. Using Generics with the new and improved loop makes live much easier. Lets look at a loop using the new and old method with the accountList.

New Method

for (AccountInformation ai : accountList) {
    // Do something with the account information ai
}

Old Method

AccountInformation ai = null;
Iterator it = accountList.iterator();
for (int i = 0; i < accountList.size(); i++) {
    ai = (AccountInformation)it.next();
    // Do something with account infromation ai
}

As you can see from this simple example the new method is shorter and simpler to use. The compiler automatically puts in the casting of the type to the variable and iterates over the list. No more manual iteration over the list or unsafe casting. This is possible because the compiler does the type check for you to insure that the list contains only AccountInformation objects, this is where the warning from the dislikes comes in, so you always know what you are working with. If the Old Method above were to be written to insure safe casting it would look more like this.

Old Method with Safe Casting

Object obj = null;
AccountInformation ai = null;
Iterator it = accountList.iterator();
for (int i = 0; i < accountList.size(); i++) {
    obj = it.next();
    if (obj instanceof AccountInformation) {
        // Now you are asured that the type is correct and it is safe to cast.
        ai = (AccountInformation)obj;
        // Do something with account infromation ai
    } else {
        // Not safe to cast you must do something else.
        // Handle Error.
    }
}

You can see from the examples above that it lessens the code required for a loop and insures safe object casting. The compiler also insures the correct type improving the typeing of the objects and helps to eliminate the need for as much error checking.

Conclusion
Love them or hate them you should know them because they are not going away. If you are new to Generics remember they are there to make your life easier and from the examples above you can see that they do. Also, this is only one example of where they make life easier. You should try them out and see what they can do for you.

More information
For more information on Generics and other changes in Java SE 5 please see the following:
Java Tutorial
Java SE 5 Adoption

Update
Using @SuppressWarnings("unchecked") on methods which perform castings will tell the compiler to not warn on unchecked types. Thanks Dave for the information.

I have not looked at annotations yet I guess that should be my next task and I will test this one out then.



EJB Creation and Consumption with NetBeans and JBoss

Posted by ddevore on January 10, 2006 at 08:02 AM | Permalink | Comments (2)

At the time of writing this guide NetBeans IDE was in version 5.0 Beta. This guide was written using the latest development build #200601052030 to take advantage of the bug fixes since NetBeans IDE 5.0 went into beta. Also, NetBeans officially supports JBoss Application Server 4.0.3 so this guide will walk through the JBoss Application Server 4.0.3sp1 setup. If you are using a previous version of JBoss I suggest switching to 4.0.3sp1 because of some support changes in JBoss for Web Services which will be discussed when I get to Web Services. If you have not setup NetBeans to work with JBoss please see NetBeans with JBoss Setup.

Creating Projects
Now that you have NetBeans setup with JBoss you can create a project to create and consume EJBs. The EJB Module is the only project which NetBeans will allow you to create EJBs. There is an Enterprise Application project which by default creates an EJB Module and Web Module, used for Web Services and pages, as sub projects. Since most project now days will not have only EJBs this guide will use the Enterprise Application project as the main project, though you can use the same methods for a project without the use of the Enterprise Application project.

Creating a Enterprise Application Project
To create an Enterprise Application either right click in the project view and select New Project or from the main menu select File | New Project. Both will bring up the New Project dialog. In this dialog select the Enterprise node and Enterprise Application from the list of projects on the right and select Next. In the next screen enter the project name, location and server. Because of the incomplete implementation of JAX-RPC in JBoss NetBeans will not create a web service with the JBoss server as the target. So to create an Enterprise Application project which will have Web Services the target server of the Web Module of the Enterprise Application must be the Sun Java System Application Server this can be changed later. If you choose the JBoss server at this stage the target server will have to be changed in the Web Module to create Web Services. You also have the opportunity to change the name of the EJB Module and Web Module which will be created with this project. For this guide I am leaving the default names for these modules and naming the project NBJBossApplication. Once this is done click Finish. This will create the project and open them up in the projects tab see Figure 1 below.

projectview1.jpg
Figure 1

You can see in Figure 1 above that NetBeans created not only the NBJBossApplication project but the NBJBossApplication-EJBModule and NBJBossApplication-WebModule as well. The directory structure of the NBJBossApplication project with the sub projects can be seen in Figure 2 below.

fileview1.jpg
Figure 2

As you can see by simply looking at the file layout in Figure 2 Enterprise Application projects are a very good way of organizing large applications which is why I am using them in this guide. A complete discussion of the Enterprise Application project is outside the scope of this guide and will not be discussed here.

Creating a EJB Module
You create an EJB Module the same way as the Enterprise Application. Right click in the project view and select New Project or from the main menu select File | New Project. Both will open the New Project dialog. In this dialog select the Enterprise node on the left and then the EJB Module on the right and click Next. Enter the project name, location and server. This also allows you to add this module to an Enterprise Application project if you wish. This can be very useful if you are making an enterprise project with all components contained in the same parent project. If you are adding this project to an Enterprise Application you do not need to put it in the Enterprise Application directory though it may prove easier to put it in the same directory for organization.

Working with EJBs and JBoss
Working with EJBs in NetBeans for JBoss is not really any different from working with any other server. You create and consume them the same way as any other targeted server. When I am developing both EJBs and Web Services I usually use the Sun Java System Application Server as the target and deploy the project manually, mostly because NetBeans will not compile a Web Service correctly with the JBoss server as the target.

Creating EJBs
To create an EJB you can use either the New | File/Folder from the main menu or use the context menu for the EJB Module by right clicking on the EJB Module. You can also select the specific bean type from the EJB Module, if it is in the list under the New option. If you selected the New File option you will get the New File dialog, select the Enterprise node on the left and the bean type on the right. This guide will walk through the creation of a Session Bean, though we will not be creating other beans they are created in the same manner though the information in the wizards is slightly different.

Session Beans
In the New Session Bean dialog enter the EJB name and the package name. You can also select the source location if you have multiple source locations setup in the project. Mark the correct session type and the interface types to create. If you are not going to be calling this bean from a remote server you only need to select the local interface, though I usually select both remote and local interfaces for flexibility just in case. For the guide I created a stateless EJB with the name NBJBossSession in the package com.nbjboss.ejb.session with both remote and local interfaces. This gives the following structure in the Projects view see Figure 3.

sessionejb1.jpg
Figure 3

As you can see this creates all the files needed for a remote interface as well as a local interface. You will also notice a NBJBossSessionSB node under the Enterprise Beans node with Remote Methods and Local Methods nodes. These nodes allow you to create new business methods for both the remote and local interfaces. That is all there is to creating an EJB.

Working with EJBs
Once you have an EJB created expand the Enterprise Beans node for the module you created the bean in. You will see the bean you created if you then expand the node you will see the interfaces you created for the bean. You can add a business method to the bean by right clicking on the bean and select Add | Business Method. This will bring up a dialog for adding the method information. Enter the method name, return type, which interface to add it to, and any parameters and exceptions for the method. For this example I used the simple sayHello business method with a String return type and String parameter named name. As you can see in Figure 4 it added the business method to the remote and local interfaces for me.

sessionejb2.jpg
Figure 4

You can access the business method by double clicking on the method name in either the remote or local interfaces and entering the logic, both of these nodes take you to the same file. The following is the code I added to the method for the sayHello logic.

    public String sayHello(java.lang.String name) {
        return "Hello " + name;
    }

Code 1

As you can see I simply returned the input name concatenated onto Hello.

Deploying and Testing
Once you have the logic you need in the EJB build the project to check for any errors, deploying will automatically build the module also. If you have JBoss setup as the target server you can right click on the module and select deploy to deploy it directly to JBoss.

Deploying
Before you deploy the first time you want to check the target server to insure the correct server is selected. If you followed the setup guide for NetBeans with JBoss the target server will likely be the Sun Java System Application Server and will need to be changed. To do this you need to right click on the EJB Module and select properties. Then select the Run node and make sure the server dropdown is set to the correct JBoss server see Figure 5.

targetserver.jpg
Figure 5

Once this is done you need to right click on the EJB Module and select Deploy Project. The server will be started and the project will be deployed. If the server is running outside of NetBeans you will get a deployment error so make sure you do not have a server running outside of NetBeans. If all goes well you can go to the server and get the default JBoss screen. If you are running locally use localhost:portfor the address. The Output tab on the bottom of NetBeans will also allow you to start, start in debug, restart, stop and refresh on the server at the appropriate times by using the icons on the left of the output tab for the target server.

Testing
For testing the EJB you will need to have something to call it. I will do it from a web page within a web application which will be a part of the NBJBossApplication project used as the parent to the NBJBossApplication-EJBModule. So create a Web Application by selecting New Project and selecting the Web node on the left of the dialog and Web Application on the right and select Next. Then enter the name NBJBossTestWebApplication, set the location to the NBJBossApplication directory and add it to the NBJBossApplication project and select Finish see Figure 6.

testwebapp.jpg
Figure 6

You will then have the default web application module created and opened as a project and need to make a call to the EJB. There are 2 ways NetBeans will write the code to cal the EJB for you. The first is through a Service Locator pattern from the J2EE design patterns. The second is to create a class to call the service from, right click in the class and select Enterprise Resource | Call Enterprise Bean. In the dialog select the NBJBossSessionBean, select remote or local interface and click OK. This will create the required code to do a lookup on the bean you selected. To call this from a JSP you will have to either add a wrapper method or change the method to public. The second method is only available to the EJB module project or a project within the same Enterprise Project. For this guide we will look at the first method though I included the JSP code for the second method below. Both methods use the remote interface to access the EJB.
Create a Service Locator by right clicking on the NBJBossTestApplication node and selecting New | File/Folder. On the right side select Enterprise and Service Locator from the list on the right. Name the Service Locator ServiceLocator and make the package com.nbjboss.util and click Finish see Figure 7.

servicelocator.jpg
Figure 7

Next you need to enter the code into the JSP. To do this Expand the project and the Web Pages node. You will see an index.jsp page there, open this and enter the following code just above the </body> tag. You may want to change the parameter from Dru unless your name is Dru also.

    <h4>Calling NBJBossSessionBean sayHello()</h4>
    <%
        com.nbjboss.util.ServiceLocator sl =
            new com.nbjboss.util.ServiceLocator();
        com.nbjboss.ejb.session.NBJBossSessionRemote bean =
                ((com.nbjboss.ejb.session.NBJBossSessionRemoteHome)
                sl.getRemoteHome("java:comp/env/ejb/NBJBossSessionBean",
                com.nbjboss.ejb.session.NBJBossSessionRemoteHome.class)).create();
        out.println(bean.sayHello("Dru"));
    %>

Code 2

Before you build the project you will need to add the EJB Module to the Libraries. To do this right click on the project and select Properties and select the Libraries node and click Add Project on the right. Browse to the EJB project and select Add Project JAR Files. If you are going to deploy this and the EJB Module to the same server you will need to uncheck the package button.

For the second method add the following code to the JSP and create a class as mentioned above.

    <h4>Calling NBJBossSessionBean sayHello()</h4>
    <%
        com.nbjboss.util.ServiceLookup sl =
            new com.nbjboss.util.ServiceLookup();
        com.nbjboss.ejb.session.NBJBossSessionRemote bean =
                sl.lookupNBJBossSessionBean();
        out.println(bean.sayHello("Dru"));
    %>

Code 3

Now we have the bean being called we need to get it deployed but we need to set the libs correctly. To do this right click on the project and select Properties in the properties dialog select the libraries node and uncheck the checkbox next to the NBJBossApplication-EJBModule. This will tell NetBeans not to include the EJB Module with the war file created for the test application if it is included you will get a class cast exception. Now if the EJB Module is still deployed simply deploy the NBJBossTestApplication. If not then deploy the NBJBossApplication-EJBModule first then deploy the Test Application. Another option is to deploy them both with the NBJBossApplication parent project. This is possible if the EJB Module and the Test Application are both included in the Enterprise Application project. To check to see if they are right click on the NBJBossApplication and select Properties then select the Packaging node under the Build node. This will list all the projects which are part of the parent project. Now point your browser to the server for the Test Application. If you have followed this guide and the server is local with port number 8080 then the address will be http://localhost:8080/NBJBossTestWebApplication/ make sure the port is correct for your installation.

Conclusion
NetBeans has setup the easiest way of working with EJBs of any IDE that I have seen and with the built in support for the servers it towers above any other IDE. Once you start working with EJBs in NetBeans you will see that the development is easy and consuming them is even easier. With the work that NetBeans has done with writing the code and XML for you it allows you the time to do the real work.
You can download the source for this project here.

NOTE: If you deployed the individual modules through NetBeans and attempt to deploy the Enterprise Project you will get an error. This is due to JBoss wanting to deploy the individual modules with the Enterprise Project which will cause duplicate deployments. To fix this go to the deploy directory of the server you are using and delete the module files before deploying the Enterprise Project. Also, please note that this will work if you are deploying to Sun Java System Application Server. All you need to do is to change the target to the Sun Java System Application Server and deploy.

NetBeans with JBoss Setup

Posted by ddevore on January 06, 2006 at 10:59 AM | Permalink | Comments (2)

This guide describes the setup necessary to setup NetBeans IDE 5.0 work with JBoss in preparation for developing EJBs and Web Services targeting the JBoss runtime. Once you have completed the instructions in this setup guide you will be able to create and consume EJBs and Web Services with the JBoss application server through NetBeans IDE 5.0. This will also allow you to do it all without doing any manual deployments to the JBoss application server. For more information on creating and consuming EJBs and Web Services for the JBoss server through NetBeans IDE 5.0, please see the other guides for NetBeans IDE 5.0 and JBoss.

At the time of writing this guide NetBeans IDE was in version 5.0 Beta. This guide was written using the latest development build #200601052030 to take advantage of the bug fixes since NetBeans IDE 5.0 went into beta. Also, NetBeans officially supports JBoss Application Server 4.0.3, but due to business requirements I have to use JBoss Application Server 4.0.1. So, this guide will walk through the JBoss Application Server 4.0.1 setup as well as the JBoss 4.0.3 setup.

Download Required Files
First you need to download the files needed for setup. You will need JDK 5.0, NetBeans IDE 5.0 (latest build), JBoss Application Server 4.0.3, and Sun Java System Application Server Platform Edition 8.1.

JDK 5.0
The latest JDK 5.0 can be downloaded from here http://java.sun.com/j2se/1.5.0/download.jsp. Download the latest update of the JDK. NOTE: Until NetBeans IDE 5.0 reaches final release, do not download the NetBeans IDE / JDK bundle from this page because the version of NetBeans IDE on this page is currently the final release version of NetBeans IDE 4.1. This document covers JBoss setup with NetBeans IDE 5.0 Beta version.

NetBeans IDE Version 5.0
The NetBeans 5.0 version IDE can be downloaded from the NetBeans web site at http://www.netbeans.info/downloads/download.php?a=n&p=1. You will need the latest daily build or release, which ever is newer for, version 5.0 or the 5.0 version once it has reached final release. Select the NetBeans IDE installer from the list.

JBoss Application Server 4.0.3sp1
The JBoss application server can be downloaded from SourceForge at http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=16942. Please select version JBoss version 4.0.3sp1. This guide may work with earlier versions of JBoss, but they have not been tested.

Sun Java System Application Server 8.1 Platform Edition
The Sun Java System Application Server 8.1 Platform Edition is needed to create services correctly since JBoss currently does not fully support JAX-RPC. This can be downloaded at http://java.sun.com/j2ee/1.4/download.html#sdk. Select the separate bundles Sun Java System Application Server Platform Edition 8.1 2005Q2 UR2.

Installation
Although the order of installation could be done alternatively, the suggested and easiest installation is too; install the JDK first then install the NetBeans IDE 5.0. Then, proceed to install the JBoss Application Server and Sun Java System Application Server. Make note of the admin name and password you enter when you install the Sun Java System Application Server. You will need the admin name and password when you register the application server in the NetBeans IDE a little later in this guide. If you are using the JBoss installer make sure you choose the all option A full J2EE server profile with enterprise extensions. Then select the options needed for your installation. For this guide the default options were selected.
NOTE: The JBoss installer is an executable jar file to run this file use
java jar jar_file_name

Setting Up Your Environment Setting up the environment is only needed if you plan to build the project outside the NetBeans environment. The environment setup shown here is geared toward the Windows platform. If you are using another operating system please make changes as appropriate. Also, the settings can all be set in the system properties. For setting the variables in the system properties go to the Control Panel and open the System dialog then go to the advanced tab and select Environment Variables. Here you can add the variables in the user or system variables.
To do this, set the environment variable ANT_HOME to the directory where you have Ant installed. If you have not installed Ant, then set ANT_HOME to <NETBEANS_INSTALL_DIR>\ide6\ant. Then add ANT_HOME\bin to your PATH environment variable. For my installation I have NetBeans installed in C:\Program Files\netbeans-5.0dev so for me the correct setting would be.

set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_05

set ANT_HOME= C:\Program Files\netbeans-5.0dev\ide6\ant set PATH=%PATH%;ANT_HOME\bin

If you have ant installed and would like to use it instead of the version provided by NetBeans change the ANT_HOME above appropriately.

NetBeans Setup
Once you have NetBeans started, go to the Runtime tab at the top of the navigation pane and expand the Servers node you will notice the only server listed is a bundled Tomcat server. Right click on the Servers node and select Add Server. This will by default select the Sun Java System Application Server as the server. Since that is one that we want to add click Next. Enter the location for the installation for the server in the next screen and click Next. Enter the proper information in the next screen for the admin name and password and click Finish. The admin name and password to enter here are the admin name and password you entered during the installation of the Sun Java System Application Server.

JBoss Server Setup
The JBoss setup about the same as the Sun Server setup, but because of the different server versions there are some things that must be considered when registering a JBoss Application Server with the NetBeans IDE. In the NetBeans IDE, first right click on the Server node in the runtime tab and select Add Server. Select JBoss Application Server 4.0.3 and click Next, since this is the only JBoss setup available you must select it no matter what version of JBoss you are using; again this has been tested with JBoss 4.0.3sp1 only. Enter the installation directory for the JBoss server such as c:\jboss-4.0.3sp1 and click Next. Select the domain; it defaults to 'default'. If you are using JBoss 4.0.3 the port number is read from the configuration file and put in the port field automatically and cannot be changed in the dialog. If you are using a JBoss installation previous to JBoss 4.0.3sp1 the configuration is not read in and will only work with the default settings. If you wish to change the port numbers for JBoss 4.0.3sp1, look in:

<JBOSS_INSTALLATION_DIR>\server\default\deploy\jbossweb-tomcat55.sar\server.xml

On line 12 you will see the definition for the JBoss port number,

Change the Connector Port to your desired port number. I suggest you change this port number or the Sun Java System Application Server port number because of conflicts with the listening port. By default, both JBoss and Sun Java System Application Server listen to port number 8080. If you are using a previous version of JBoss you cannot change the default port number if you are going to deploy directly from NetBeans. If you do not change the JBoss Application Server or Sun Application Server port number please be careful when deploying the applications since you may experience some unexpected behavior such as deployments not being successful. You need to be sure you do not have both application servers running at the same time if the ports are not changed on either server.
To save yourself some potential deployment issues with using JBoss version 4.0.3, it is easiest to change the JBoss port number via the JBoss server.xml file as described above.

Server Setup
About a month ago there were some changes which made changes to the server unnecessary. So what this means is that JBoss 4.0.3sp1 works out of the box. After the server is setup in NetBeans you can deploy and test with the JBoss 4.0.3sp1 server. Keep in mind though that JBoss 4.0.3sp1 does not support documentliteral correctly for web services so if you are developing web services please insure that you set them to rpcliteral.

Conclusion
This is all there is to the setup for working with NetBeans and JBoss. Once this is done you can create and consume EJBs and Web Services with the JBoss application server through NetBeans IDE 5.0. This will also allow you to do it all without doing any manual deployments to the JBoss application server. For more information on creating and consuming EJBs and Web Services for the JBoss server through NetBeans IDE 5.0, please see upcoming blogs for NetBeans IDE 5.0 and JBoss.

Next
EJB Creation and Consumption with NetBeans and JBoss



Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds