Java plugin - Irrelevant JARs are loaded and cause conflicts


I am creating a Java input plugin that uses '' and libraries from manticore-0.7.0-java are loaded into my plugin and cause conflicts.

After successful installation, when I try to use the plugin I get the following error:

[2021-05-06T09:38:47,640][FATAL][org.logstash.Logstash    ][main][4a185b63cbba2ea2d3e1b0a33bead708588ed3bb1e55cff5f78bf05ea03c034b] uncaught error (in thread main_logim_s3_4a185b63cbba2ea2d3e1b0a33bead708588ed3bb1e55cff5f78bf05ea03c034b)
    java.lang.BootstrapMethodError: bootstrap method initialization exception
Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type interface org.apache.http.Header; not a subtype of implementation type interface org.apache.http.NameValuePair

I understand I need to make sure I am using http-core >= 4.4.9 but I am.
To understand why it is failing, I added the following log statement:

log.atInfo().log("Header class location: [{}]", Class.forName("org.apache.http.Header").getProtectionDomain().getCodeSource().getLocation().getPath());

and the log shows:

Header class location: [/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/manticore-0.7.0-java/lib/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4.jar]

When I run logstash locally and use my plugin I see the following log message:

Header class location: [/C:/Users/melisha/.m2/repository/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4.jar]

How can I prevent those JARs to be loaded into my plugin? I would like only the plugin dependencies to be loaded. These are my gradle project dependencies:

dependencies {
        implementation 'org.apache.commons:commons-compress:1.20'
        implementation 'org.apache.logging.log4j:log4j-api:2.14.1'
        implementation 'org.apache.logging.log4j:log4j-core:2.14.1'
        implementation ''
        implementation fileTree(dir: LOGSTASH_CORE_PATH, include: "**/logstash-core-?.??.?.jar")

//    Adding the below dependencies does not help
//    implementation 'org.apache.httpcomponents:httpclient:4.5.13'
//    implementation 'org.apache.httpcomponents:httpcore:4.4.14'
//    implementation 'org.apache.httpcomponents:httpmime:4.5.13'

        testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
        testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.