title: Unable to deploy JAX-WS as an OSGi bundle in Glassfish
body: <p>When I deploy a JAX-WS as a standard web application service through Glassfish everything works fine.</p>
  
  <p>The same JAR file is also an OSGi bundle (so a WAB).  If I try to install as an OSGi bundle, I get an error about the return property not being there for the response.  This is the web service class:</p>
  
  <pre><code>package org.example;
  
  import javax.jws.WebService;
  import javax.jws.WebMethod;
  import javax.xml.ws.ResponseWrapper;
  
  @WebService
  public class ExampleComponent {
     private String message = new String("Hello, ");
  
     public ExampleComponent() {
     }
  
     public String sayHello(String name) {
         return message + name + ".";
  
  
     }
  }
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <pre><code>javax.xml.ws.WebServiceException: class org.example.Wrapper do not have a property of the name return
  at com.sun.xml.ws.server.sei.EndpointResponseMessageBuilder$DocLit.&lt;init&gt;(EndpointResponseMessageBuilder.java:217)
  at com.sun.xml.ws.server.sei.TieHandler.createResponseMessageBuilder(TieHandler.java:210)
  at com.sun.xml.ws.server.sei.TieHandler.&lt;init&gt;(TieHandler.java:116)
  at com.sun.xml.ws.db.DatabindingImpl.&lt;init&gt;(DatabindingImpl.java:108)
  at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:74)
  at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:58)
  at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:130)
  at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:433)
  at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:268)
  at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:145)
  at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:569)
  at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:552)
  at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:623)
  at org.glassfish.webservices.WSServletContextListener.registerEndpoint(WSServletContextListener.java:282)
  at org.glassfish.webservices.WSServletContextListener.contextInitialized(WSServletContextListener.java:102)
  at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4750)
  at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:550)
  at org.apache.catalina.core.StandardContext.start(StandardContext.java:5366)
  at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
  at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
  at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
  at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
  at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
  at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
  at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
  at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
  at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
  at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
  at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
  at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
  at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
  at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
  at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
  at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
  at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
  at java.lang.Thread.run(Thread.java:680)
  Caused by: javax.xml.bind.JAXBException: return is not a valid property on class org.example.Wrapper
  at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:981)
  at com.sun.xml.ws.db.glassfish.JAXBRIContextWrapper.getElementPropertyAccessor(JAXBRIContextWrapper.java:121)
  at com.sun.xml.ws.server.sei.EndpointResponseMessageBuilder$DocLit.&lt;init&gt;(EndpointResponseMessageBuilder.java:214)
  ... 42 more
  </code></pre>
  
  <p>If I add the following annotations to the method and create a wrapper class, it kinda works:</p>
  
  <pre><code>@WebMethod
  @ResponseWrapper(className="org.example.Wrapper")
  </code></pre>
  
  <p>With these annotations, no errors on installation and I'm able to retrieve the WSDL.  However, the Tester doesn't work and I get this message from my browser:</p>
  
  <pre><code>Exceptions details : java.lang.RuntimeException: Cannot find the correct port class.
  javax.servlet.ServletException: java.lang.RuntimeException: Cannot find the correct port class. at
  org.glassfish.webservices.monitoring.WebServiceTesterServlet.initializePort(WebServiceTesterServlet.java:572) at 
  org.glassfish.webservices.monitoring.WebServiceTesterServlet.doGet(WebServiceTesterServlet.java:169) at 
  org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:104) at 
  org.glassfish.webservices.JAXWSServlet.doGet(JAXWSServlet.java:186) at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) at 
  javax.servlet.http.HttpServlet.service(HttpServlet.java:770) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542) at 
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at 
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at 
  org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at 
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331) at 
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at 
  com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317) at 
  com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849) 
  at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045) at 
  com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228) at 
  com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at 
  com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at 
  com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at 
  com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at 
  com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at 
  com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.RuntimeException: 
  Cannot find the correct port class. at org.glassfish.webservices.monitoring.WebServiceTesterServlet.initializePort(WebServiceTesterServlet.java:559) ... 29 more 
  </code></pre>
  
  <p>I would rather not have to add these annotations for each method and a wrapper class just to get things to work and even doing so, still not optimal.</p>
  
  <p><b>UPDATE:</b> Here's the WSDL file for this:</p>
  
  <pre><code> &lt;!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2-b13 (branches/2.2-6964; 2012-01-09T18:04:18+0000) JAXWS-RI/2.2.6-promoted-b20 JAXWS/2.2 svn-revision#unknown. --&gt;
   &lt;!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2-b13 (branches/2.2-6964; 2012-01-09T18:04:18+0000) JAXWS-RI/2.2.6-promoted-b20 JAXWS/2.2 svn-revision#unknown. --&gt;
   &lt;definitions targetNamespace="http://example.org/" name="ExampleComponentService"&gt;
     &lt;types&gt;
       &lt;xsd:schema&gt;
         &lt;xsd:import namespace="http://example.org/" schemaLocation="http://localhost:8080/test-jaxws/ExampleComponentService?xsd=1"/&gt;
       &lt;/xsd:schema&gt;
     &lt;/types&gt;
     &lt;message name="sayHello"&gt;
       &lt;part name="parameters" element="tns:sayHello"/&gt;
     &lt;/message&gt;
     &lt;message name="sayHelloResponse"&gt;
       &lt;part name="parameters" element="tns:sayHelloResponse"/&gt;
     &lt;/message&gt;
     &lt;portType name="ExampleComponent"&gt;
       &lt;operation name="sayHello"&gt;
         &lt;input wsam:Action="http://example.org/ExampleComponent/sayHelloRequest" message="tns:sayHello"/&gt;
         &lt;output wsam:Action="http://example.org/ExampleComponent/sayHelloResponse" message="tns:sayHelloResponse"/&gt;
       &lt;/operation&gt;
     &lt;/portType&gt;
     &lt;binding name="ExampleComponentPortBinding" type="tns:ExampleComponent"&gt;
       &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt; 
       &lt;operation name="sayHello"&gt;&lt;soap:operation soapAction=""/&gt;
         &lt;input&gt;
           &lt;soap:body use="literal"/&gt;
         &lt;/input&gt;
         &lt;output&gt;
           &lt;soap:body use="literal"/&gt;
         &lt;/output&gt;
       &lt;/operation&gt;
     &lt;/binding&gt;
     &lt;service name="ExampleComponentService"&gt;
       &lt;port name="ExampleComponentPort" binding="tns:ExampleComponentPortBinding"&gt;
         &lt;soap:address location="http://localhost:8080/test-jaxws/ExampleComponentService"/&gt;
       &lt;/port&gt;
     &lt;/service&gt;
   &lt;/definitions&gt;
  </code></pre>