4

我正在尝试使用 maven 使用 Spring 和 postgres 实现 solr 搜索,但是在运行应用程序时,我得到 404 例外

Exception processing loader WebappLoader[/solrjExample] background process
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.StackOverflowError

我真的不明白有什么问题这是我的spring-servlet:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:beans=" http://www.springframework.org/schema/beans  "
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:solr="http://www.springframework.org/schema/data/solr"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
   http://www.springframework.org/schema/beans     
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/data/solr 
   http://www.springframework.org/schema/data/solr/spring-solr.xsd">

    <context:component-scan base-package="org.tcs.com.controller" />
    <context:property-placeholder location="classpath:org/tcs/com/lak/resources/application.properties" />
    <mvc:annotation-driven />
    <bean id="jacksonMessageConverter"
        class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
    <bean
        class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="mediaTypes">
            <map>
                <entry key="html" value="text/html" />
                <entry key="json" value="application/json" />
            </map>
        </property>
        <property name="viewResolvers">
            <list>
                <bean
                    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <!-- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" 
                        /> -->
                    <property name="prefix" value="/WEB-INF/jsp/" />
                    <property name="suffix" value=".jsp" />
                </bean>
            </list>
        </property>
        <property name="defaultViews">
            <list>
                <bean
                    class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
                    <property name="prefixJson" value="true" />
                </bean>
            </list>
        </property>
    </bean>
    <!-- ##################################### SOLR ##################################### -->
    <!-- Configures HTTP Solr server -->
    <solr:solr-server id="solrServer" url="${solr.server.url}" />

    <!-- Configures Solr template -->
    <bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
        <constructor-arg index="0" ref="solrServer" />
    </bean>
<!-- ##################################### postgres ##################################### -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close" p:driverClassName="org.postgresql.Driver"
        p:url="jdbc:postgresql://localhost:5432/Prime" p:username="postgres"
        p:password="Password" /> 
        <!-- ##################################### Hibernate ##################################### -->
    <bean id="sessionfactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation">
            <value>classpath:Hibernate.cfg.xml</value>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.cache.use_second_level_cache">false</prop>
            </props>
        </property>
    </bean> 
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionfactory" />
    </bean>  
</beans>

还有我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>

  <web-app id="WebApp_ID" version="2.4"
   xmlns="http://java.sun.com/xml/ns/j2ee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <display-name>solrjExample</display-name>
   <servlet>
      <servlet-name>solrjExample</servlet-name>
      <servlet-class>
         org.springframework.web.servlet.DispatcherServlet
      </servlet-class>
        <init-param>
       <param-name>contextConfigLocation</param-name>
         <param-value>WEB-INF/slorjExample-servlet.xml</param-value>
       </init-param>
      <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet-mapping>
      <servlet-name>solrjExample</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>

</web-app>

我认为配置有问题,或者我是 solr 的新手。谢谢您的帮助。

4

3 回答 3

1

通常这种错误是由于递归无限循环造成的。您是否在服务器启动时执行了一些自己的代码?

于 2013-03-06T17:11:27.813 回答
1

这个错误背后的基础是使用了SolrjSpring-data-solr这基本上是因为这些 API 中使用的记录器递归地相互调用,直到抛出堆栈溢出错误导致 tomcat 崩溃。所以我从我的 pom.xml 中删除了 spring-data-solr 依赖项。

The purpose of slf4j-jcl module is to delegate or redirect calls made to an SLF4J logger to jakarta commons logging (JCL). 

The purpose of the jcl-over-slf4j module is to redirect calls made to a JCL logger to SLF4J.

 If both slf4j-jcl.jar and jcl-over-slf4j.jar are present on the class path, then a StackOverflowError will inevitably occur immediately after the first invocation of an SLF4J or a JCL logger. 

该问题在链接http://www.slf4j.org/legacy.html中进行了描述

试图找出是否有相同的解决方法。

于 2013-04-04T13:10:59.660 回答
0

当你说你运行你的应用程序时,你是什么意思?您是在运行某种搜索还是在加载欢迎页面时?运行应用程序时是否默认访问特定页面?您是否尝试在启动应用程序时运行的代码段中放置一些调试点?还是您的意思是在部署应用程序后启动服务器时出现此错误?

于 2013-03-06T16:58:33.353 回答