【问题标题】:Stackoverflow error when uses Apache Jmeter Core使用 Apache Jmeter Core 时出现 Stackoverflow 错误
【发布时间】:2019-05-22 18:22:08
【问题描述】:

我是 Gradle 的新手。我正在将我的 gradle 与 kotlin dsl 脚本一起使用。当我使用

执行时

gradle bootRun

然后它会为 log4J 抛出 StackoverFlow 错误

线程“主”java.lang.StackOverflowError 中的异常 java.lang.reflect.InvocationTargetException.(InvocationTargetException.java:72) 在 sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:110) 在 org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:123) 在 org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)

只要我从构建脚本中评论 implementation("org.apache.jmeter:ApacheJMeter_core:5.0") ,它就不会抛出任何错误,我该怎么办?请帮忙。

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"
}

主要趣味文件

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)
    }
}

【问题讨论】:

    标签: spring-boot gradle kotlin jmeter gradle-kotlin-dsl


    【解决方案1】:

    如果你list your project dependencies你会看到

    因此,您遇到了Jar Hell 的一种形式。您不能在一个应用程序中可靠地使用同一 JAR 的 2 个不同版本,因为 CLASSPATH 中加载的类的顺序是一个很大的问号。从理论上讲,您可以使用custom classloader 来控制它,但是这对您的项目来说可能有点过头了。

    最简单的方法是删除您的 implementation("org.apache.commons:commons-collections4:4.2") 依赖项并重新编写受影响的代码以使用 Commons Collections 3 syntax

    或者,您将不得不重新考虑在应用程序中使用 JMeter 的方式并选择one of the alternative JMeter execution options

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-06
      相关资源
      最近更新 更多