gpt4 book ai didi

java.lang.NoSuchFieldError : INSTANCE

转载 作者:IT老高 更新时间:2023-10-28 13:47:14 25 4
gpt4 key购买 nike

当尝试通过 StormSubmitter 提交我的拓扑时,我得到 -

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

我正在使用 Spring。

我没有在 Spout/Bolt 构造函数中初始化 HttpClient。相反,它在一个类的构造函数中初始化,该类在 prepare() 的 Bolt 方法中从 Spring 上下文中获取

代码结构如下-

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

@Component
public class SomeClient {
private final CloseableHttpClient httpClient;

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

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

最佳答案

这可能是一个依赖问题。

这是一个非常不清楚的错误消息,但我在这里发现了类似的内容: Hibernate NoSuchFieldError INSTANCE but only with Struts 1?

关于java.lang.NoSuchFieldError : INSTANCE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21622885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com