Summary when trying to use Solr in Java and getting an error (Solr 6.x)

Introduction

Here is a memorandum of what to do if you get an error while using Solrj. It may increase gradually.

Error initializing SolrServer

Generally, when initializing SolrServer, the code is as follows.

SolrServerSample.java


import java.io.IOException;
import org.apache.solr.client.solrj.*;
import org.apache.solr.client.solrj.impl.*;

public class SolrServerSample {
	public static void main(String[] args) throws SolrServerException, IOException {
		String url = "http://localhost:8983/solr/exampleCore";
		SolrClient solr = new HttpSolrClient.Builder(url).build(); //* 1 The part that initializes SolrServer
	}
}

The errors that occur in the above * 1 part are summarized.

Class not found

Specifically, the error is as follows.

The required jar file may not be included in the build path. Include the following jars in the dist-> solrj-lib folder in the solr6.x.x folder that you think you have downloaded in advance in your build path. (x is the version number)

slf4j related

Specifically, the error is as follows.

Download the latest slf4j from the slf4j download page and add the following jar files inside to your build path. (x is the version number)

If the above jar already exists, remove it and replace it with the latest one.

Error generating SolrInputDocument

SolrDocumentSample.java


import java.io.IOException;
import org.apache.solr.client.solrj.*;
import org.apache.solr.client.solrj.impl.*;

public class SolrDocumentSample {
	public static void main(String[] args) throws SolrServerException, IOException {
		String url = "http://localhost:8983/solr/exampleCore";
		SolrClient solr = new HttpSolrClient.Builder(url).build();

		SolrInputDocument document = new SolrInputDocument(); //* 2 Part that generates SolrInputDocument
	}
}

The errors that occur in the above * 2 part are summarized.

Class not found

Specifically, the error is as follows.

The required jar file may not be included in the build path. Include the following jars in the dist-> solrj-lib folder in the solr6.x.x folder that you think you have downloaded in advance in your build path. (x is the version number)

Recommended Posts

Summary when trying to use Solr in Java and getting an error (Solr 6.x)
Resolved the error that occurred when trying to use Spark in an environment where Java 8 and Java 11 coexist.
407 error when trying to access an HTTPS site in Java via an authenticated proxy
Error when trying to use heroku command
What to do and how to install when an error occurs in DXRuby 1.4.7
I get an error when I try to use "^" or "$" in ruby ​​regular expression
When using a list in Java, java.awt.List comes out and an error occurs
Summary of how to use the proxy set in IE when connecting with Java
What happened in "Java 8 to Java 11" and how to build an environment
How to call and use API in Java (Spring Boot)
Reasons to use Servlet and JSP separately in Java development
How to use classes in Java?
After switching between Java 8 and 11 versions, an error occurs in confirmation
[Java] Shallow copy and deep copy when converting an array to List
How to solve the unknown error when using slf4j in Java
Multilingual Locale in Java How to use Locale
[Java] [Maven3] Summary of how to use Maven3
I want to display an error message when registering in the database
Java to C and C to Java in Android Studio
Summary of good points and precautions when converting Java Android application to Kotlin
Use without preparing an authentication file when using Firebase Admin SDK in Java
[Error resolution] Occurs when trying to build an environment for spring with docker
[Java] How to use FileReader class and BufferedReader class
I want to send an email in Java.
When deploying to Heroku, OpenApp causes an error
How to solve an Expression Problem in Java
[Java] How to use Calendar class and Date class
[Java] What to do if you get an error in Eclipse saying "Not allowed at source level below 1.X"
An embarrassing story that was treated as the same day when trying to compare dates on 3/31 and 4/1 [Java / Calendar]
[In team development] Error when moving to another member's branch and doing rails s [Rails]
I got an error when trying to install sbt to build a Scala development environment
Code to use when you want to process Json with only standard library in Java
What to do when an error occurs in rails db: migrate ((StandardError: An error has occurred, this and all later migrations canceled :))
I want to use ES2015 in Java too! → (´ ・ ω ・ `)
Summary of Java communication API (3) How to use SocketChannel
How to convert A to a and a to A using AND and OR in Java
What to do when an error (StandardError: An error has occurred, this and all later migrations canceled:) appears in rails db: migrate
Summary of Java communication API (2) How to use HttpUrlConnection
When you want to dynamically replace Annotation in Java8
Use of Abstract Class and Interface properly in Java
Summary of how to implement default arguments in Java
[Java] Convert JSON to Java and Java to JSON-How to use GSON and Jackson-
Gzip-compress byte array in Java and output to file
Notes on how to use regular expressions in Java
When trying to insert a specific gem (levenshtein) with Docker, an error occurred without ruby-dev
How to change Java version and execute in an environment where Java cannot be installed freely
Use PreparedStatement in Java
I got an error when using nextInt, nextLine and substring.
Getting started with Java and creating an AsciiDoc editor with JavaFX
How to use JSON data in WebSocket communication (Java, JavaScript)
[Java] Change language and locale to English in JVM options
Resolve CreateProcess error = 206 when running Java in a Windows environment
Use Java Web Start in an OpenJDK environment on Windows
Things you often use when doing web development in Java
How to use Java enums (Enum) in MyBatis Mapper XML
How to write and notes when migrating from VB to JAVA
Things to be aware of when writing code in Java
How to dynamically switch JDK when building Java in Gradle
An error occurs when codedeploy-agent is installed in Ubuntu Server 20.04
How to develop and register a Sota app in Java
Show detailed error in Logger when running Java on server