Hi,

As JBoss AS7 is very new And most powerful application server with many changes in it. Here we are going to see a very simple demo of how we can develop, build, deploy and test a simple WebService application in JBoss AS7

In this example we will mainly focus on following points

Point-1). What is the use of “standalone-preview.xml” file which is present inside the directory “/home/userone/jboss-as-7.0.1.Final/standalone/configuration”

Point-2). How to use the Ant Task “org.jboss.ws.tools.ant.WSProvideTask” to build our WebService and how to use the “org.jboss.ws.tools.ant.WSConsumeTask” ant task to generate the Client side artifacts.

Point-3). Also we will discuss a little about “*.dodeploy” file as well which is required for exploded directory deployment in AS7.

Point-4). Mainly we will see the classpath and path settings required while running the ANT script to build and test our webservice.

Point-5). How to use the @HandlerChain annotation and where exactly we are supposed to place the “handler-chain.xml” file.

So here we begin the Simple WebService development.

Step1). Create a directory somewhere in your filesystem like “/home/userone/TestWebServiceAS7” where we will place our webservice related stuffs to build. Then create another directory “src” inside “/home/userone/TestWebServiceAS7” where we will be placing our source codes and XML files which will be used by the WebService.

Step2). Create webservice class “HandlerWS.java” as following inside the “/home/userone/TestWebServiceAS7/src” directory.

package ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.HandlerChain;
import javax.annotation.Resource;
import javax.xml.ws.WebServiceContext;
import java.util.Collection;
@WebService(name = "HandlerDemoService", targetNamespace="http://test.org")
@HandlerChain(file="handler-chain.xml")
// Make sure that the "handler-chain.xml" file is placed just beside the compiled webservice class
// Example: "DemoHandlerService.war/WEB-INF/classes/ws" directory.

public class HandlerWS
{
  @Resource
  WebServiceContext ctx;
  @WebMethod()
  public String getProperty(String propertyName)
  {
    System.out.println("nnt Method Invoked....String getProperty(String propertyName)");
    return "RETURNED: "+(Collection) ctx.getMessageContext().values();
  }
}

Step3). As we want to use a simple “javax.xml.ws.handler.soap.SOAPHandler” inside our webservice so we will create “HandlerOne.java” handler class inside “/home/userone/TestWebServiceAS7/src” directory as following:

package ws;
import java.util.Set;
import java.util.Collections;
import javax.xml.namespace.QName;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPMessage;
public class HandlerOne implements SOAPHandler<SOAPMessageContext>
{
  public Set<QName> getHeaders()
  {
    return Collections.emptySet();
  }
  public boolean handleMessage(SOAPMessageContext messageContext)
  {
      System.out.println("nntHandler1-----handleMessage(SOAPMessageContext messageContext) called...");
      System.out.println("** Response: "+messageContext.getMessage().toString());
      return true;
  }
  public boolean handleFault(SOAPMessageContext messageContext)
  {
    return true;
  }
  public void close(MessageContext messageContext)
  {
  }
}

Step4). Now we will create the “handler-chain.xml” to specify what all handlers our webservice is going to use, Place this file as wll inside the “/home/userone/TestWebServiceAS7/src” directory as following:

<?xml version="1.0" encoding="UTF-8"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
  <handler-chain>
    <handler>
      <handler-class>ws.HandlerOne</handler-class>
    </handler>
  </handler-chain>
</handler-chains>

Step5). Now create a “web.xml” file deployment descriptor for our webapplication which is going to contain the above webservice description in it. Place the “web.xml” file inside “/home/userone/TestWebServiceAS7/src” directory as following:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <servlet>
    <servlet-name>HandlerDemoService</servlet-name>
    <servlet-class>ws.HandlerWS</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>HandlerDemoService</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>

Step6). Now create an empty file with name “DemoHandlerService.war.dodeploy” inside “/home/userone/TestWebServiceAS7/src” directory. The EMPTY ‘${war.name}.dodeploy’ tells JBoss AS7 to deploy the application, This file is needed if we want to deploy an exploded application in JBossAS7.

Step7). Now write a “TestClient.java” class as following inside “/home/userone/TestWebServiceAS7/src”, this will be our WebService client application to test the WebService as following:

package client;
import  java.net.URL;
public class TestClient
  {
     public static void main(String ar[]) throws Exception
      {
        String WSDL_URL=ar[0];
        HandlerWSService service=new HandlerWSService(new URL(WSDL_URL));
        HandlerDemoService port= service.getHandlerDemoServicePort();
        System.out.println("nt port.getProperty("something") = "+port.getProperty("something"));
      }
  }

Step7). Now the most important part, here we are going to develop “build.xml” ANT file, which will build, deploy and create clientside artifacts as wel as run the TestClient program for us, so write the following “build.xml” file inside “/home/userone/TestWebServiceAS7” directory.

<project name="JBoss_Service" default="build">
<property name="jboss.home" value="/home/userone/jboss-as-7.0.1.Final" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="war.name" value="DemoHandlerService.war" />
<property name="src.dir" value="src" />
<property name="client.src.dir" value="${basedir}/clientSrc" />
<property name="output.dir" value="build" />
<property name="client.dir" value="${basedir}/clientStuff" />
<property name="client.jar.name" value="HandlerDemoClient.jar" />

   <path id="jboss.classpath">
     <fileset dir="${jboss.module.dir}">
        <include name="**/*.jar"/>
     </fileset>
   </path>

   <path id="client.classpath">
     <fileset dir="${jboss.module.dir}">
        <include name="**/*.jar"/>
     </fileset>
     <fileset dir="${client.dir}">
        <include name="*.jar"/>
     </fileset>
   </path>

   <taskdef name="wsprovide" classname="org.jboss.ws.tools.ant.WSProvideTask">
       <classpath refid="jboss.classpath"/>
   </taskdef>

   <taskdef name="wsconsume" classname="org.jboss.ws.tools.ant.WSConsumeTask">
       <classpath refid="jboss.classpath"/>
   </taskdef>

        <target name="init">
           <delete dir="${output.dir}" />
           <mkdir dir="${output.dir}" />
           <mkdir dir="${output.dir}/${war.name}"/>
           <mkdir dir="${output.dir}/${war.name}/META-INF"/>
           <mkdir dir="${output.dir}/${war.name}/WEB-INF"/>
           <mkdir dir="${output.dir}/${war.name}/WEB-INF/classes"/>
           <delete dir="${client.dir}" />
           <mkdir dir="${client.dir}"/>
        </target>

    <target name="build" depends="init">
       <javac srcdir="${src.dir}" destdir="${output.dir}/${war.name}/WEB-INF/classes"  includes="*.java" excludes="TestClient.java" classpathref="jboss.classpath"/>
       <copy todir="${output.dir}/${war.name}/WEB-INF/classes/ws">
	  <fileset dir="${basedir}/src">
	      <include name="handler-chain.xml"/>
	  </fileset>
	</copy>
       <copy todir="${output.dir}/${war.name}/WEB-INF">
	  <fileset dir="${basedir}/src">
	      <include name="web.xml"/>
	  </fileset>
	</copy>
       <wsprovide
        	fork="false"
        	keep="true"
        	destdir="${output.dir}"
        	resourcedestdir="${output.dir}/${war.name}/WEB-INF/wsdl"
        	sourcedestdir="${output.dir}"
        	genwsdl="true"
        	verbose="true"
        	sei="ws.HandlerWS">
            	<classpath>
                	  <pathelement path="${output.dir}/${war.name}/WEB-INF/classes"/>
            	</classpath>
      </wsprovide>
    </target>

        <target name="deploy">
            <echo message="*******************  Deploying   *********************" />
            <echo message="********** ${war.name} to ${jboss.home}/standalone/deployments **********" />
            <copy todir="${jboss.home}/standalone/deployments/">
                <fileset dir="${output.dir}/">
                  <include name="${war.name}/**"/>
                </fileset>
            </copy>
            <echo message="The EMPTY '${war.name}.dodeploy' tells JBoss AS7 to deploy the application"/>
            <echo message="This file is needed if we want to deploy an exploded application in JBossAS7"/>
            <copy todir="${jboss.home}/standalone/deployments/">
	        <fileset dir="${basedir}/src">
	          <include name="${war.name}.dodeploy"/>
	        </fileset>
	    </copy>
            <echo message="*******************  Deployed Successfully   *********************" />
        </target>

        <target name="post-deploy" depends="deploy">
            <echo message="*******************  NOTE  *********************" />
            <echo message="***** You should be able to access your WSDL using Browser now *****" />
            <echo message="                 http://localhost:8080/DemoHandlerService?wsdl          " />
        </target>

        <target name="client" depends="post-deploy">
             <wsconsume
                      fork="true"
                      keep="true"
                      destdir="${client.dir}"
                      sourcedestdir="${client.dir}"
                      package="client"
                      wsdlLocation="service.wsdl"
                      wsdl="http://localhost:8080/DemoHandlerService?wsdl">
            </wsconsume>
            <jar jarfile="${client.dir}/${client.jar.name}" basedir="${client.dir}" compress="true" />
       </target>

        <target name="run" depends="client">
            <javac srcdir="${src.dir}" destdir="${client.dir}"  includes="TestClient.java" classpathref="client.classpath"/>
            <java classname="client.TestClient"  >
	        <classpath>
	            <pathelement location="${client.dir}"/>
	            <path refid="client.classpath"/>
	        </classpath>
                <arg value="http://localhost:8080/DemoHandlerService?wsdl"/>
            </java>
        </target>
</project>

NOTE: The only change in the above file you need to do is to change the “jboss.home” directory path in the second line of the above script
to point to your own JBoss AS7 directory.

Step8). Now before running your ANT script to build and deploy the above webservice you should have the ANT as well as JAVA set in the $PATH variable of the Shell / command prompt as following:

For Unix Based OS:
export PATH=/home/userone/jdk1.6.0_21/bin:/home/userone/org.apache.ant_1.6.5/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.6.5/bin;%PATH%

Step9). Now once the PATH is set In the command/Shell prompt you can move inside the directory “/home/userone/TestWebServiceAS7” and then run the ant to build the webservice. by running the command “ant build”

ant build

Buildfile: build.xml
init:
    [mkdir] Created dir: /home/userone/TestWebServiceAS7/build
    [mkdir] Created dir: /home/userone/TestWebServiceAS7/build/DemoHandlerService.war
    [mkdir] Created dir: /home/userone/TestWebServiceAS7/build/DemoHandlerService.war/META-INF
    [mkdir] Created dir: /home/userone/TestWebServiceAS7/build/DemoHandlerService.war/WEB-INF
    [mkdir] Created dir: /home/userone/TestWebServiceAS7/build/DemoHandlerService.war/WEB-INF/classes
    [mkdir] Created dir: /home/userone/TestWebServiceAS7/clientStuff

build:
    [javac] Compiling 1 source file to /home/userone/TestWebServiceAS7/build/DemoHandlerService.war/WEB-INF/classes
     [copy] Copying 1 file to /home/userone/TestWebServiceAS7/build/DemoHandlerService.war/WEB-INF/classes/ws
     [copy] Copying 1 file to /home/userone/TestWebServiceAS7/build/DemoHandlerService.war/WEB-INF
[wsprovide] Generating from endpoint: ws.HandlerWS
[wsprovide] log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
[wsprovide] log4j:WARN Please initialize the log4j system properly.
[wsprovide] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[wsprovide] java2ws -s /home/userone/TestWebServiceAS7/build -classdir /home/userone/TestWebServiceAS7/build -d /home/userone/TestWebServiceAS7/build/DemoHandlerService.war/WEB-INF/wsdl -verbose -wsdl -cp :::::::: -wrapperbean -createxsdimports ws.HandlerWS
[wsprovide] java2ws - Apache CXF 2.4.1

Step10). Now to deploy and run the TestClient you can run the following command “ant run”

deploy:
     [echo] *******************  Deploying   *********************
     [echo] ********** DemoHandlerService.war to /home/userone/jboss-as-7.0.1.Final/standalone/deployments **********
     [copy] Copying 5 files to /home/userone/jboss-as-7.0.1.Final/standalone/deployments
     [echo] The EMPTY 'DemoHandlerService.war.dodeploy' tells JBoss AS7 to deploy the application
     [echo] This file is needed if we want to deploy an exploded application in JBossAS7
     [copy] Copying 1 file to /home/userone/jboss-as-7.0.1.Final/standalone/deployments
     [echo] *******************  Deployed Successfully   *********************

post-deploy:
     [echo] *******************  NOTE  *********************
     [echo] ***** You should be able to access your WSDL using Browser now *****
     [echo]                  http://localhost:8080/DemoHandlerService?wsdl

client:
[wsconsume] Consuming wsdl: http://localhost:8080/DemoHandlerService?wsdl
[wsconsume] log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
[wsconsume] log4j:WARN Please initialize the log4j system properly.
[wsconsume] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
      [jar] Building jar: /home/userone/TestWebServiceAS7/clientStuff/HandlerDemoClient.jar

run:
    [javac] Compiling 1 source file to /home/userone/TestWebServiceAS7/clientStuff
      Nov 3, 2011 1:49:45 AM client.HandlerWSService <clinit>
      INFO: Can not initialize the default wsdl from service.wsdl
      log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
      log4j:WARN Please initialize the log4j system properly.
      log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

      	 port.getProperty("something") = RETURNED: [{http://test.org}HandlerDemoServicePort, [MessageInfo INPUT: {http://test.org}getProperty], {Accept=[*/*], cache-control=[no-cache], connection=[keep-alive], Content-Length=[194], content-type=, host=[localhost:8080], pragma=[no-cache], SOAPAction=[""], user-agent=[Apache CXF 2.4.1]}, null, stem, http://localhost:8080/DemoHandlerService, {http://test.org}HandlerDemoService, /DemoHandlerService, org.apache.catalina.connector.RequestFacade@2991d3fe, null, org.apache.catalina.core.StandardWrapperFacade@4c81ff8e, */*, [], /DemoHandlerService, /DemoHandlerService/, {http://test.org}HandlerWSService, [], [org.apache.cxf.transport.https.CertConstraintsInterceptor@481beb90], UTF-8, null, org.jboss.wsf.stack.cxf.HttpServletResponseExt@6ab0eadf, org.apache.cxf.transport.http.AbstractHTTPDestination$2@50c0d32, true, null, true, POST, true, {http://test.org}getProperty, org.apache.cxf.transport.servlet.ServletDestination@23cbb431, false, http://localhost:8080/DemoHandlerService?wsdl, {}, org.apache.cxf.service.model.BindingMessageInfo@12a30f53, org.apache.catalina.core.ApplicationContextFacade@f431bb4, text/xml; charset=UTF-8]

Some Issues which you may face

Issue-1).

Classpath might not be set properly so you may see the following kind of exception:

build.xml:27: taskdef class org.jboss.ws.tools.ant.WSProvideTask cannot be found
OR
build.xml:27: taskdef class org.jboss.ws.tools.ant.WSConsumeTask cannot be found

So make sure that the JAR “jboss-as-7.0.1.Final/modules/org/jboss/ws/tools/common/main/jbossws-common-tools-1.0.0.Beta1.jar” is added in the classpath or better if you include the CLasspath setting in your ant file like following to include all the required JARs present inside the “modules” directory of JBoss:

   <property name="jboss.module.dir" value="/home/userone/jboss-as-7.0.1.Final/modules" />
   <path id="jboss.classpath">
     <fileset dir="${jboss.module.dir}">
        <include name="**/*.jar"/>
     </fileset>
   </path>

Issue-2).

While deploying your above webservice on JBoss AS7 you may see following kind of Exception trace:

 11:33:20,677 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) Starting deployment of "DemoHandlerService.war"
11:33:20,697 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) added javax.persistence.api dependency to DemoHandlerService.war
11:33:20,703 WARN  [org.jboss.as.ee.component.ResourceInjectionAnnotationParsingProcessor] (MSC service thread 1-3) Can't handle @Resource for ENC name: ws.HandlerWS/ctx on class ws.HandlerWS since it's missing a "lookup" (or "mappedName") value and isn't of any known type
11:33:20,743 INFO  [org.jboss.web] (MSC service thread 1-8) registering web context: /DemoHandlerService
11:33:20,776 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "DemoHandlerService.war"
11:33:45,070 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/DemoHandlerService]] (http-localhost-127.0.0.1-8080-1) Marking servlet HandlerDemoService as unavailable
11:33:45,070 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/DemoHandlerService].[HandlerDemoService]] (http-localhost-127.0.0.1-8080-1) Allocate exception for servlet HandlerDemoService: java.lang.ClassCastException: ws.HandlerWS cannot be cast to javax.servlet.Servlet
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1156) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
	at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
	at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]

11:33:45,841 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) Stopped deployment DemoHandlerService.war in 27ms
11:33:45,843 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) Starting deployment of "DemoHandlerService.war"
11:33:45,852 INFO  [org.jboss.as.jpa] (MSC service thread 1-5) added javax.persistence.api dependency to DemoHandlerService.war
11:33:45,857 WARN  [org.jboss.as.ee.component.ResourceInjectionAnnotationParsingProcessor] (MSC service thread 1-5) Can't handle @Resource for ENC name: ws.HandlerWS/ctx on class ws.HandlerWS since it's missing a "lookup" (or "mappedName") value and isn't of any known type
11:33:45,915 INFO  [org.jboss.web] (MSC service thread 1-4) registering web context: /DemoHandlerService
11:33:45,960 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Replaced deployment "DemoHandlerService.war" with deployment "DemoHandlerService.war"

The above exception is an indication that the required WebService stack might not be loaded in yur JBoss Profile. So we will need to make sure that to start the JBoss AS7 we use the “standalone-preview.xml” rather than using “standalone.xml”, Because the “standalone-preview.xml” file has the configuration to load the WebService Stack of JBoss.
So make sure that you start your JBoss like following from directory “jboss-as-7.0.1.Final/bin”:

./standalone.sh --server-config=standalone-preview.xml

Issue-3).

If you have not placed the “handler-chain.xml” file at the right place then you may see following kind of Exception while deploying your WebService which uses @HandlerChain annotation:

11:40:44,656 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.unit."DemoHandlerService.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."DemoHandlerService.war".INSTALL: Failed to process phase INSTALL of deployment "DemoHandlerService.war"
	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
	at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_21]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_21]
	at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]
Caused by: javax.xml.ws.WebServiceException: javax.xml.ws.WebServiceException: Could not find the handler configuration file handler-chain.xml specified by @HandlerChain annotation
	at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)
	at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.doPublish(EndpointImpl.java:88)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509)
	at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:116)
	at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:109)
	at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:132)
	at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.internalDeploy(AspectDeploymentProcessor.java:79)
	at org.jboss.as.webservices.deployers.TCCLDeploymentProcessor.deploy(TCCLDeploymentProcessor.java:42)
	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)
	... 5 more
Caused by: javax.xml.ws.WebServiceException: Could not find the handler configuration file handler-chain.xml specified by @HandlerChain annotation
	at org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder.buildHandlerChainFromClass(AnnotationHandlerChainBuilder.java:88)
	at org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder.buildHandlerChainFromClass(AnnotationHandlerChainBuilder.java:284)
	at org.apache.cxf.jaxws.JaxWsServerFactoryBean.buildHandlerChain(JaxWsServerFactoryBean.java:237)
	at org.apache.cxf.jaxws.JaxWsServerFactoryBean.initializeResourcesAndHandlerChain(JaxWsServerFactoryBean.java:216)
	at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:203)
	at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433)
	at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322)
	... 14 more

11:40:44,889 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployment of "DemoHandlerService.war" was rolled back with failure message {"Failed services" => {"jboss.deployment.unit."DemoHandlerService.war".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit."DemoHandlerService.war".INSTALL: Failed to process phase INSTALL of deployment "DemoHandlerService.war""},"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.DemoHandlerService.DemoHandlerService.DemoHandlerService.Validator missing [ jboss.naming.context.java.module.DemoHandlerService.DemoHandlerService ]","jboss.naming.context.java.comp.DemoHandlerService.DemoHandlerService.DemoHandlerService.ValidatorFactory missing [ jboss.naming.context.java.module.DemoHandlerService.DemoHandlerService ]"]}
11:40:44,891 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) Stopped deployment DemoHandlerService.war in 3ms
11:40:44,893 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 2) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Failed services" => {"jboss.deployment.unit."DemoHandlerService.war".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit."DemoHandlerService.war".INSTALL: Failed to process phase INSTALL of deployment "DemoHandlerService.war""},"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.DemoHandlerService.DemoHandlerService.DemoHandlerService.Validator missing [ jboss.naming.context.java.module.DemoHandlerService.DemoHandlerService ]","jboss.naming.context.java.comp.DemoHandlerService.DemoHandlerService.DemoHandlerService.ValidatorFactory missing [ jboss.naming.context.java.module.DemoHandlerService.DemoHandlerService ]"]}}}

So to avoid the above kind of Exception make sure that the “handler-chain.xml” file is placed just beside the compiled webservice class. In this case Example: “DemoHandlerService.war/WEB-INF/classes/ws” directory.
.
.
Thanks
Middleware Magic Team

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.