Hello All, I am using CloudSolrClient with Spring boot Solr 1.5.18.RELEASE and Solr Version is Solr 4.10.3.
new CloudSolrClient.Builder().withZkHost(zkHosts).withZkChroot(solrProperties.getSolrZookeeperLocation()).build(); When I use Solr which comes wth CDH 5.16.1 default when I save a document I get follwing error : org.springframework.data.solr.UncategorizedSolrException: java.lang.ClassCastException: *java.lang.String cannot be cast to java.util.Map;* nested exception is org.apache.solr.client.solrj.SolrServerException: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:168) at org.springframework.data.solr.core.SolrTemplate.saveBeans(SolrTemplate.java:223) at com.solix.emailarchiving.email.solr.search.SolrTemplateWrapper.saveBeans(SolrTemplateWrapper.java:33) at com.solix.emailarchiving.email.solr.search.EmailSearchRepositoryImpl.saveEmails(EmailSearchRepositoryImpl.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy153.saveEmails(Unknown Source) at com.solix.emailarchiving.email.EmailSolrServiceImpl.saveEmails(EmailSolrServiceImpl.java:24) at com.solix.emailarchiving.email.EmailSolrServiceImpl$$FastClassBySpringCGLIB$$40f18538.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89) at com.solix.emailarchiving.annotation.ServiceTransactionAspect.beforeMethod(ServiceTransactionAspect.java:46) at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:643) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:632) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) at com.solix.emailarchiving.email.EmailSolrServiceImpl$$EnhancerBySpringCGLIB$$a84565b1.saveEmails(<generated>) at com.solix.emailarchiving.hbasetosolrsync.EmailsSync.sendEmailsToSolr(EmailsSync.java:157) at com.solix.emailarchiving.hbasetosolrsync.EmailsSync.syncMailsFromHbaseToSolr(EmailsSync.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) at com.solix.emailarchiving.hbasetosolrsync.EmailsSync$$EnhancerBySpringCGLIB$$2714482.syncMailsFromHbaseToSolr(<generated>) at com.solix.emailarchiving.hbasetosolrsync.HBaseToSolrEmailSyncConsumer.processEmailIdModels(HBaseToSolrEmailSyncConsumer.java:129) at com.solix.emailarchiving.hbasetosolrsync.HBaseToSolrEmailSyncConsumer.hbaseToSolrSyncListen(HBaseToSolrEmailSyncConsumer.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:181) at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:114) at org.springframework.kafka.listener.adapter.HandlerAdapter.invoke(HandlerAdapter.java:48) at org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:248) at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:80) at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:51) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:1001) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:981) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:932) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:801) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:689) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.solr.client.solrj.SolrServerException: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:1246) at org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:1073) at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:160) at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:106) at org.springframework.data.solr.core.SolrTemplate.lambda$saveBeans$3(SolrTemplate.java:223) at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:164) ... 66 more Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map at org.apache.solr.common.cloud.DocRouter.getRouteField(DocRouter.java:53) at org.apache.solr.common.cloud.CompositeIdRouter.sliceHash(CompositeIdRouter.java:46) at org.apache.solr.common.cloud.HashBasedRouter.getTargetSlice(HashBasedRouter.java:38) at org.apache.solr.client.solrj.request.UpdateRequest.getRoutes(UpdateRequest.java:262) at org.apache.solr.client.solrj.impl.CloudSolrClient.directUpdate(CloudSolrClient.java:771) at org.apache.solr.client.solrj.impl.CloudSolrClient.sendRequest(CloudSolrClient.java:1263) at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:1134) ... 71 more After dug little deeper and googling I came to know that issue is something related to router field in zookeepers *clusterstate.json* Info about my collection in clusterstate.json is "88_Exchange12_2":{ "shards":{"shard1":{ "range":"80000000-7fffffff", "state":"active", "replicas":{"core_node1":{ "state":"active", "core":"88_Exchange12_2_shard1_replica1", "node_name":"SEZ-DESK-047-Linux:8983_solr", "base_url":"http://SEZ-DESK-047-Linux:8983/solr", "leader":"true"}}}}, "maxShardsPerNode":"1", * "router":"compositeId",* "replicationFactor":"1", "autoAddReplicas":"false", *"routerSpec":{"name":"compositeId"}*}, Value in router field is expected to be like *"router":{"name":"compositeId"}. * hoewever it is getting stored incorrect and thus result into above ClassCastException. However when I use Apache Solr same version 4.10.3, "router" set with correct value. "92_S2R1_35":{ "replicationFactor":"1", "shards":{ "shard1":{ "range":"80000000-ffffffff", "state":"active", "replicas":{"core_node2":{ "core":"92_S2R1_35_shard1_replica1", "base_url":"http://172.52.110.44:8983/solr", "node_name":"172.52.110.44:8983_solr", "state":"down", "leader":"true"}}}, "shard2":{ "range":"0-7fffffff", "state":"active", "replicas":{}}}, * "**router":{"name":"compositeId"}**,* "maxShardsPerNode":"1", "autoAddReplicas":"false", "autoCreated":"true"} Q1. How to solve this. Can we set *router *programatically form java code? Q2. In CDH's clusterstate.json we can see one more field named *'routerSpec' *which has correct value, but i think its not getting used. Is there a way to use this field as router and get the work done?