Creating a SOAP connection factory fails due to ClassCastException

Hi guys,

I wrote a Jira plugin that sends and receives data to/from a SOAP web service after certain IssueEvents occured. For this I wrote a simple SOAP client using javax.xml.soap to send a request via HTTP. This all works fine when I call and test the client directly but fails whenever I upload the plugin to my local Jira.

I get the following error when calling SOAPConnectionFactory.newInstance():

javax.xml.soap.SOAPException: 
	Unable to create SOAP connection factory: 
	com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory cannot be cast to javax.xml.soap.SOAPConnectionFactor

Does anyone know what to make of this? I’m relatively new to Jira development and especially web services.

Hello!

I also encountered a similar problem. Mine, also triggered by SOAPConnectionFactory.newInstance() was:

Unable to create SOAP connection factory: Provider com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory not found

My workaround was to add these in the pom.xml dependencies:

<dependency>
   <groupId>javax.xml.soap</groupId>
   <artifactId>javax.xml.soap-api</artifactId>
   <version>1.4.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
   <groupId>com.sun.xml.messaging.saaj</groupId>
   <artifactId>saaj-impl</artifactId>
   <version>1.4.0</version>
   <scope>compile</scope>
</dependency>

My jira version is 8.5.3 and jdk 11. I am having the same problem and adding those dependencies did not solve the issue. My project has the soap client as dependency in pom xml. so I have this separate soap client mvn project and there all code works without problem. but when I deploy the jira plugin then I get

Caused by: javax.xml.soap.SOAPException: Unable to create SOAP connection factory: Provider com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory not found

I believe I am missing something in my jira plugin pom. Any pointers would highly appreciated. I tried to add com.sun.* to Export-Package or Import-Package result did not change.

And when I check the obr file. Actually I can see that HttpSOAPConnectionFactory is in the right folder.

Have you tried:

  • atlas-clean
  • atlas-mvn eclipse:eclipse
  • atlas-package

as changes in the pom.xml file are not automatically updated.

I have been doing clean and package all the time. I like to deploy the plugin manually. And yes same exception.

Hmm okay.

I’m not really sure if this helps, but if you are using an IDE, make sure that your maven home directory is from the atlassian-plugin-sdk 's path and not a bundled maven.

Also, the atlas-mvn command sometimes seems to re-import maven dependencies that atlas-package doesn’t, so I’d try that as well.

Regarding the pom dependencies, my xml contains these:

<dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>jira-servicedesk-api</artifactId>
            <version>${jira.service.desk.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-runtime</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.soap</groupId>
            <artifactId>javax.xml.soap-api</artifactId>
            <version>1.4.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.4.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

I did not change my build part.

The issue is with JDK 11. The required packages were removed. You need to manually add them yourself in the pom or use jdk8.

https://www.studytonight.com/post/solved-unable-to-create-saaj-metafactory-provider-saajmetafactoryimpl-not-found