title: configuring a cxf web service in jboss as 7
body: <p>I am developing a new web service. But I cannot seem to figure out the best way to set up the web service to deploy in jboss as 7.</p>
  
  <p>As per the jboss documentation, here is the web.xml.</p>
  
  <pre><code>&lt;web-app 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"
    version="2.5"&gt; 
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;testService&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sgb.testService.ws.web.TestService&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;testService&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p></p>
  
  <p>As per the jboss docs, it also needs a jboss-cxf.xml for all the configurations for cxf and spring.</p>
  
  <pre><code> &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:cxf="http://cxf.apache.org/core" 
  xmlns:jaxws="http://cxf.apache.org/jaxws" 
  xmlns:context="http://www.springframework.org/schema/context" 
  xmlns:wsa="http://cxf.apache.org/ws/addressing" 
  xmlns:http="http://cxf.apache.org/transports/http/configuration" 
  xmlns:sec="http://cxf.apache.org/configuration/security" 
  xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
   http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd 
   http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd 
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
   http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd "&gt;
  
  &lt;import resource="classpath:META-INF/cxf/cxf.xml" /&gt;
  &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&gt;
  &lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /&gt;
  
  &lt;!--  import spring application context configurations --&gt;
  &lt;import resource="classpath:META-INF/spring/applicationContext-ws.xml" /&gt;
  
  &lt;jaxws:endpoint id="testService" 
      implementor="com.sgb.testService.ws.web.TestService"
      address="/testService" &gt;
      &lt;!-- 
      address="http://localhost:8080/testService"&gt;
      --&gt;
      &lt;jaxws:properties&gt;
          &lt;entry key="schema-validation-enabled" value="true" /&gt;
      &lt;/jaxws:properties&gt;
      &lt;jaxws:invoker&gt;
          &lt;bean class="org.jboss.wsf.stack.cxf.InvokerJSE" /&gt;
      &lt;/jaxws:invoker&gt;
  &lt;/jaxws:endpoint&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the spring configurations are defined in the ApplicationContext-ws.xml here.</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:aop="http://www.springframework.org/schema/aop" 
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:jee="http://www.springframework.org/schema/jee" 
  xmlns:jaxws="http://cxf.apache.org/jaxws"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/aop      http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
      http://www.springframework.org/schema/context      http://www.springframework.org/schema/context/spring-context-3.1.xsd
      http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
      http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"&gt;
  
  &lt;context:property-placeholder location="classpath*:META-INF/spring/*.properties" /&gt;
  
  &lt;!--  
  import the common configurations from core sub-module
  which contains the declarations for Datasource, EntityManagerFactory &amp; PersistanceUnit 
  --&gt;
  &lt;import resource="applicationContext-core.xml" /&gt;
  &lt;import resource="applicationContext-jpa.xml" /&gt;
  
  
  &lt;!-- setting up multiple packages to scan for components --&gt;
  &lt;context:component-scan base-package="com.sgb.testService.ws.service" /&gt;
  
  
  &lt;!-- Declare the Transaction Manager --&gt;
  &lt;bean id="transactionManager" 
      class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  
  
  &lt;!-- declare transactions as annotation driven --&gt;
  &lt;tx:annotation-driven 
      transaction-manager="transactionManager" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Does the above look right?
  Am I missing anything?</p>
  
  <p>Specific Question:
  For deploying a cxf based web service in jboss AS 7, where does the spring beans configuration (ApplicationContext-ws.xml above) need to be defined?</p>
  
  <p>Can someone point me to a recent (2012) example or tutorial. Most of the examples I find online seem to be old and I cannot seem to find a proper tutorial  in the jboss or spring websites...</p>
  
  <p>Thank you.
  -SGB</p>
  
  <p>EDIT TO ADD:
  The error message seems to indicate that while deploying the war file, jboss is attempting to publish the wsdl to JBOSS_HOME/standalone/data/wsdl/TestService.war, but is failing as it cannot find the schema (xsd file).  This is a bit strange as bot the schema and wsdl is inside WEB-INF/wsdl/ directory.
  where 
  JBOSS_HOME = C:\Program Files (x86)\Apache Software Foundation\jboss-as-7.1.1.Final\</p>
  
  <p>ERROR MESSAGE:</p>
  
  <pre><code>15:56:09,146 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-4) Creating Service {http://www.sgb.com/Slm/ES
  /TestServiceIdentifier}TestServiceIdentifier from WSDL: WEB-INF/wsdl/TestService.wsdl
  15:56:09,238 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-4) Setting the server's publish address to be http://localhost:8080/eucl
  id-ws
  15:56:09,266 INFO  [org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher] (MSC service thread 1-4) WSDL published to: JBOSS_HOME/standalone/data/wsdl/testService-ws.war    /TestService.wsdl
  15:56:09,270 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."testService-ws.war".INSTA
  LL: org.jboss.msc.service.StartException in service jboss.deployment.unit."testService-ws.war".INSTALL: Failed to process phase INSTALL of deployment "eucl
  id-ws.war"
      at    org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_33]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_33]
      at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_33]
   Caused by: java.lang.RuntimeException: Cannot publish wsdl to: JBOSS_HOME\standalone\data\
  wsdl\testService-ws.war\TestService.wsdl
      at org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher.publishWsdlFiles(WSDLFilePublisher.java:107)
      at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.publishContractToFilesystem(EndpointImpl.java:222)
      at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.doPublish(EndpointImpl.java:93)
      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:117)
      at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:113)
      at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:66)
      at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.deploy(AspectDeploymentProcessor.java:74)
      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1
   .Final]
      ... 5 more
  Caused by: java.io.FileNotFoundException: JBOSS_HOME\standalone\data\wsdl\testService-ws.war\TestServiceIdentifier.xsd (The system cannot find the file specified)
      at java.io.FileInputStream.open(Native Method) [rt.jar:1.6.0_33]
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:120) [rt.jar:1.6.0_33]
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:79) [rt.jar:1.6.0_33]
      at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70) [rt.jar:1.6.0_33]
          at     sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161) [rt.jar:1.6.0_33]
          at java.net.URL.openStream(URL.java:1010) [rt.jar:1.6.0_33]
      at org.jboss.ws.common.utils.AbstractWSDLFilePublisher.publishSchemaImports(AbstractWSDLFilePublisher.java:243)
      at org.jboss.ws.common.utils.AbstractWSDLFilePublisher.publishSchemaImports(AbstractWSDLFilePublisher.java:250)
      at org.jboss.ws.common.utils.AbstractWSDLFilePublisher.publishSchemaImports(AbstractWSDLFilePublisher.java:250)
      at org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher.publishWsdlFiles(WSDLFilePublisher.java:94)
      ... 14 more
  
  15:56:09,343 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870:     Deploy of deployment "testService-ws.war" was rolled back with failure
   message {"JBAS014671: Failed services" =&gt; {"jboss.deployment.unit.\"testService-ws.war\".INSTALL" =&gt; "org.jboss.msc.service.StartException in service jbos
  s.deployment.unit.\"testService-ws.war\".INSTALL: Failed to process phase INSTALL of deployment \"testService-ws.war\""}}
  15:56:09,413 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment testService-ws.war in 70ms
  15:56:09,414 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2)     JBAS014774: Service status report
  JBAS014777:   Services which failed to start:      service jboss.deployment.unit."testService-ws.war".INSTALL: org.jboss.msc.service.StartException in serv
  ice jboss.deployment.unit."testService-ws.war".INSTALL: Failed to process phase INSTALL of deployment "testService-ws.war"
  
  15:56:09,421 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled ba
  ck. Steps that failed:" =&gt; {"Operation step-2" =&gt; {"JBAS014671: Failed services" =&gt; {"jboss.deployment.unit.\"testService-ws.war\".INSTALL" =&gt; "org.jboss.m
  sc.service.StartException in service jboss.deployment.unit.\"testService-ws.war\".INSTALL: Failed to process phase INSTALL of deployment \"testService-ws.war\""
  </code></pre>
  
  <p>}}}}</p>
  
  <p>From the above, the root cause seem to be this:</p>
  
  <pre><code>Caused by: java.io.FileNotFoundException: JBOSS_HOME\standalone\data\wsdl\testService-ws.war\TestServiceIdentifier.xsd (The system cannot find the file specified)
  </code></pre>
  
  <p>It seems like it is able to find the WSDL, but not the corresponding xsd which it uses which is available in the same directory as WSDL file.</p>