0
    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)

rupanjan
  • 169
  • 2
  • 11
  • Can you please provide the full stacktrace? – Christoph Strobl Sep 27 '13 at 04:37
  • Hi Christoph, just updated the stacktrace in the post .. – rupanjan Sep 27 '13 at 05:35
  • I guess `SolrTemplate` is still null when `new SolrRepositoryFactory` is called. Please add the Interface `InitializingBean` to your `RepositoryMembershipIndexService` and create `MembershipDocumentRepository` whithin `afterPropertiesSet()`. Hope that helps. – Christoph Strobl Sep 27 '13 at 05:42
  • SolrTemplate is null, getting following exception ... Caused by: 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]: Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property update found for type void – rupanjan Sep 27 '13 at 08:37
  • you have to provide an implementation for your `CustomMembershipDocumentRepository`. like `new SolrRepositoryFactory(this. solrMembershipTemplate).getRepository(MembershipDocumentRepository.class, new CustomMembershipDocumentRepositoryImpl(solrMembershipTemplate));` – Christoph Strobl Sep 30 '13 at 21:25

1 Answers1

0

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.

alizelzele
  • 892
  • 2
  • 19
  • 34