我在运行项目时遇到了java.lang.StackOverflowError?

时间:2013-03-06 06:01:25

标签: java hibernate maven spring-mvc solrj

我正在尝试使用maven实现solr搜索和使用maven的postgres但是在运行appilcation时我得到了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>

我认为配置有问题或者我不熟悉的东西。 谢谢你的帮助。

3 个答案:

答案 0 :(得分:1)

此错误背后的基础是使用 Solrj Spring-data-solr 这基本上是因为这些API中使用的记录器相互调用递归直到抛出堆栈溢出错误导致tomcat失效。所以我从我的pom中删除了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

中描述

尝试查找是否有相同的解决方法。

答案 1 :(得分:0)

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

答案 2 :(得分:0)

通常这种错误是由递归无限循环引起的。你在服务器启动时有自己的代码吗?