Spring Data Solr with Solr 4.1 multicores

送分小仙女□ 提交于 2019-12-23 04:29:06

问题


    Trying to implement Spring-Data-Solr with Solr 4.1 multicores, 

At server startup getting following exception, I guess it expecting a default constructor somewhere. So, is there a limitation of spring-data-solr with solr muticores implementation, here is my implementation,

repositories

    public interface MembershipDocumentRepository extends
            CustomMembershipDocumentRepository,
            SolrCrudRepository<MembershipDocument, String> {
    }


 created 'repository' manually instead of autowiring/injection.......

    @Service
    public class RepositoryMembershipIndexService implements MembershipIndexService {   
        @Autowired
        private SolrTemplate solrMembershipTemplate;

        private MembershipDocumentRepository repository = new SolrRepositoryFactory(
                this.solrMembershipTemplate)
                .getRepository(MembershipDocumentRepository.class);

        @Transactional
        @Override
        public void addToIndex(Membership membershipEntry) {
            MembershipDocument document = MembershipDocument.getBuilder(
                    ...           
            repository.save(document);
        }
    }

applicationContext-solr.xml

        <solr:repositories
            base-package="net.pegonwheels.spring.datasolr.domain.repository.solr" />
        <beans profile="prod">
            <solr:solr-server id="solrMembershipServer" url="${solr.server.url.membership}" />
            <bean id="solrMembershipTemplate" class="org.springframework.data.solr.core.SolrTemplate">
                <constructor-arg ref="solrMembershipServer" />
            </bean>
        </beans>

exception

    At server startup getting following exception, I guess it expecting a default constructor somewhere. So, is there a limitation of spring-data-solr with solr muticores implementation. Can somebody please help me, thanks a ton in advance.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryMembershipIndexService' defined in file [/home/rupanjan/Installations/apache-tomcat-7.0.39/webapps/pegonwheels-server/WEB-INF/classes/net/pegonwheels/spring/datasolr/domain/service/RepositoryMembershipIndexService.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [net.pegonwheels.spring.datasolr.domain.service.RepositoryMembershipIndexService]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662)


回答1:


in code u have

private MembershipDocumentRepository repository = new SolrRepositoryFactory(this.solrMembershipTemplate)
       .getRepository(MembershipDocumentRepository.class);

but your MembershipDocumentRepository can not be build with out custom implemention of CustomMembershipDocumentRepository.

if you implemented it check the name.it must be in the same package as MembershipDocumentRepository and named MembershipDocumentRepositoryImpl ( this is the default naming for it.



来源:https://stackoverflow.com/questions/19038153/spring-data-solr-with-solr-4-1-multicores

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!