iBatis java.lang.OutOfMemoryError:Java堆空间

时间:2016-12-28 22:40:01

标签: java eclipse tomcat jdbc ibatis

我有一个使用Struts和iBatis的Web应用程序。我在Eclipse中的tomcat服务器中运行应用程序。每当我运行返回许多行的SELECT查询时,我都会得到java.lang.OutOfMemoryError。如果我限制返回的行数,那么它不会发生。我在这个网站上搜索过类似的问题,大多数答案都谈到增加我在eclipse.INI文件中完成的java堆大小,方法是通过-Xmx2048m将其设置为2048。我也看到有些人建议改变jdbc处理结果集的方式,但我一直无法使用iBatis找到如何做到这一点。这是我的数据库设置的样子

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>

<bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="initialSize" value="3" />
    <property name="maxActive" value="10" />
    <property name="maxIdle" value="10" />
    <property name="maxWait" value="10000" />
    <property name="minIdle" value="3" />
    <property name="removeAbandoned" value="true" />
    <property name="removeAbandonedTimeout" value="300" />
    <property name="logAbandoned" value="false" />
    <property name="accessToUnderlyingConnectionAllowed"
        value="true" />
</bean>


<bean id="jdbcConnectionConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:jdbc-db.properties" />
</bean>


<bean id="sqlMapClient"
    class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <property name="configLocation">
        <value>WEB-INF/SqlMapConfig.xml</value>
    </property>
    <property name="useTransactionAwareDataSource">
        <value>true</value>
    </property>
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
</bean>

编辑:这是完整的堆栈跟踪

    java.lang.OutOfMemoryError: Java heap space
    at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:99)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:393)
    at java.lang.StringBuffer.append(StringBuffer.java:225)
    at org.apache.struts.taglib.html.OptionsCollectionTag.addOption(OptionsCollectionTag.java:313)
    at org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:266)
    at org.apache.strutsel.taglib.html.ELOptionsCollectionTag.doStartTag(ELOptionsCollectionTag.java:220)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005foptionsCollection_005f2(humanRestAreagoiotionCreate_jsp.java:1984)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005fselect_005f2(humanRestAreagoiotionCreate_jsp.java:1948)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005fform_005f0(humanRestAreagoiotionCreate_jsp.java:1578)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspService(humanRestAreagoiotionCreate_jsp.java:457)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1078)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:396)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:347)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
Dec 28, 2016 4:46:40 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
java.lang.OutOfMemoryError: Java heap space
    at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:99)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:393)
    at java.lang.StringBuffer.append(StringBuffer.java:225)
    at org.apache.struts.taglib.html.OptionsCollectionTag.addOption(OptionsCollectionTag.java:313)
    at org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:266)
    at org.apache.strutsel.taglib.html.ELOptionsCollectionTag.doStartTag(ELOptionsCollectionTag.java:220)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005foptionsCollection_005f2(humanRestAreagoiotionCreate_jsp.java:1984)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005fselect_005f2(humanRestAreagoiotionCreate_jsp.java:1948)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005fform_005f0(humanRestAreagoiotionCreate_jsp.java:1578)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspService(humanRestAreagoiotionCreate_jsp.java:457)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1078)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:396)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:347)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
[SYS] [2016-12-28 16:46:40.651] DSC-ID[NULL_ID] SID[16CF384A6BBB483CD2CC7009350B5598] RID[654474] [ERROR] ID:861385 CODE:AI-90-0000 MESSAGE:[AI-90-0000]Unexpected exception occurred. Exception Type: javax.servlet.ServletException, Message: java.lang.OutOfMemoryError: Java heap space DATE & TIME:2016-12-28 16:46:40.408
com.globaldenso.ai.common.core.exception.SystemException: [AI-90-0000]Unexpected exception occurred. Exception Type: javax.servlet.ServletException, Message: java.lang.OutOfMemoryError: Java heap space
    at org.apache.jsp.WEB_002dINF.jsp.common.error_jsp._jspService(error_jsp.java:237)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:416)
    at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:270)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:595)
Caused by: javax.servlet.ServletException: java.lang.OutOfMemoryError: Java heap space
    at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspService(humanRestAreagoiotionCreate_jsp.java:471)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1078)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:396)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:347)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.ai.tro2.core.filter.RequestLoggingFilter.doFilter(RequestLoggingFilter.java:89)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.ai.tro2.core.filter.LogContextFilter.doFilter(LogContextFilter.java:80)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.ai.tro2.core.filter.DensoContextFilter.doFilter(DensoContextFilter.java:94)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.na.nascs_admin.common.filter.PageAccessFilter.doFilter(PageAccessFilter.java:108)
    at com.globaldenso.na.nascs_admin.common.filter.PageAccessFilter.doFilter(PageAccessFilter.java:90)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.na.nascs_admin.common.filter.ChgPwdFilter.doFilter(ChgPwdFilter.java:106)
    at com.globaldenso.na.nascs_admin.common.filter.ChgPwdFilter.doFilter(ChgPwdFilter.java:81)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.na.nascs_admin.common.filter.LoginFilter.doFilter(LoginFilter.java:110)
    at com.globaldenso.na.nascs_admin.common.filter.LoginFilter.doFilter(LoginFilter.java:83)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.ai.tro2.core.filter.CheckFilter.doFilter(CheckFilter.java:80)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.globaldenso.ai.tro2.core.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:92)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    ... 7 more
Caused by: java.lang.OutOfMemoryError: Java heap space
    at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:99)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:393)
    at java.lang.StringBuffer.append(StringBuffer.java:225)
    at org.apache.struts.taglib.html.OptionsCollectionTag.addOption(OptionsCollectionTag.java:313)
    at org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:266)
    at org.apache.strutsel.taglib.html.ELOptionsCollectionTag.doStartTag(ELOptionsCollectionTag.java:220)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005foptionsCollection_005f2(humanRestAreagoiotionCreate_jsp.java:1984)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005fselect_005f2(humanRestAreagoiotionCreate_jsp.java:1948)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspx_meth_html_005fform_005f0(humanRestAreagoiotionCreate_jsp.java:1578)
    at org.apache.jsp.WEB_002dINF.jsp.humanRestAreagoiotion.humanRestAreagoiotionCreate_jsp._jspService(humanRestAreagoiotionCreate_jsp.java:457)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1078)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:396)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:347)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

1 个答案:

答案 0 :(得分:2)

eclipse.ini为eclipse本身定义了内存。您必须将-Xmx2048定义到您的应用程序的启动器中。 如果您使用eclipse启动webapp,请尝试按以下链接:

http://crunchify.com/how-to-increase-tomcat-heapsize-jvm-heap-in-eclipse-ede/

请注意,如果你在eclipse之外启动它,你必须自己更改tomcat:

http://crunchify.com/how-to-change-jvm-heap-setting-xms-xmx-of-tomcat/