系统环境: jdk1.5  weblogic9.2  linux
在导入excel文件(105k)时,系统会报如下异常, 而当导入大小为15K的excel文件,运行正常! 请问大侠们,这是怎么回事啊? 怎么解决!<2008-10-15 下午04时49分36秒 CDT> <Critical> <Health> <BEA-310003> <Free memory in the server is 1,015,760 bytes. There is danger of OutOfMemoryError> 
ERROR 2008-10-15 16:49:44,627 [[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] com.opensymphony.webwork.dispatcher.DispatcherUtils     - Could not execute action
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:364)
        at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:216)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
        at com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:168)
        at com.opensymphony.xwork.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:115)
        at com.opensymphony.xwork.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.webwork.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:233)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.webwork.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:147)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:151)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:186)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.webwork.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:233)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
        at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:113)
        at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:225)
        at com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:202)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at com.opensymphony.webwork.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:88)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at com.zjpublic.webapps.filter.SessionOuttimeFilter.doFilter(SessionOuttimeFilter.java:60)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at com.zjpublic.webapps.filter.PermissionFilter.doFilter(PermissionFilter.java:91)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at com.zjpublic.webapps.filter.LoginFilter.doFilter(LoginFilter.java:147)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at cn.com.zjtelecom.sso.client.filter.CASFilter.doFilter(CASFilter.java:352)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3212)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: java.lang.OutOfMemoryError: Java heap space

解决方案 »

  1.   

    这个系统在我本地调试的时候 导入ok!  但是实际系统中导入时 就抛如上异常!
    public String upload() throws FileNotFoundException, IOException {
    resultList = null;
    List<Result> tmplist = new ArrayList<Result>();
    if (file == null) {
    errorMessage = "请选择要导入的文件";
    return list();
    }
    POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file));
    HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);// 第一页的内容
    int rows = sheet.getPhysicalNumberOfRows();// 行数

    if(rows>30001) //限制取前30000条
    rows = 30001;

    for (int r = 1; r < rows; r++) {// 第2行开始
    Result result = new Result(); HSSFRow row = sheet.getRow(r);
    if (row != null) {
    HSSFCell assetIdCell = row.getCell((short) 0);// 实物Id
    if (assetIdCell != null) {
    String assetId = assetIdCell.getStringCellValue();
    if (assetId.trim() != null) {
    Asset asset = new Asset();
    asset.setId(assetId);
    if (asset != null) {
    result.setAsset(asset);
    }
    }
    }
    // 2008-09-09代码修改
    HSSFCell cardIdCell = row.getCell((short) 1);// 卡片编号
    String cardId = null;
    if(cardIdCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
    {
    Double d = new Double(cardIdCell.getNumericCellValue());
    cardId = String.valueOf(d.longValue()).trim();
    }
    else
    {
    cardId = cardIdCell.getStringCellValue().trim();
    }
    result.setCardId(cardId);

    if (result.getAsset()==null){
    Asset asset = resultService.getAsset(cardId,getOperator().getCompany().getId());
    result.setAsset(asset);
    }

    // HSSFCell cardIdCell = row.getCell((short) 1);// 卡片编号
    // if(cardIdCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
    // {
    // Double d = new Double(cardIdCell.getNumericCellValue());
    // result.setCardId(String.valueOf(d.longValue()));
    // }
    // else
    // {
    // if (cardIdCell != null) {
    // String cardId = cardIdCell.getStringCellValue();
    // if (cardId.trim() != null) {
    // result.setCardId(cardId);
    // }
    // }
    // } HSSFCell assetNoCell = row.getCell((short) 2);// 资产编号
    if (assetNoCell != null) {
    if(assetNoCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
    {
    Double d = new Double(assetNoCell.getNumericCellValue());
    result.setAssetNo(String.valueOf(d.longValue()));
    }
    else
    {
    String assetNo = assetNoCell.getStringCellValue();
    if (assetNo.trim() != null) {
    result.setAssetNo(assetNo);
    }
    }
    } HSSFCell assetNameCell = row.getCell((short) 3);// 资产名称
    if (assetNameCell != null) {
    String assetName = assetNameCell.getStringCellValue();
    if (assetName.trim() != null) {
    result.setAssetName(assetName);
    }
    } HSSFCell standardTypeCell = row.getCell((short) 4);// 规格型号
    if (standardTypeCell != null) {
    String standardType = standardTypeCell.getStringCellValue();
    if (standardType.trim() != null) {
    result.setStandardType(standardType);
    }
    } HSSFCell localInfoCell = row.getCell((short) 5);// 所在地点
    if (localInfoCell != null) {
    String localInfo = localInfoCell.getStringCellValue();
    if (localInfo.trim() != null) {
    result.setLocalInfo(localInfo);
    }
    } HSSFCell measureUnitCell = row.getCell((short) 6);// 计量单位
    if (measureUnitCell != null) {

    String measureUnit = measureUnitCell.getStringCellValue();
    if (measureUnit.trim() != null) {
    result.setMeasureUnit(measureUnit);
    }
    } HSSFCell sysNumCell = row.getCell((short) 7);// 账面数
    if (sysNumCell != null) {
    double sysNum = sysNumCell.getNumericCellValue();
    if (sysNum != 0) {
    result.setSysNum(String.valueOf(sysNum));
    }
    } HSSFCell factNumCell = row.getCell((short) 8);// 实际盘点数
    if (factNumCell != null) {
    double fn_cell = factNumCell.getNumericCellValue();
    if (fn_cell != 0) {
    result.setFactNum(String.valueOf(fn_cell));
    }
    } HSSFCell balanceCell = row.getCell((short) 9);// 差异数
    if (balanceCell != null) {
    double balance = balanceCell.getNumericCellValue();
    if (balance != 0) {
    result.setBalance(String.valueOf(balance));
    }
    } HSSFCell resultCell = row.getCell((short) 10);// 盘查结果
    if (resultCell != null) {
    String results = resultCell.getStringCellValue();
    if (results.trim() != null) {
    result.setResult(results);
    }
    } HSSFCell reseanCell = row.getCell((short) 11);// 原因
    if (reseanCell != null) {
    String resean = reseanCell.getStringCellValue();
    if (resean.trim() != null) {
    result.setResean(resean);
    }
    }
    }
    tmplist.add(result);
    }
    // reports = dao.getObjects(Report.class);
    IQueryBuilder builder = new QueryBuilderImpl(Report.class);
    SystemUser systemUser = getOperator();
    if (systemUser != null) {
    builder.eq("company.id", systemUser.getCompany().getId());
    Department department = systemUser.getDepartment();
    if (department != null) {
    builder.eq("department.id", department.getId());
    }
    }
    reports = dao.find(builder);

    getSession().setAttribute(IConstants.RESULT_LIST, tmplist);

    /**** ***/
    int count;
    int endcount;
    count = tmplist.size();
    page = new Page(count , currPage);
            currPage = page.getCurrPage();
            if(count < page.getPageSize()+page.getStartIndex())
             endcount = count;
            else
             endcount = page.getPageSize()+page.getStartIndex();
           
    resultList = tmplist.subList(page.getStartIndex(), endcount);

    return "upload";
    }