0

I am new in Gradle. I am using my gradle with kotlin dsl script. When I execute using

gradle bootRun

Then it throw StackoverFlow error for log4J

Exception in thread "main" java.lang.StackOverflowError at java.lang.reflect.InvocationTargetException.(InvocationTargetException.java:72) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:110) at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:123) at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)

As Soon as I comment the implementation( "org.apache.jmeter:ApacheJMeter_core:5.0") from the build script, it doesn't throw any Error, what I should do? Please help.

Build.Gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile


plugins {
    java
    kotlin("jvm") version "1.3.11"
    "kotlin-spring"
    id("org.springframework.boot") version "2.1.1.RELEASE"
}

group = "org.kayd"
version = "1.0-DEV"

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib-jdk8"))
    implementation(kotlin("reflect"))
    implementation("org.apache.commons:commons-collections4:4.2")
    implementation("org.springframework.boot:spring-boot-starter:2.1.1.RELEASE")
    implementation( "org.apache.jmeter:ApacheJMeter_core:5.0")
//    implementation("org.apache.jmeter:ApacheJMeter_java:5.0")
//    implementation( "org.apache.jmeter:ApacheJMeter_http:5.0")
//    implementation( "org.antlr:antlr:3.1.3")
//    implementation( "org.json:json:20180813")
    testCompile("junit", "junit", "4.12")
}

configure<JavaPluginConvention> {
    sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}

Main Fun file

package org.kayd

import org.springframework.boot.Banner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication

@EnableConfigurationProperties
@SpringBootApplication
open class StartApplication

fun main(args: Array<String>) {
    runApplication<StartApplication>(*args) {
        setBannerMode(Banner.Mode.OFF)
        setLogStartupInfo(true)
    }
}

1 Answers1

0

If you list your project dependencies you will see that

So you're suffering from a form of a Jar Hell. You cannot reliably use 2 different versions of a same JAR in one application as the order of loaded classes in the CLASSPATH is a big question mark. Theoretically you can control this using a custom classloader however it might be an overkill for your project.

The easiest would be just removing your implementation("org.apache.commons:commons-collections4:4.2") dependency and re-write the impacted code to use Commons Collections 3 syntax.

Alternatively you will have to reconsider the way you're using JMeter in your application and go for one of the alternative JMeter execution options.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133