Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);     } } 
like image 817
Harsh Moorjani Avatar asked Feb 07 '14 08:02

Harsh Moorjani


2 Answers

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?

like image 80
K.C. Avatar answered Sep 23 '22 23:09

K.C.


I faced similar issue like this, In my class path there was two jar contains same class, httpcore-4.3 and apache-httpcomponents-httpcore, I have removed apache-httpcomponents-httpcore from class path solved the issue.

like image 37
abdul hameed basha Avatar answered Sep 22 '22 23:09

abdul hameed basha