我运行我的项目时得到java.lang.StackOverflowError? [英] Im getting java.lang.StackOverflowError while running my project?

查看:140
本文介绍了我运行我的项目时得到java.lang.StackOverflowError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 异常处理加载器WebappLoader [/ solrjExample]后台进程
java.lang.RuntimeException:java.util.concurrent.ExecutionException:java.lang.StackOverflowError

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

 <?xml version =1.0encoding =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 =htmlvalue =text / html/>
< entry key =jsonvalue =application / json/>
< / map>
< / property>
< property name =viewResolvers>
< list>
< bean
class =org.springframework.web.servlet.view.InternalResourceViewResolver>
<! - < property name =viewClassvalue =org.springframework.web.servlet.view.JstlView
/> - >
< property name =prefixvalue =/ WEB-INF / jsp //>
< property name =suffixvalue =。jsp/>
< / bean>
< / list>
< / property>
< property name =defaultViews>
< list>
< bean
class =org.springframework.web.servlet.view.json.MappingJacksonJsonView>
< property name =prefixJsonvalue =true/>
< / bean>
< / list>
< / property>
< / bean>
<! - ##################################### SOLR ### ################################## - >
<! - 配置HTTP Solr服务器 - >
< solr:solr-server id =solrServerurl =$ {solr.server.url}/>

<! - 配置Solr模板 - >
< bean id =solrTemplateclass =org.springframework.data.solr.core.SolrTemplate>
< constructor-arg index =0ref =solrServer/>
< / bean>
<! - ##################################### postgres ### ################################## - >
< bean id =dataSourceclass =org.apache.commons.dbcp.BasicDataSource
destroy-method =closep:driverClassName =org.postgresql.Driver
p:url =jdbc:postgresql:// localhost:5432 / Primep:username =postgres
p:password =Password/>
<! - ##################################### Hibernate ### ################################## - >
< bean id =sessionfactory
class =org.springframework.orm.hibernate4.LocalSessionFactoryBean>
< property name =dataSourceref =dataSource/>
< property name =configLocation>
< value> classpath:Hibernate.cfg.xml< / value>
< / property>
< property name =hibernateProperties>
<道具>
< 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>
< /道具>
< / property>
< / bean>
< bean id =transactionManager
class =org.springframework.orm.hibernate4.HibernateTransactionManager>
< property name =sessionFactoryref =sessionfactory/>
< / bean>
< / beans>

和我的web.xml

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

< web-app id =WebApp_IDversion =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>
1< / load-on-startup>
< / servlet>

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

< / web-app>

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

解决方案

这个错误背后的基础是使用 Solrj Spring-data-solr 基本上是因为记录器在这些API的调用中互相调用,直到抛出堆栈溢出错误为止。所以我删除了我的pom中的spring-data-solr依赖项。

  slf4j-jcl模块的目的是将对SLF4J记录器的调用委托或重定向到jakarta公共日志记录(JCL)。 

jcl-over-slf4j模块的目的是将对JCL记录器的调用重定向到SLF4J。

如果slf4j-jcl.jar和jcl-over-slf4j.jar都存在于类路径中,那么在第一次调用SLF4J或JCL记录器之后,将不可避免地发生StackOverflowError。

这个问题在 http://www.slf4j.org/legacy.html



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


I'm trying to implement solr search with Spring and postgres using maven but on running the appilcation i get 404 with the exception

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

I really don't understand what is the problem Here is my 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>

And my 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>

I think there is something wrong with the configuration or something as i am new to solr. Thanks for the help.

解决方案

The basics behind this error was the use the use of both Solrj and Spring-data-solr it is basically because of the logger used in these API's call each other recursively until the stack overflow error is thrown bring down the tomcat. So i removed the spring-data-solr dependency from my pom.

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. 

The problem is described in the link http://www.slf4j.org/legacy.html

Trying to find if there is a workaround for the same.

这篇关于我运行我的项目时得到java.lang.StackOverflowError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆