Umesh Awasthi
Umesh Awasthi

Reputation: 23587

superclass access check failed: class com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl

I am getting the following error while using spring-ws-core.3.1.1. This was working fine except we have upgraded our platform and require us to use Java 17 (previous version was build on Java 11). Here is the code calling external service.

customerRequestType = buildCustomerRequest(customerModel);
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement < CreateCustomerRequestType > jaxb = objectFactory.createCreateCustomerReques(customerRequestType);
JAXBElement < CreateCustomerResponseType > responseJaxb = (JAXBElement < CreateCustomerResponseType > ) customWebServiceTemplate.marshalSendAndReceive(jaxb);
CreateCustomerResponseType customerResponse = responseJaxb.getValue();

here is the Spring definition

<bean id="customWebServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    <constructor-arg ref="clientMessageFactory" />
    <property name="defaultUri" value="${vertex.service.create.customer.endpoint}" />
    <property name="marshaller" ref="customerJaxbMarshaller" />
    <property name="unmarshaller" ref="customerJaxbMarshaller" />
    <property name="messageSender">
        <bean class="org.springframework.ws.transport.http.HttpComponentsMessageSender">
            <property name="connectionTimeout" value="5000" />
            <property name="readTimeout" value="5000" />
        </bean>
    </property>
</bean>

There is complex logic or anything, while calling the external endpoint, this is what I can see in the error log

    "thrown": {
    "localizedMessage": "superclass access check failed: class com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl (in unnamed module @0x7045bf72) cannot access class com.sun.org.apache.xerces.internal.dom.DocumentImpl (in module java.xml) because module java.xml does not export com.sun.org.apache.xerces.internal.dom to unnamed module @0x7045bf72",
    "extendedStackTrace": [
        {
            "line": 106,
            "class": "com.sun.xml.messaging.saaj.soap.SOAPPartImpl",
            "file": "SOAPPartImpl.java",
            "method": "<init>"
        },
        {
            "line": 70,
            "class": "com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl",
            "file": "SOAPPart1_1Impl.java",
            "method": "<init>"
        },
        {
            "line": 96,
            "class": "com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl",
            "file": "Message1_1Impl.java",
            "method": "getSOAPPart"
        },
        {
            "line": 138,
            "class": "org.springframework.ws.soap.saaj.SaajSoapMessage",
            "file": "SaajSoapMessage.java",
            "method": "getEnvelope"
        },
        {
            "line": 38,
            "class": "org.springframework.ws.soap.AbstractSoapMessage",
            "file": "AbstractSoapMessage.java",
            "method": "getSoapBody"
        },
        {
            "line": 56,
            "class": "org.springframework.ws.soap.AbstractSoapMessage",
            "file": "AbstractSoapMessage.java",
            "method": "getPayloadResult"
        },
        {
            "line": 79,
            "class": "org.springframework.ws.support.MarshallingUtils",
            "file": "MarshallingUtils.java",
            "method": "marshal"
        },
        {
            "line": 402,
            "class": "org.springframework.ws.client.core.WebServiceTemplate$2",
            "file": "WebServiceTemplate.java",
            "method": "doWithMessage"
        },
        {
            "line": 572,
            "class": "org.springframework.ws.client.core.WebServiceTemplate",
            "file": "WebServiceTemplate.java",
            "method": "doSendAndReceive"
        },
        {
            "line": 542,
            "class": "org.springframework.ws.client.core.WebServiceTemplate",
            "file": "WebServiceTemplate.java",
            "method": "sendAndReceive"
        },
        {
            "line": 394,
            "class": "org.springframework.ws.client.core.WebServiceTemplate",
            "file": "WebServiceTemplate.java",
            "method": "marshalSendAndReceive"
        },
        {
            "line": 388,
            "class": "org.springframework.ws.client.core.WebServiceTemplate",
            "file": "WebServiceTemplate.java",
            "method": "marshalSendAndReceive"
        },
        {
            "line": 378,
            "class": "org.springframework.ws.client.core.WebServiceTemplate",
            "file": "WebServiceTemplate.java",
            "method": "marshalSendAndReceive"
        }

Since its a managed cloud environment, I have limited options while compiling the code or passing any additional parameter to JVM. Anyone have any idea what might be the RCA and what can be the corrective action to fix this issue?

Edit I am able to get some details on the error, this is what the original error look like

Method threw 'java.lang.IllegalAccessError' exception. Cannot evaluate org.springframework.ws.soap.saaj.SaajSoapMessage.toString()

This is thrown by MarshallingUtils class in Spring-WS. Here is the method

 public static void marshal(Marshaller marshaller, Object graph, WebServiceMessage message) throws IOException {
        if (marshaller instanceof MimeMarshaller && message instanceof MimeMessage) {
            MimeMarshaller mimeMarshaller = (MimeMarshaller)marshaller;
            MimeMessageContainer container = new MimeMessageContainer((MimeMessage)message);
            mimeMarshaller.marshal(graph, message.getPayloadResult(), container);
        } else {
            marshaller.marshal(graph, message.getPayloadResult());
        }

    }

 MimeMessageContainer container = new MimeMessageContainer((MimeMessage)message)

above line seems to create the issue when trying ti build the SOAP request

Upvotes: 1

Views: 2195

Answers (1)

Ramya Musunuru
Ramya Musunuru

Reputation: 471

This could be because of a missing dependency.

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.5.1</version>
</dependency>

Upvotes: 0

Related Questions