カスタムリポジトリメソッドの機能(Spring Data jpaのような)を使用しようとしました。
Spring Data Elastic Search 用に構成されたパッケージにリポジトリ インターフェイスがありました。
public interface TestrunSetRepository extends ElasticsearchRepository<TestrunSetDocument, String>, TestrunSetRepositoryCustom {
}
TestrunSetRepositoryCustom の実装がありました
public class TestrunSetRepositoryCustomImpl implements
TestrunSetRepositoryCustom {
private ElasticsearchTemplate elasticsearchTemplate;
public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate) {
this.elasticsearchTemplate = elasticsearchTemplate;
}
@Override
public List<String> getUniqueCategoriesDe() {
return null;
}
}
applicationContext.xml:
<elasticsearch:repositories base-package="some.repositories.es" />
<elasticsearch:transport-client id="esClient"
cluster-nodes="#{@'some.elasticsearch.cluster.nodes'}"
cluster-name="#{@'some.elasticsearch.cluster.name'}"/>
<bean id="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
<constructor-arg name="client" ref="esClient"/>
</bean>
<bean id="testrunSetRepositoryCustom"
class="some.repositories.es.impl.TestrunSetRepositoryCustomImpl">
<property name="elasticsearchTemplate" ref="elasticsearchTemplate"/>
</bean>
しかし、Spring コンテキストの初期化中に、次の例外が発生しました。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testrunSetRepository': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1454)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:270)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 63 more
Caused by: java.lang.NullPointerException
at org.springframework.data.elasticsearch.repository.support.MappingElasticsearchEntityInformation.<init>(MappingElasticsearchEntityInformation.java:53)
at org.springframework.data.elasticsearch.repository.support.MappingElasticsearchEntityInformation.<init>(MappingElasticsearchEntityInformation.java:49)
at org.springframework.data.elasticsearch.repository.support.ElasticsearchEntityInformationCreatorImpl.getEntityInformation(ElasticsearchEntityInformationCreatorImpl.java:46)
at org.springframework.data.elasticsearch.repository.query.ElasticsearchQueryMethod.<init>(ElasticsearchQueryMethod.java:42)
at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory$ElasticsearchQueryLookupStrategy.resolveQuery(ElasticsearchRepositoryFactory.java:108)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:290)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:158)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:162)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:44)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)