简体   繁体   English

java.lang.NoSuchFieldError:INSTANCE

[英]java.lang.NoSuchFieldError: INSTANCE

When trying to submit my topology through StormSubmitter, I am getting - 当我尝试通过StormSubmitter提交我的拓扑时,我得到了 -

Caused by: java.lang.NoSuchFieldError: INSTANCE  
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)

I am using Spring. 我正在使用Spring。

I am not initializing HttpClient in Spout/Bolt Constructor. 我没有在Spout / Bolt构造函数中初始化HttpClient。 Instead its initialized in constructor of a class that is being fetched from Spring Context in prepare() method of bolt 相反,它在一个类的构造函数中初始化,该类是在Spring的prepare()方法中从Spring上获取的

Code is structured as follows - 代码结构如下 -

SomeBolt.java SomeBolt.java

@Component
public class SomeBolt extends BaseRichBolt {
    private OutputCollector _collector;
    private SomeClient someClient;

    @Override
    public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
        _collector = collector;
        someClient = AppContext.getBean(SomeClient.class);
    }
}

SomeClient.java SomeClient.java

@Component
public class SomeClient {
    private final CloseableHttpClient httpClient;

    public SomeClient() {
        this.httpClient = (httpClient == null ? HttpClients.createDefault() : httpClient);
    }
}

AppContext.java AppContext.java

@Component
public class AppContext implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        AppContext.applicationContext = applicationContext;
    }

    public static <T> T getBean(Class<T> c) {
        return applicationContext.getBean(c);
    }
}

This is probably a dependency issue. 这可能是一个依赖问题。

It's a very unclear error message but I found something similar here: Hibernate NoSuchFieldError INSTANCE but only with Struts 1? 这是一个非常不清楚的错误消息,但我发现类似的东西: Hibernate NoSuchFieldError INSTANCE但只有Struts 1?

我遇到类似这样的问题,在我的类路径中有两个jar包含相同的类,httpcore-4.3和apache-httpcomponents-httpcore,我已经从类路径中删除了apache-httpcomponents-httpcore解决了这个问题。

Harsh is right its in the storm class path. 苛刻是风暴阶级的正确道路。

So what I did to make this work was remove the httpclient and httpcore that comes with storm and replaced them with newer version 4.3.3 and 4.3.2 respectively. 所以我做的工作就是删除风暴附带的httpclient和httpcore,分别用更新版本的4.3.3和4.3.2替换它们。 This changes the classpath the works/nimbus/supervisor uses to start. 这会更改works / nimbus / supervisor用于启动的类路径。 You can run storm classpath and it print the class path out. 您可以运行storm classpath并打印出类路径。

[nimbus ~]$ storm classpath
...../storm-0.8.2/lib/httpclient-4.3.3.jar:..../storm-0.8.2/lib/httpcore-4.3.2.jar.....

I am not sure this is a very good work around, I am not sure what part of storm uses this jar. 我不确定这是一个非常好的工作,我不确定风暴的哪一部分使用这个罐子。

if you look at the python storm code you see that it will put all jars in the storm root and storm/lib 如果你看一下python 风暴代码,你会发现它会把所有的jar放在暴风根和暴风/ lib中

def get_classpath(extrajars):
    ret = get_jars_full(STORM_DIR)
    ret.extend(get_jars_full(STORM_DIR + "/lib"))
    ret.extend(extrajars)
    return normclasspath(":".join(ret))

I had the below jar files in the path inside the plugin folder: 我在插件文件夹中的路径中有以下jar文件:
./var/lib/jenkins/plugins/build-pipeline-plugin/WEB-INF/lib/httpcore-4.2.1.jar ./var/lib/jenkins/plugins/build-pipeline-plugin/WEB-INF/lib/httpcore-4.2.1.jar
./var/lib/jenkins/plugins/git-client/WEB-INF/lib/httpcore-4.3.2.jar ./var/lib/jenkins/plugins/git-client/WEB-INF/lib/httpcore-4.3.2.jar
./var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/httpcore-4.2.4.jar ./var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/httpcore-4.2.4.jar

After, I removed the below file, it worked for me 之后,我删除了下面的文件,它对我有用
/var/lib/jenkins/plugins/build-pipeline-plugin/WEB-INF/lib/httpcore-4.2.1.jar /var/lib/jenkins/plugins/build-pipeline-plugin/WEB-INF/lib/httpcore-4.2.1.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM