Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse - Part 2

In this second part of a blog series (part 1), I plan to explore the steps to develop/deploy/invoke a Web service on GlassFish using IntelliJIDEA IDE.

Searching in the help bundled with the IDE on "web service from Java" returned no results relevant to Web service. I found several (1,2,3) people asking "How do I develop Web service in IntelliJ 6.x?" but all the questions are unanswered. The online documentation does not seem to talk anything about Web service. Searching on gave no results. Finally I found some lead after searching in the forums but there is no help on "Enable Web Service Support" as mentioned in the post. Another response in the forum requires you to add @javax.jws.WebService manually, pretty primitive. So I decided to ask the question (1, 2) in the forum. 

After discussion in the forum I found that IntelliJ does not support creation of Web services natively but instead support it through a Web service plugin. The plugin, at the time of this writing is "0.6 build 2" with few skeptical comments but anyway worth a try. This plugin supports JWSDP 2.0 so first I'll investigate how Web services can be deployed on GlassFish and then come back to this plugin.

Here are the steps I followed to successfully build and deploy a Web service:

  1. Create a Web module (requires 12 clicks for default settings), say with name "hello". On Deployment Descriptors tab, select the default "Web Module Deployment Descriptor" and delete it as shown here. This is not required for deploying a Web service in GlassFish v2. Take all other defaults.
  2. In the "Project" pane, click on "src", add a new package "hello" as shown here.
  3. Select the package "hello", add a new class "Hello" as shown here.
  4. Click on the Project, right-click and select "Module Settings". Select the module and remove "j2ee.jar" as shown here. Add a new module library, javaee.jar, from GlassFish lib directory as shown here.
  5. Add @javax.jws.WebService annotation to the class and add a method as shown:

    public class Hello {
      public String sayHello(String name) {
        return "Hello " + name;
  6. Select "Build", "Make Project" (default shortcut Ctrl+F9).
  7. Configure and Run GlassFish v2 in IntelliJ. I added GlassFish v2 M4 using the following steps.
    1. Select "Run", "Edit Configurations ..." menu.
    2. Click on "+" in top-left corner to add a new configuration and then select "GlassFish Server" and "Local" as shown here.
    3. Specify the location of GlassFish by clicking on "Configure" button.
    4. Select the domain (default value "domain1";) in "GlassFish Server Settings".
    5. Add a new server by clicking on "+" in top-left corner and give the location where GlassFish is installed as shown here. Ignore the "There are no modules to deploy" warning as this will be fixed during Run. Now GlassFish is configured.
    6. To run the GlassFish instance
      1. Select "Run", "Run" (default shortcut Shift+F10) menu item. 
      2. Run configuration window displays the warning message "There are no modules to deploy". Go to "Deployment" tab and selecting the newly created module to deploy as shown here .
      3. Check "Deploy Web Module" check box and click "Configure" button and select "Create web module war file". A warning is displayed "Warning: 'Glassfish Web Module Deployment Descriptor' is not defined" as shown here. This message can be ignored as no GlassFish specific deployment descriptors are required.
      4. Click "Run" button.
  8. Once the GlassFish server has started, the endpoint is hosted at http://localhost:8080/hello/HelloService?wsdl.

The key point to note here is that no Deployment Descriptors (either standard or application serve specific) are required in the WAR file. The deployed WAR file in GlassFish consists only of the compiled class. 

The only way IDEA support creation of Web service clients is through Web Services plugin so I'll explore it in another blog. So the recommended way is to use NetBeans 5.5.1 to invoke the Web service.

Enjoy Web services deployed on GlassFish in IntelliJIDEA! And remember, GlassFish v2 uses Web Services Interoperability Technology (WSIT) that gives you interoperable Web services with Microsoft .NET 3.0 framework.

Technorati: NetBeans IntelliJ Eclipse GlassFish Web service WSIT


[Trackback] As I mentioned in my previous post, here are the steps to develop/deploy/invoke a Web service using the Web Services plugin in IntelliJ IDEA. Thanks to AdvancedTools, author of the plugin, for helping me through this process. The Web service...

Posted by Arun Gupta's Blog on February 01, 2007 at 12:51 AM PST #

[Trackback] In this third and last part of a blog series (part 1 and part 2), I plan to explore the steps to develop/deploy/invoke a Web service on GlassFish using Eclipse IDE. Eclipse does not offer GlassFish as a a bundled...

Posted by Arun Gupta's Blog on February 05, 2007 at 01:18 AM PST #

During new module creation if one chooses deployment descriptor version to be 2.5 then javaee.jar is added automatically (and then no need to remove j2ee.jar manually) Besides, removal of deployment descriptor makes the created web module to be invalid JEE web application that will work in Glassfish only thus I do not recommend this action unless WORA is not needed.

Posted by AdvTools on February 08, 2007 at 07:49 PM PST #

[Trackback] As a follow up from a previous blog, the Web Services plugin in IntelliJIDEA now supports GlassFish v2. Here are the steps I followed to deploy the Web service on GlassFish: I updated the plugin version from "0.6 build 2"...

Posted by Arun Gupta's Blog on February 10, 2007 at 02:36 AM PST #

[Trackback] Interested in first-class support for GlassFish in IntelliJ IDEA ? Vote here. Since this is still a wish for IntelliJ developers, consider using NetBeans IDE that provide comprehensive support for GlassFish. Developing/deploying a Web service on GlassF...

Posted by Arun Gupta's Blog on May 01, 2007 at 12:19 PM PDT #

[Trackback] Het creeeren van een webservice in netbeans6 is een eitje, in ongeveer 5 stappen heb je al een simpele webservice. Ik vroeg mij af of ik dat ook zo makkelijk kan in idea6. Helaas moet ik concluderen dat dat toch niet zo makkelijk gaat. Doormiddel v...

Posted by Logic blog on October 14, 2007 at 05:53 AM PDT #

It will be nice if you write an article about intellij idea 7 + jax-ws 2.1 + glassfish (tomcat is much better), or is there something about them online already?

Posted by Thai Dang Vu on December 13, 2007 at 12:41 AM PST #

Posted by advtools on December 25, 2007 at 07:53 AM PST #

Hi Arun, thanks for this good tutorial. I have a question regarding the jax-ws SSL support, I configured my application server with SSL support and basic authentication. When running my client, I got this exception... Caused by: Any ideas? Any tutorial on accessing webservice from a secured server (SSL) with basic authentication? Thanks in advance.

Posted by cjbaldoza on February 05, 2008 at 06:43 PM PST #

Hello Sir,

I followed the screencast of creating and deploying web service using Eclipse on glassfish. It was very informative as i am new to it , thanks for that.

But when i am running my .jsp file on server ,the glassfish server gets started and it is throwing java.lang.NullPointerException . Do u have any idea why is it so.Please help me resolve this problem

thank you

Posted by Priyanka on October 23, 2008 at 03:53 PM PDT #

Hi Priyanka,

We really need more information to help you figure out why you're getting a NullPointerException. I suggest you post to the mailing list and we can try to help.

Posted by Rochelle Raccah on October 24, 2008 at 06:17 AM PDT #

Dear sir,
I want complete information regarding how to create deploy and run web service in eclipse europa using glassfish
specifically i need information regarding how to create webservice client for accessing web service

thank you

Posted by Kashmira on November 04, 2008 at 12:48 PM PST #

Kashmira, you can find more details at:

Posted by Arun Gupta on November 07, 2008 at 09:09 AM PST #

Enjoy Web services deployed on GlassFish in IntelliJIDEA! And remember, GlassFish v2 uses Web Services Interoperability Technology (WSIT) that gives you interoperable Web services with Microsoft .NET 3.0 framework.

Posted by BATTERY on November 27, 2008 at 08:50 AM PST #

Post a Comment:
Comments are closed for this entry.

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« July 2016