Skip to content

JAX-WS Metro instrumentation fails when Packet.getWSDLOperation() is null for Provider-based endpointsΒ #16553

@Adithya11811

Description

@Adithya11811

Metro OpenTelemetry Instrumentation crashes on JAX-WS Provider-based endpoints when Packet.getWSDLOperation() is null

Describe the bug

When using JAX-WS Provider-based endpoints (@WebServiceProvider) with Metro, the OpenTelemetry Metro instrumentation assumes that Packet.getWSDLOperation() always returns a non-null value.

However, for Provider-based services, Metro does not always resolve a WSDL operation during request dispatch β€” so Packet.getWSDLOperation() may legitimately return null.

The current instrumentation dereferences the returned value without a null check, which results in an exception during request handling.

This happens even when a WSDL is provided via wsdlLocation.

Provider endpoints bypass SEI method dispatch and instead operate on raw SOAP payloads, so the Metro runtime may skip operation resolution and leave Packet.wsdlOperation unset.

Steps to reproduce

  1. Create a minimal provider-based service
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
import java.io.StringReader;

@WebServiceProvider(
    serviceName = "HelloService",
    portName = "HelloPort",
    targetNamespace = "http://demo/"
)
@ServiceMode(Service.Mode.PAYLOAD)
public class HelloProvider implements Provider<Source> {

    @Override
    public Source invoke(Source request) {
        String response =
            "<ns2:helloResponse xmlns:ns2=\"http://demo/\">" +
            "<return>Hello</return>" +
            "</ns2:helloResponse>";
        return new StreamSource(new StringReader(response));
    }
}
  1. Publish the Endpoint:
import javax.xml.ws.Endpoint;

public class Server {

    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8080/hello", new HelloProvider());
    }
}
  1. Run with Opentelemetry javaagent

  2. Send SOAP request

curl -X POST http://localhost:8080/hello \ -H "Content-Type: text/xml" \ -d ' <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dem="http://demo/"> <soapenv:Header/> <soapenv:Body> <dem:hello/> </soapenv:Body> </soapenv:Envelope>

Expected behavior

The instrumentation should handle cases where Packet.getWSDLOperation() == null and still create a span with a fallback name such as jaxws.request or similar.

Instrumentation should not throw an exception during request processing.

Actual behavior

An exception occurs when the instrumentation tries to access the WSDL operation name

<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"><faultcode>S:Server</faultcode><faultstring>Cannot invoke "javax.xml.namespace.QName.getLocalPart()" because the return value of "com.sun.xml.ws.api.message.Packet.getWSDLOperation()" is null</faultstring></S:Fault></S:Body></S:Envelope>%

Javaagent or library instrumentation version

opentelemetry-javaagent: 2.x

Environment

Java: OpenJDK 21
OS: Linux (EndeavourOS)
Architecture: x86_64

Additional context

No response

Tip

React with πŸ‘ to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions