Annotated Web Services in JBoss

I recently recorded a flash demo of the creation—using annotations—of a web service for JBoss 4.2 using a pre-release of the new Eclipse IDE for Java EE Developers (the work-in-progress landing page is here). You can find the demo here.

Creating the web service is pretty easy.

I noticed that JBoss requires an entry in the web.xml file for the web service (to be honest, I’ve spent a little too much time away from this technology to know if this is typical of other application servers, or if there is a way to encourage JBoss to work without it). Rather than try to fumble my way through the bits and pieces that are required for an entry in web.xml, I instead just created a servlet. The process of creating the servlet creates entries in the deployment descriptor along with a skeleton of a servlet class.

In the next step, I deleted most of the code generated for the servlet class and reduced it to a simple POJO along the lines of:

import javax.jws.WebService;
public class Welcome {
    public String getGreeting(String name) {
        return "Hello " + name;

It’s pretty simplistic, but my intent is to show that building a web service is pretty easy, not build an actual interesting web service.

And that’s about it. The next step is to run it, which I do using the Servers view. Eclipse does a great job managing the servers. During the start up, JBoss reports that the web service has started and provides a URL for WSDL generated for it. In my demonstration, I use the Web Services Explorer to play a bit. I could just as easily used the WSDL to create a Java client using the New Web Service Client wizard.

One thing I learned in setting up the demonstration is that JBoss 4.2 (and 5.0) don’t run all that well with Java 6. When I attempted that, I wound up with a bunch of errors that just disappeared when I instead used a Java 5 JRE. Maybe it’s just me.

I’d love your feedback on the demo.

This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to Annotated Web Services in JBoss

  1. Genady Beryozkin says:

    Nice demo, but it takes a huge 47MB!How about disabling all the Vista effects?JBoss indeed doesn’t work well with Java6.

  2. Wayne says:

    I naively just rendered the demos at the highest possible quality. Even at the lowest quality, they look good, so I’m re-rendering them (I’ve done the Java one already and I’ll get the rest done early next week).Thanks.And my experience with “doesnt’ work well” is more like “doesn’t even start”.

  3. Erwin Reyns says:

    I am a newbie in Java who simply wanted to write a simple servlet . So , downloaded …
    – a recent version of Eclipse : 3.3.1
    – a recent version of JBOSS : 4.2.2-GA
    – a recent version of Sun JDK : 1.6.0_03

    I followed the tutorial up to the point where it is deployed and run : there things went wrong. Should I try JDK version 5 ?

  4. Wayne Beaton says:

    JBOSS doesn’t run on Java 6. You’ll have to download Java 1.5.

    FWIW, your best bet is to pose your question on the newsgroup, news://

    By posting on the newsgroup, you’ll have many eyes looking at your question, and you won’t have to wait for me to find a computer while I’m visiting my in-laws over the next week 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s