2

In my spring-data-solr project, Im getting

org.springframework.data.solr.UncategorizedSolrException: Error from server at http://localhost:8983/solr/preauth: Expected mime type application/octet-stream but got text/html.

The URL that gets generated while any operation is wrong. It contains the core name twice.

The Stack Trace:

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /solr/preauth/preauth/select. Reason:
<pre>    Not Found</pre></p>
</body>
</html>

The solr url contains the core name "preauth" twice.

My dependency:

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>

My Configuration:

@Configuration
@EnableSolrRepositories(basePackages = { "com.abi.claimbook" }, multicoreSupport = true)
public class SolrConfig {

    @Value("${solr.claimbook.url}")
    private String host;

    @Bean
    public SolrClient solrClient() throws Exception {
    HttpSolrClientFactoryBean factory = new HttpSolrClientFactoryBean();
    factory.setUrl(host);
    factory.afterPropertiesSet();
    SolrClient client = factory.getSolrClient();
    return client;
    }

    @Bean
    public SolrTemplate solrTemplate(SolrClient solrClient) throws Exception {
    SolrTemplate solrTemplate = new SolrTemplate(solrClient);
    return solrTemplate;
    }

}

My Document bean:

@SolrDocument(solrCoreName = "preauth")
public class Preauth {

    @Id
    @Indexed
    @Field
    private Integer preauthId;

    @Indexed
    @Field
    private String patientName;

    @Indexed
    @Field
    private String alNumber;
    .....
 Getters and setters...
.....

My Repository:

public interface SolrPreauthRepository extends SolrCrudRepository<Preauth, Integer> {

}
Kazi
  • 113
  • 2
  • 13
  • 2
    that's a bug in the current implementation using multicore support. Please try disable the multicore support. For updates please see [DATASOLR-364](https://jira.spring.io/browse/DATASOLR-364) – Christoph Strobl Mar 03 '17 at 08:55

2 Answers2

3

This is due to a bug in the current version of Spring Data Solr.

A potential workaround is updating your Spring Boot version in your build script to a previous version where this isn't the case i.e v1.4.3.RELEASE.

Example for Gradle:

buildscript {
    ext {
        springBootVersion = '1.4.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

More bug info: https://jira.spring.io/browse/DATASOLR-364

mlapointe22
  • 181
  • 1
  • 6
1

it is a known bug. they have fixed it but it is not released yet. you can use a snapshot release:

repositories {
    maven { 
        url "https://repo.spring.io/libs-snapshot" 
    }
}


dependencies {
    compile('org.springframework.data:spring-data-solr:2.2.0.DATASOLR-364-SNAPSHOT')
}
santa1983
  • 11
  • 2