1 Reply Latest reply on Nov 16, 2007 1:17 PM by Alessio Soldano

    WebServiceRef & HandlerChain annotations

    Bryan Brouckaert Newbie

      I think I found a bug with the way the HandlerChain annotation is implemented in JBossWS 2.0.1.SP2 on JBoss 4.2.2

      It happends when I use @HandlerChain in the following condition:
      1) A field in a Stateless Session Bean
      2) The type of the field is the port type
      3) The field is annotated with @WebServiceRef

      An example of the declaration:

      @HandlerChain(file = "MyWsClient_HandlerChains.xml")
      @WebServiceRef(name = "ws/MyWs", wsdlLocation = "META-INF/wsdl/MyWs.wsdl")
      private MyWsPort wsPort;
      


      In that case I get the following errror:
      Caused by: org.jboss.ws.WSException: Cannot resolve handler file 'be/egelke/MyWsClient_HandlerChains.xml' on javax.xml.ws.Service
       at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilder.getHandlerChainsMetaData(JAXWSMetaDataBuilder.java:235)
       at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegateImpl.java:150)
       at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:61)
       at javax.xml.ws.Service.<init>(Service.java:83)
       at javax.xml.ws.Service.create(Service.java:721)
       at org.jboss.ws.core.jaxws.client.ServiceObjectFactoryJAXWS.getObjectInstance(ServiceObjectFactoryJAXWS.java:135)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1273)
       at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1290)
       ... 143 more
      


      I did check the code and found the following on the line specified in the above exception:
      // Try the filename relative to class
      if (fileURL == null)
      {
       String filepath = filename;
       String packagePath = wsClass.getPackage().getName().replace('.', '/');
       String resourcePath = packagePath + "/" + filepath;
       while (filepath.startsWith("../"))
       {
       packagePath = packagePath.substring(0, packagePath.lastIndexOf("/"));
       filepath = filepath.substring(3);
       resourcePath = packagePath + "/" + filepath;
       }
       fileURL = wsClass.getClassLoader().getResource(resourcePath);
      }
      
      if (fileURL == null)
       throw new WSException("Cannot resolve handler file '" + filename + "' on " + wsClass.getName());
      


      As you can see, the above tries the load my handler file with the classloader from the javax.xml.ws.Service class. Obviously, my handler file can't be found.

      Is there a way that I can make it work or is this a bug or limitation?

      I did find some ways to get arround the problem, but all have there disadvantages:

      1) Replace the Port class of the field by the Service Client class: requires extra code which complicates unit testing.
      2) Specify the correct service implementation class: only available in JBoss 5.0