Step by Step tutorial to create a JAX-WS with Eclipse, CXF and Glassfish V3

Creating a JAX-WS under eclipse is not a big problem when using Tomcat. According to CXF developers, deploying a JAX-WS under glassfish SHOULD not be a problem, however, when using glassfish, things does not work as expected. Not because glassfish and CXF are not compatible, but because some steps or extra steps were made wrong. This step by step tutorial should show how to create a JAX-WS with Eclipse and Glassfish.Create a Dynamic Web Project in eclipse.

    • CXF 2.x Web Services
    • Dynamic Web Module
    • Glassfish Deployment description Files
    • Java

Figure 1

On the configuration Panel, click on modify and select the following options (also shown in figure 2):

Figure 2

Figure 2

When finished, click ok à and then finish. A project structure as showed in figure 3 would be created.

Figure 3

Create a Web Service interface and an implementation class of your web Service.

Figure 4

Once all the classes are implemented, right click on the implementation class of the Service and go to-> new ->Others -> Web Services -> Web Service and then click next.

Figure 5

A web service wizard will be started. In this tutorial we will create a Bottom up java Web Service. Your implementation class will be automatically selected. If not, select the implementation class in the Service Implementation tab. On the configuration console, please select the right deployment server (Glassfish) and the right Web Service Runtime environment.  (Normally an Apache Tomcat as well as Axis2 Runtime will be automatically selected; this must change as shown in figure 6). Once finished, click on next.

Figure 6

Click on Use Service Endpoint Interface and select your service endpoint interface (SEI) from your project. If you still don’t’ have one, the wizard could create one for you. Click next

Figure 7

Now select the JAX-WS annotation to be added to your Implementation class. Now, this step is really important. Only select @ WebMethod and @WebParam annotations. Selecting other ones will result that your Web Service my have some deployment difficulties or that the Web Service WSDL URL on the Glassfish Admin console (See figure 13) will not work properly. When finished, click next

Figure 8

Click only Generate Wrapper and Fault Beans.  You really don’t need the WSDL since it is regenerated automatically when deployed. Now click finish

Figure 8

The Wrapper classed and annotations will be generated and the project will be deployed into Glassfish

Figure 10

Now the service is deployed into Glassfish. Go to Glassfish admin console (http://localhost:4848) à Web Application and click on the ConverterEAR.?

Figure 11

A new window will be opened where are all deployed components are showed.

Figure 12

On the Action Tab (Aktion in the figure) please click on show. The new web site will have two links, one for the WSDL and the other for a test Site where the Web Service would be tested…

Figure 13

Author: Ahmed Al-Moayed

Share This Post On


  1. When deploying an ear file, the following exception may be thrown
    cannot Deploy ConverterEAR
    org.eclipse.core.runtime.CoreException: Deployment Error for module: ConverterEAR: Error during deployment : Extra bytes at the end of class file intf/jaxws/ConvertToCel%%%EOL%%%
    at com.sun.enterprise.jst.server.sunappsrv.SunAppServerBehaviour.
    at com.sun.enterprise.jst.server.sunappsrv.SunAppServerBehaviour.
    at com.sun.enterprise.jst.server.sunappsrv.SunAppServerBehaviour.
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publis
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publis
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publis
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publis
    at org.eclipse.wst.server.core.internal.Server.publishImpl(
    at org.eclipse.wst.server.core.internal.Server.publish(
    at org.eclipse.jface.operation.ModalContext$


    To resolve this, you have to stop the application server and delete the old deployment file under \glassfish\domains\domain1\eclipseApps. I really don’t know why, but sometimes when using the add and remove button in the Web Project, eclipse does not remove old deployed files correctly..

    Post a Reply
  2. Great tutorial. Thanks.

    Post a Reply
  3. Great!!!10 points!!!

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

× 1 = seven

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>