ClassCastException MappingMetaData - Java

Hey,

I'm writing a Java application wicht reads all fields from my index at startup.

Since I updated to EL 7.6.1 I get the following error:

java.lang.ClassCastException: org.elasticsearch.cluster.metadata.MappingMetadata cannot be cast to org.elasticsearch.cluster.metadata.MappingMetaData
    at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.getAllFields(ElasticDBPersistanceImpl.java:251) ~[classes/:?]
    at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.findQueryField(ElasticDBPersistanceImpl.java:226) ~[classes/:?]
    at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.getFieldDataDistict(ElasticDBPersistanceImpl.java:163) ~[classes/:?]
    at com.initka.bprocess.hforms_formlist.startup.FormListSecurityServiceImpl.getTemplateIds(FormListSecurityServiceImpl.java:40) ~[classes/:?]
    at com.initka.bprocess.hforms_formlist.startup.FormListSecurityServiceImpl.<init>(FormListSecurityServiceImpl.java:21) ~[classes/:?]
    at com.initka.bprocess.hforms_formlist.startup.HformsFormlistFactoryImpl.<init>(HformsFormlistFactoryImpl.java:55) ~[classes/:?]
    at com.initka.bprocess.hforms_formlist.startup.Booter.startTenant(Booter.java:70) ~[classes/:?]
    at com.initka.bprocess.hforms_formlist.startup.Booter.lambda$0(Booter.java:45) ~[classes/:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

The code I'm using is provided through the documentation and could be found here:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-get-mappings.html

I have modificated it a little bit and in my application it looks like:

GetMappingsResponse mapping1 = dbManager.getFormlistDBConnection().indices().getMapping(getMappingsRequest, RequestOptions.DEFAULT);
    Map<String, MappingMetaData> mappings2 = mapping1.mappings();
    MappingMetaData mappingMetaData = mappings2.get(indexName);
    Map<String, Object> sourceAsMap = mappingMetaData.getSourceAsMap();

I have searched a lot of time for this error and haven't found any solution. This is my first elasticsearch application. So any help on this would be nice.

Thanks in advance

After hours of searching it seems that it was a chaching problem with maven.

After deleting my local maven repo an reload the sources it seems to work now.

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