Jspxcms启动报错:The object cannot be set twice

2018-04-23 10:30 阅读

如果在启动或访问的时候,出现以下报错信息,是因为Tomcat里的应用启动了两次。

com.ujcms.common.fulltext.LuceneException: Error during searching.; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'searcherManager' defined in class path resource [custom.xml]: 
Cannot resolve reference to bean 'indexWriter' while setting bean property 'indexWriter';
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'indexWriter': FactoryBean threw exception on object creation;
nested exception is org.apache.lucene.util.SetOnce$AlreadySetException: The object cannot be set twice!

导致Tomcat应用启动两次的原因通常是因为修改了tomcat的server.xml里的host、context配置,比如程序放在tomcat/webapps目录下,然后在server.xml里再次配置context,就会出现这种情况。因为在tomcat/webapps里的应用本身就会启动,然后tomcat就检测到server.xml里配置的context,所以会再次启动一次。如:

<Host ...>
    <Context path="/" docBase="D:/tomcat/webapps/ROOT" />
</Host>

或者

<Host ...>
    <Context path="/" docBase="D:/tomcat/webapps/jspxcms" reloadable="true" />
</Host>

正确的做法是不要修改tomcat的server.xml配置文件中的Host、Context配置,直接将程序作为ROOT文件夹,放在tomcat/webapps目录下。

QQ咨询
电话
微信
微信扫码咨询