2

When I deploy a JAX-WS as a standard web application service through Glassfish everything works fine.

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:

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 + ".";


   }
}

This is the error I get:

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.<init>(EndpointResponseMessageBuilder.java:217)
at com.sun.xml.ws.server.sei.TieHandler.createResponseMessageBuilder(TieHandler.java:210)
at com.sun.xml.ws.server.sei.TieHandler.<init>(TieHandler.java:116)
at com.sun.xml.ws.db.DatabindingImpl.<init>(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.<init>(EndpointResponseMessageBuilder.java:214)
... 42 more

If I add the following annotations to the method and create a wrapper class, it kinda works:

@WebMethod
@ResponseWrapper(className="org.example.Wrapper")

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:

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 

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.

UPDATE: Here's the WSDL file for this:

 <!-- 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. -->
 <!-- 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. -->
 <definitions targetNamespace="http://example.org/" name="ExampleComponentService">
   <types>
     <xsd:schema>
       <xsd:import namespace="http://example.org/" schemaLocation="http://localhost:8080/test-jaxws/ExampleComponentService?xsd=1"/>
     </xsd:schema>
   </types>
   <message name="sayHello">
     <part name="parameters" element="tns:sayHello"/>
   </message>
   <message name="sayHelloResponse">
     <part name="parameters" element="tns:sayHelloResponse"/>
   </message>
   <portType name="ExampleComponent">
     <operation name="sayHello">
       <input wsam:Action="http://example.org/ExampleComponent/sayHelloRequest" message="tns:sayHello"/>
       <output wsam:Action="http://example.org/ExampleComponent/sayHelloResponse" message="tns:sayHelloResponse"/>
     </operation>
   </portType>
   <binding name="ExampleComponentPortBinding" type="tns:ExampleComponent">
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> 
     <operation name="sayHello"><soap:operation soapAction=""/>
       <input>
         <soap:body use="literal"/>
       </input>
       <output>
         <soap:body use="literal"/>
       </output>
     </operation>
   </binding>
   <service name="ExampleComponentService">
     <port name="ExampleComponentPort" binding="tns:ExampleComponentPortBinding">
       <soap:address location="http://localhost:8080/test-jaxws/ExampleComponentService"/>
     </port>
   </service>
 </definitions>
Dave H
  • 547
  • 1
  • 5
  • 16
  • Can you show me your wsdl file? – Paulius Matulionis Jun 13 '12 at 21:05
  • @PauliusMatulionis, I've added the WSDL file. – Dave H Jun 14 '12 at 12:23
  • I don't know what you are trying to do, but we have a test bundle that uses JAX-WS and it's working fine. You can find it here: https://svn.java.net/svn/glassfish~svn/trunk/fighterfish/test/testapp/test.app17 – sahoo Jun 14 '12 at 18:34
  • @sahoo, I am able to build the web app and it loads successfully just like mine, but the Tester parameter still doesn't work. I'm guessing there is something funky the Tester does with the class loader so it doesn't work as a bundle. – Dave H Jun 19 '12 at 18:26
  • @sahoo Me and the community would be very happy If you could update the link on your comment, because it isn't working anymore :( Thank you – Twimnox Nov 21 '16 at 10:10

2 Answers2

1

I'm not sure if this was your exact problem, but I had a similar exception when trying to deploy a simple test WebService. It had these exceptions at the bottom of the stack:

javax.xml.ws.WebServiceException: class com.test.AddResponse do not have a property of the name return
javax.xml.bind.JAXBException: return is not a valid property on class com.test.AddResponse

After looking at Sahoo's sample code I saw this in osgi.properties for their webservices test bundle:

# See http://java.net/jira/browse/GLASSFISH-16551 as to why the WAB needs to import JAXB classes
DynamicImport-Package=javax.xml.bind, javax.xml.bind.*

The link explains why the problem happens and that to work around it you may include those packages as dynamic imports.

che javara
  • 748
  • 1
  • 8
  • 18
0

I know that is no solution to your problem, but maybe you could have a look an http://cxf.apache.org/. CXF is a service framework specially for SOAP/REST webservices and works great with OSGi. Maybe this could solve your problems.

christian.vogel
  • 2,117
  • 18
  • 22
  • I looked at CXF, specifically the OSGi remote service implementation, but it seemed like it had a lot of dependencies and a bigger footprint than I was looking for. If I remember correctly, it requires a bunch of Spring bundles even though I'm using Glassfish and JSF. – Dave H Jun 19 '12 at 18:00
  • There are a lot of dependencies, thats true. But Apache bundled all these dependencies in just one bundle jar: http://cxf.apache.org/dosgi-releases.html. You only need the single bundle distribution. Thats enough. – christian.vogel Jun 19 '12 at 19:45