Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

spring - java.lang.NoSuchFieldError: INSTANCE

When trying to submit my topology through StormSubmitter, I am getting -

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

I am using Spring.

I am not initializing HttpClient in Spout/Bolt Constructor. Instead its initialized in constructor of a class that is being fetched from Spring Context in prepare() method of bolt

Code is structured as follows -

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);
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...