在网上找了段ssh+compass代码,研究了一下。但是运行时就报错:Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'compassIndexBuilder' defined in ServletContext resource [/WEB-INF/applicationContext-compass.xml]: Cannot resolve reference to bean 'compassGps' while setting bean property 'compassGps'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'compassGps' defined in ServletContext resource [/WEB-INF/applicationContext-compass.xml]: Cannot resolve reference to bean 'compass' while setting bean property 'compass'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'compass' defined in ServletContext resource [/WEB-INF/applicationContext-compass.xml]: Invocation of init method failed; nested exception is org.compass.core.config.ConfigurationException: No mapping match directory [C:\tomcat6\webapps\shop_v1.1\WEB-INF\classes\service\impl]找了很长时间,都没有效果,大家有遇到这情况的没?怎么解决啊???

解决方案 »

  1.   

    看看/WEB-INF/applicationContext-compass.xml
    中的compassGps的定义,结合配置文件上下文。
     
      

  2.   

    把全部配置文件内容贴出来啊,很明显嘛
    [/WEB-INF/applicationContext-compass.xml]:
    这个文件中怎么定义的compassGps,好好查查
      

  3.   

    这个是applicationContext-compass.xml文件!!<?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=" http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
    default-lazy-init="true"> <bean id="annotationConfiguration"
    class="org.compass.annotations.config.CompassAnnotationsConfiguration">
    </bean>
    <bean id="compass" class="org.compass.spring.LocalCompassBean">
    <property name="resourceDirectoryLocations">
    <list>
    <value>classpath:service/impl</value>
    </list>
    </property>
    <property name="connection">
    <value>/lucene/indexes</value>
    </property> <property name="classMappings">
    <list>
    <value>model.Product</value>
    </list>
    </property>
    <property name="compassConfiguration" ref="annotationConfiguration" /> <property name="compassSettings">
    <props>
    <prop key="compass.transaction.factory">
    org.compass.spring.transaction.SpringSyncTransactionFactory
    </prop>
    <prop key="compass.engine.analyzer.MMAnalyzer.CustomAnalyzer">net.paoding.analysis.analyzer.PaodingAnalyzer </prop>
    </props>
    </property> <property name="transactionManager" ref="transactionManager" />
    </bean>
    <bean id="hibernateGpsDevice" class="org.compass.gps.device.hibernate.HibernateGpsDevice">
    <property name="name">
    <value>hibernateDevice</value>
    </property>
    <property name="sessionFactory" ref="sessionFactory" />
    <property name="mirrorDataChanges">
    <value>true</value>
    </property>
    </bean>
    <!-- 同步更新索引 -->
    <bean id="compassGps" class="org.compass.gps.impl.SingleCompassGps"
    init-method="start" destroy-method="stop">
    <property name="compass" ref="compass" />
    <property name="gpsDevices">
    <list>
    <bean
    class="org.compass.spring.device.SpringSyncTransactionGpsDeviceWrapper">
    <property name="gpsDevice" ref="hibernateGpsDevice" />
    </bean>
    </list>
    </property>
    </bean>
    <bean id="compassTemplate" class="org.compass.core.CompassTemplate">
    <property name="compass" ref="compass" />
    </bean>
    <!-- 定时重建索引(利用quartz)或随Spring ApplicationContext启动而重建索引 -->
    <bean id="compassIndexBuilder" class="service.impl.CompassIndexBuilder"
    lazy-init="false">
    <property name="compassGps" ref="compassGps" />
    <property name="buildIndex" value="true" />
    <property name="lazyTime" value="10" />
    </bean></beans>
      

  4.   

    大家帮忙看一下,有用过compass的吗??做全文搜索。。
      

  5.   

    web.xml 中监听器配置的位置不对或是写错了
      

  6.   

    没有啊,我原来这个程序是好使的,但是加上compass就报错了!
      

  7.   

    No mapping match directory [C:\tomcat6\webapps\shop_v1.1\WEB-INF\classes\service\impl]
    compassGps在实例化的时候遇到这个问题
      

  8.   

    compassGps我是通过spring注入的,直接setCompassGps,没错啊。。