Home > Software engineering >  Spring boot application works with IntelliJ, however fails with NoSuchMethodError while running with
Spring boot application works with IntelliJ, however fails with NoSuchMethodError while running with

Time:08-16

My spring boot application works perfectly while executed from IntelliJ Idea, however when I try to run it with bootRun it complies, but throws NoSuchMethodError while executing.

build.gradle file is listed below.

plugins {
    id 'org.springframework.boot' version '2.6.3'
    id 'io.spring.dependency-management' version '1.0.12.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = "16"

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.github.salesforce-marketingcloud:fuelsdk:1.6.0'

    implementation 'org.springframework.boot:spring-boot-starter-web:2.7.2'
    compileOnly 'org.projectlombok:lombok:1.18.24'
    developmentOnly 'org.springframework.boot:spring-boot-devtools:2.7.2'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor:2.7.2'
    annotationProcessor 'org.projectlombok:lombok:1.18.24'

    testImplementation 'org.springframework.boot:spring-boot-starter-test:2.7.2'
}

tasks.named('test') {
    useJUnitPlatform()
}
targetCompatibility = JavaVersion.VERSION_16

Also the stacktrace of the error:

java.lang.NoSuchMethodError: 'org.codehaus.stax2.ri.EmptyIterator org.codehaus.stax2.ri.EmptyIterator.getInstance()'
    at com.ctc.wstx.sw.OutputElementBase.getPrefixes(OutputElementBase.java:358) ~[woodstox-core-asl-4.4.1.jar:4.4.1]
    at org.apache.cxf.staxutils.StaxUtils.writeStartElement(StaxUtils.java:789) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:737) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:701) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:625) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.interceptor.AbstractLoggingInterceptor.writePayload(AbstractLoggingInterceptor.java:168) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback.onClose(LoggingOutInterceptor.java:249) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:209) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:652) ~[cxf-rt-transports-http-3.1.2.jar:3.1.2]
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277) ~[cxf-core-3.1.2.jar:3.1.2]
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) ~[cxf-rt-frontend-simple-3.1.2.jar:3.1.2]
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139) ~[cxf-rt-frontend-jaxws-3.1.2.jar:3.1.2]
    at jdk.proxy3/jdk.proxy3.$Proxy88.retrieve(Unknown Source) ~[na:na]
    at com.exacttarget.fuelsdk.ETSoapObject.retrieve(ETSoapObject.java:350) ~[fuelsdk-1.6.0.jar:na]
    at com.exacttarget.fuelsdk.ETSoapObject.retrieve(ETSoapObject.java:173) ~[fuelsdk-1.6.0.jar:na]
    at com.exacttarget.fuelsdk.ETSoapObject.retrieve(ETSoapObject.java:149) ~[fuelsdk-1.6.0.jar:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at com.exacttarget.fuelsdk.ETClient.retrieve(ETClient.java:630) ~[fuelsdk-1.6.0.jar:na]
    at com.exacttarget.fuelsdk.ETClient.retrieve(ETClient.java:569) ~[fuelsdk-1.6.0.jar:na]
    at com.example.sfmcbackend.service.DERetrievalService.getDataExtensionByName(DERetrievalService.java:18) ~[main/:na]

I've checked the classpath both runtime and compile and all of the dependecies are there, as well as the dependency which is causing the error.

CodePudding user response:

The method which causes the error is this https://javadoc.io/doc/org.codehaus.woodstox/stax2-api/latest/index.html

Check the documentation for the version you're using, maybe there is no getInstance method in that version. I don't see any reference to that dependency in your gradle file, it is probably imported by one of your dependencies. I'm not an expert with gradle, but you can try the gradle equivalent for mvn tree to get all the infos. If you find out that the version does not have getInstance method, you can import it manually with excluding the version imported by your dependency.

Once again this a solution i used with maven, but i assume gradle offers similar functionnalities.

  • Related