Miles to go …

January 31, 2007

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

Filed under: eclipse, netbeans, webservices — arungupta @ 5:12 pm

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 intellij.org 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:

    @WebService
    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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 3
  2. Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 1
  3. GlassFish v2 supported in IntelliJ Web Services Plugin
  4. TOTD #98: Create a Metro JAX-WS Web service using GlassFish Tools Bundle for Eclipse
  5. Getting Started with GlassFish in IntelliJ IDEA

14 Comments »

  1. [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…

    Comment by Arun Gupta's Blog — February 1, 2007 @ 8:51 am

  2. [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…

    Comment by Arun Gupta's Blog — February 5, 2007 @ 9:18 am

  3. 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.

    Comment by AdvTools — February 9, 2007 @ 3:49 am

  4. [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"…

    Comment by Arun Gupta's Blog — February 10, 2007 @ 10:36 am

  5. [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…

    Comment by Arun Gupta's Blog — May 1, 2007 @ 7:19 pm

  6. [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…

    Comment by Logic blog — October 14, 2007 @ 12:53 pm

  7. 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?

    Comment by Thai Dang Vu — December 13, 2007 @ 8:41 am

  8. http://youradvtools.blogspot.com/

    Comment by advtools — December 25, 2007 @ 3:53 pm

  9. 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: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:. Any ideas? Any tutorial on accessing webservice from a secured server (SSL) with basic authentication? Thanks in advance.

    Comment by cjbaldoza — February 6, 2008 @ 2:43 am

  10. 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

    Comment by Priyanka — October 23, 2008 @ 10:53 pm

  11. 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.

    Comment by Rochelle Raccah — October 24, 2008 @ 1:17 pm

  12. 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

    Comment by Kashmira — November 4, 2008 @ 8:48 pm

  13. Kashmira, you can find more details at:

    http://blogs.sun.com/arungupta/entry/creating_and_invoking_a_web2

    Comment by Arun Gupta — November 7, 2008 @ 5:09 pm

  14. 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.

    Comment by BATTERY — November 27, 2008 @ 4:50 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress