首页 新闻 会员 周边 捐助

关于在hibernate.cfg.xml中配置listener出错

0
悬赏园豆:20 [待解决问题]
 1 严重: Error listenerStart
 2 Exception in thread "Thread-12" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'courseServiceImpl': Injection of resource fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\apache-tomcat-6.0.43\webapps\opera2\WEB-INF\classes\applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not init listeners
54 Caused by: org.hibernate.HibernateException: could not init listeners
55 64 Caused by: java.lang.NullPointerException
65 at org.hibernate.search.engine.DocumentBuilderIndexedEntity.init(DocumentBuilderIndexedEntity.java:151)
66 at org.hibernate.search.engine.DocumentBuilderContainedEntity.<init>(DocumentBuilderContainedEntity.java:93)
67 at org.hibernate.search.engine.DocumentBuilderIndexedEntity.<init>(DocumentBuilderIndexedEntity.java:128)
68 at org.hibernate.search.impl.SearchFactoryImpl.initDocumentBuilders(SearchFactoryImpl.java:409)
69 at org.hibernate.search.impl.SearchFactoryImpl.<init>(SearchFactoryImpl.java:119)
70 at org.hibernate.search.event.ContextHolder.getOrBuildSearchFactory(ContextHolder.java:30)
71 at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:79)
72 at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
73 at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
74 at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
75 ... 54 more

我的hibernate.cfg.xml的配置

<hibernate-configuration>
<session-factory>

<!-- 1.数据库连接信息 -->
<property name="dialect">
org.hibernate.dialect.MySQL5InnoDBDialect
</property>
<!-- 
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql:///hsxoa</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
-->

<!-- 2.其他配置 -->
<!-- 显示和格式化sql语句 -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!-- 自动创建数据库表 -->
<property name="hbm2ddl.auto">update</property>

<property name="hibernate.search.default.directory_provider"> 
org.hibernate.search.store.FSDirectoryProvider </property>
<!-- 索引存放在硬盘的地址--> 
<property name="hibernate.search.default.indexBase"> 
LuceneIndex</property> 
<!-- 分词器--> 
<property name="hibernate.search.analyzer">org.apache.lucene.analysis.cjk.CJKAnalyzer</property>

<!-- 3.导入映射文件 -->
<mapping resource="com/org/opera/domain/FileLog.hbm.xml" />
<mapping resource="com/org/opera/domain/Forum.hbm.xml" />
<mapping resource="com/org/opera/domain/Manager.hbm.xml" />
<mapping resource="com/org/opera/domain/MinrenInfo.hbm.xml" />
<mapping resource="com/org/opera/domain/News.hbm.xml" />
<mapping resource="com/org/opera/domain/Photo.hbm.xml" />
<mapping resource="com/org/opera/domain/Reply.hbm.xml" />
<mapping resource="com/org/opera/domain/SihuojuInfo.hbm.xml" />
<mapping resource="com/org/opera/domain/SihuojuJoin.hbm.xml" />
<mapping resource="com/org/opera/domain/Song.hbm.xml" />
<mapping resource="com/org/opera/domain/Text.hbm.xml" />
<mapping resource="com/org/opera/domain/Topic.hbm.xml" />
<mapping resource="com/org/opera/domain/User.hbm.xml" />
<mapping resource="com/org/opera/domain/Video.hbm.xml" />
<mapping resource="com/org/opera/domain/Vip.hbm.xml" />
<mapping resource="com/org/opera/domain/OtherPhoto.hbm.xml" />
<mapping resource="com/org/opera/domain/Course.hbm.xml" />
<!-- 索引配置-->

<event type="post-insert">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener" />
</event>
<event type="post-update">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener" />
</event>

<event type="post-delete">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener" />
</event>
<event type="post-collection-recreate">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener" />
</event>
<event type="post-collection-remove">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener" />
</event>
<event type="post-collection-update">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener" />
</event>
</session-factory>
</hibernate-configuration>

我的applicationContent.xml的配置:

<!-- 配置SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>


我使用的包:

hibernate-core-3.3.1.GA.jar
hibernate-annotations-3.4.0.GA.jar
lucene-highlighter-2.4.0.jar
hibernate-commons-annotations-3.4.0.jar
lucene-core-2.4.0.jar
lucene-analyzers-2.4.0.jar
hibernate-search-3.1.1.GA.jar

情况是:当我删除了hibernate.cfg.xml中的事件监听器时,项目不报错,如果不删就报错,求处理方法

haoTim的主页 haoTim | 初学一级 | 园豆:61
提问于:2016-03-06 15:02
< >
分享
所有回答(1)
0

重来一遍

haoTim | 园豆:61 (初学一级) | 2016-08-15 17:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册