"LuceneServiceImpl could not be instantiated" ServiceConfigurationError in VMware GemFire
search cancel

"LuceneServiceImpl could not be instantiated" ServiceConfigurationError in VMware GemFire

book

Article ID: 294363

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

GemFire Cache service fails to parse a JSON document into the GemFire cache with:
java.lang.RuntimeException: org.apache.geode.pdx.JSONFormatterException: Could not parse JSON document...

In addition, an "org.apache.geode.cache.lucene.internal.LuceneServiceImpl could not be instantiated" error before the JSONFormatterException is thrown.
[error 2020/05/20 16:16:51.549 UTC tid=0x1] java.util.ServiceConfigurationError: org.apache.geode.internal.cache.CacheService: Provider org.apache.geode.cache.lucene.internal.LuceneServiceImpl could not be instantiated 
......

2020-05-20 16:17:00,450 |  WARN [main] - Model was not saved compressedCould not parse JSON document: [Source: (String)"{"validFrom":1589955420448,"sourceSystem":"xxx","dataType":"Authorization","validTo":9223372036854775807}"; line: 1, column: 112]
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 18.249 s <<< FAILURE! - in com.sample.dao.AuthorizationDaoImplTest
[ERROR] testFitasSaveWhenExistingEntry(com.sample.dao.AuthorizationDaoImplTest)  Time elapsed: 17.242 s  <<< ERROR!
java.lang.RuntimeException: org.apache.geode.pdx.JSONFormatterException: Could not parse JSON document: [Source: (String)"{"validFrom":1589955420209,"sourceSystem":"xxx","dataType":"Authorization","validTo":9223372036854775807}"; line: 1, column: 112]
        at com.sample.dao.AuthorizationDaoImplTest.testFitasSaveWhenExistingEntry(AuthorizationDaoImplTest.java:64)
Caused by: org.apache.geode.pdx.JSONFormatterException: Could not parse JSON document: [Source: (String)"{"validFrom":1589955420209,"sourceSystem":"xxxx","dataType":"Authorization","validTo":9223372036854775807}"; line: 1, column: 112]
        at com.sample.dao.AuthorizationDaoImplTest.testFitasSaveWhenExistingEntry(AuthorizationDaoImplTest.java:64)
Caused by: java.lang.NullPointerException
        at com.sample.dao.AuthorizationDaoImplTest.testFitasSaveWhenExistingEntry(AuthorizationDaoImplTest.java:64)


Environment

Product Version: 9.9

Resolution

From the above logs, the JSONFormatterException could be caused by the GemFire cache service initialization failure with error "LuceneServiceImpl could not be instantiated".

According to past experiences, the "LuceneServiceImpl could not be instantiated" error has a high possibility of being caused by the classloader failing to find Lucene relevant classes. This can confirmed when you see: "Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer".

You can resolve this kind of issue by adding the below dependencies, which are located under the [Gemfire_Installation]/lib folder to the maven project or the classpath in the above scenario.

For example, in GemFire 9.9.1:

lucene-core-6.6.2.jar
lucene-queries-6.6.2.jar
lucene-queryparser-6.6.2.jar
lucene-analyzers-common-6.6.2.jar
lucene-analyzers-phonetic-6.6.2.jar
OR
<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-core</artifactId>
	<version>6.6.2</version>
</dependency>

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-queries</artifactId>
	<version>6.6.2</version>
</dependency>

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-queryparser</artifactId>
	<version>6.6.2</version>
</dependency>

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-analyzers-common</artifactId>
	<version>6.6.2</version>
</dependency>

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-analyzers-phonetic</artifactId>
	<version>6.6.2</version>
</dependency>