Error: java.lang.OutOfMemoryError when uploading CSV files to web server

Hi experts,
I have made a JSP page from which clients load csv files to web server. I am using Tomca 4.1 as my web server and JDK 1.3.1_09.
The system works fine when uploadiing small csv files, but it crashes when uploading large CSV files.
It gives me the following error:
java.lang.OutOfMemoryError
     <<no stack trace available>>
This is the code that I used to load files....
<%
String saveFile = "";
String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
     DataInputStream in = new DataInputStream(request.getInputStream());
     int formDataLength = request.getContentLength();
     byte dataBytes[] = new byte[formDataLength];
     int byteRead = 0;
     int totalBytesRead = 0;
     while (totalBytesRead < formDataLength)
          byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
          totalBytesRead += byteRead;
     String file = new String(dataBytes);
     saveFile = file.substring(file.indexOf("filename=\"") + 10);
     saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
     saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
     int lastIndex = contentType.lastIndexOf("=");
     String boundary = contentType.substring(lastIndex + 1,contentType.length());
     int pos;
     pos = file.indexOf("filename=\"");
     pos = file.indexOf("\n", pos) + 1;
     pos = file.indexOf("\n", pos) + 1;
     pos = file.indexOf("\n", pos) + 1;
     int boundaryLocation = file.indexOf(boundary, pos) - 4;
     int startPos = ((file.substring(0, pos)).getBytes()).length;
     int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
     String folder = "f:/Program Files/Apache Group/Tomcat 4.1/webapps/broadcast/file/";
     //String folder = "10.28.12.58/bulksms/";
     FileOutputStream fileOut = new FileOutputStream(folder + saveFile);
     //out.print("Saved here: " + saveFile);
     //fileOut.write(dataBytes);
     fileOut.write(dataBytes, startPos, (endPos - startPos));
     fileOut.flush();
     fileOut.close();
     out.println("File loaded successfully");
//f:/Program Files/Apache Group/Tomcat 4.1/webapps/sms/file/
%>
Please can anyone help me solve this problem for me...
Thanx...
Deepak

I know it may be hard to throw away all this code, but consider using the jakarta fileupload component.
I think it would simplify your code down to
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request
List /* FileItem */ items = upload.parseRequest(request);
// Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
    FileItem item = (FileItem) iter.next();
    if (item.isFormField()) {
        processFormField(item);
    } else {
        // item is a file.  write it
        File saveFolder = application.getRealPath("/file");          
        File uploadedFile = new File(saveFolder, item.getName());
        item.write(uploadedFile);
}Most of this code was hijacked from http://jakarta.apache.org/commons/fileupload/using.html
Check it out. It will solve your memory problem by writing the file to disk temporarily if necessary.
Cheers,
evnafets

Similar Messages

  • Error "java.lang.OutOfMemoryError" When Returning Large Number of Docs

    In our SES implementation, we have a custom search interface that allows users to search for documents and then add them to a "shopping cart". Users add then to their shopping cart from search results, by adding docs one-by-one or an Add All option. Once they are done "shopping" they create a report.
    Here is the scenario...
    Users are saerching for documents and seeing that on page 1, there is 1 - 10 of about 300 results. They clicked Add All and want all 300 docs added to their cart.
    What we do under the covers is we execute another search and set the docs requested to 200. We get the array of docs, iterate over them and add the keys to a list. We found 200 docs at a time to be a safe number. However, there are still 100 docs that were not added to their cart and users want all 300 added. In other words, when they click Add All, they want to add all docs, 300, 500, 5000, etc.
    I set the "Maximum Number of Results" to 500 and found that I can safely add up to ~ 350 docs at one time. However, going past this point throws the following error:
    [SOAPException: faultCode=SOAP-ENV:Server; msg= [java.lang.OutOfMemoryError]]
         at oracle.search.query.webservice.client.OracleSearchService.makeSOAPCallRPC(OracleSearchService.java:941)
         at oracle.search.query.webservice.client.OracleSearchService.doOracleSearch(OracleSearchService.java:469)
    After this error is thrown, SES was unable to recover and searching would not work anymore, even return 10 docs at a time. We had to restart SES to resolve the issue.
    1. What is throwing this error? Is it the amount of XML being returned?
    2. What is the maximum number of results we can get back at any one time? Is it based on the amount of data being returned or the number of attributes?
    We are running 10.1.8 with plans to upgrade soon.
    Thanks in advance.

    I know it may be hard to throw away all this code, but consider using the jakarta fileupload component.
    I think it would simplify your code down to
    // Create a factory for disk-based file items
    FileItemFactory factory = new DiskFileItemFactory();
    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);
    // Parse the request
    List /* FileItem */ items = upload.parseRequest(request);
    // Process the uploaded items
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();
        if (item.isFormField()) {
            processFormField(item);
        } else {
            // item is a file.  write it
            File saveFolder = application.getRealPath("/file");          
            File uploadedFile = new File(saveFolder, item.getName());
            item.write(uploadedFile);
    }Most of this code was hijacked from http://jakarta.apache.org/commons/fileupload/using.html
    Check it out. It will solve your memory problem by writing the file to disk temporarily if necessary.
    Cheers,
    evnafets

  • Big ANE causes java.lang.OutOfMemoryError when packaging Air application

    Hi,
    I'm working on an Air mobile game that uses ANE on iOS and Android. I'm in the process of creating a new ANE and face a problem on the Android side.
    My ANE requires an external framework (Burstly, http://burstly.com). If I just link the Android project to Burstly's .jar file, I get errors in "adb logcat", like:
    I/dalvikvm(16074): Could not find method com.burstly.lib.BurstlySdk.init, referenced from method com.freshplanet.burstly.functions.InitBurstlyFunction.call
    In order to include Burstly's files in my own .jar, I unzip Burstly's .jar file and repackage them with my compiled code in a unique .jar (following advice on http://stackoverflow.com/questions/7732742/air-3-native-extensions-for-android-can-i-how-t o-include-3rd-party-libraries).
    Problem: Burstly's SDK includes thousands of files. It doesn't create any trouble when packaging the ANE, but when I try to package the Air application, I get the following error:
    dx tool failed:
    UNEXPECTED TOP-LEVEL ERROR:
    java.lang.OutOfMemoryError: Java heap space
              at com.android.dx.util.IntList.<init>(IntList.java:87)
              at com.android.dx.rop.code.RopMethod.calcPredecessors(RopMethod.java:174)
              at com.android.dx.rop.code.RopMethod.labelToPredecessors(RopMethod.java:95)
              at com.android.dx.ssa.back.IdenticalBlockCombiner.process(IdenticalBlockCombiner.java:74)
              at com.android.dx.ssa.back.SsaToRop.convert(SsaToRop.java:132)
              at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:76)
              at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:103)
              at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:74)
              at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:269)
              at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
              at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
              at com.android.dx.command.dexer.Main.processClass(Main.java:299)
              at com.android.dx.command.dexer.Main.processFileBytes(Main.java:278)
              at com.android.dx.command.dexer.Main.access$100(Main.java:56)
              at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:229)
              at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
              at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
              at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
              at com.android.dx.command.dexer.Main.processOne(Main.java:247)
              at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
              at com.android.dx.command.dexer.Main.run(Main.java:139)
              at com.android.dx.command.dexer.Main.main(Main.java:120)
              at com.android.dx.command.Main.main(Main.java:89)
    I read that the solution to eliminate this error is to give Java the parameters "-Xms...M -Xmx...M", with "..." being a high-enough number. Note that I'm working on a machine with 8GB of RAM. I tried to package the app in command line to be able to pass these parameters:
    /usr/bin/java -Xms512M -Xmx4096M -jar "/Applications/Adobe Flash Builder 4.6/sdks/4.6.0air31/lib/adt.jar" -package -target apk -storetype pkcs12 -keystore [...].p12 Main.apk Main-app.xml Main.swf -extdir "/Users/alex/Documents/Adobe Flash Builder 4.6/.metadata/.plugins/com.adobe.flexbuilder.project.ui/ANEFiles/front-end-mobile/com.ado be.flexide.multiplatform.ios.platform"
    But when I run a "ps -ef | grep java", I can see that adt runs another Java program (dx) without transmitting my -Xms -Xmx parameters:
    /usr/bin/java -jar /Applications/Adobe Flash Builder 4.6/sdks/4.6.0air31/lib/android/bin/dx.jar --dex --output=/private/var/folders/t9/3kw74cx14nv2xg9tgmx9m1jc0000gp/T/b5757d93-1e93-439c-8f6d -c93e4933f6f1/outputDEX.dex [... bunch of jars]
    Any idea to solve this issue?
    Thanks
    Alex

    I solved my issue by setting the _JAVA_OPTIONS environment variable. (Note: there are two underscores)
    I added the following line to my .bash_profile:
    export _JAVA_OPTIONS="-Xms1024m -Xmx4096m -XX:MaxPermSize=512m"
    Now everytime a Java program is launched from the command line, I see the following message:
    Picked up _JAVA_OPTIONS: -Xms1024m -Xmx4096m -XX:MaxPermSize=512m
    And my application packaging runs just fine now.
    I still have an issue though: this trick solved the problem for packaging the app from the command line, but the _JAVA_OPTIONS are not picked up when packaging from Flash Builder, so it still crashes there.
    Note that my Adobe Flash Builder 4.6.ini contains the following options:
    -Xms512m
    -Xmx1676m
    -XX:MaxPermSize=512m
    -XX:PermSize=64m
    1676m is the highest number I can put before Flash Builder refuses to launch. I'm not sure if these parameters are actually passed to the VM that runs de dx.jar program, or if it's just for the ActionScript compiler. But anyway my app packaging still crashes in Flash Builder.
    If someone knows a way to force Flash Builder to pickup the _JAVA_OPTIONS set in the command line, let me know :-)
    Thanks
    Alex

  • Deployment Error -- JSP Compilation Error: java.lang.OutOfMemoryError -- nu

    When I deploy WAR files with the precompile jsp option, I receive the following error:
    Deployment Error -- JSP Compilation Error: java.lang.OutOfMemoryError -- null
    Is there a way for me to precompile my jsp's without using this process? Once this blows up, the admin server gets hosed. This is very frustrating. Any suggestions would be appreciated.
    Regards,
    Joshua

    You need little more memory :-), use java param -mx512M.
    You can adjust it in OC Server properties
    AS > OC4J_home(demo) > Server Properties
    section Multiple VM Configuration, Command Line Options
    Java Options: -mx512M
    Zajo

  • How to avoid the run time error  "java.lang.OutOfMemoryError"

    hi
    i have written a code to read a txt file ,i used FileReader to read a file . the code is working well for small txt files. but when i tried to read a large file(greater than 2MB), a run time error called "java.lang.OutofMemoryError" appeared .
    plz suggest the methods to read txt files of large capacity(greater than 25MB) .if possible give an example.

    thanks for ur replies
    i am new to java programming .i am a student persuing B.Tech final semester .i got struck in my project while reading a large txt file(greater than 3MB) . i am now giving a part of code that i had used in my project .it working fine with the txt files less than 3MB ,but when i am treing to read a file greater than 3MB , it is displaying a run time error "java.lang.outofmemoryerror"
    i have tried using "java -Xmx" ,it is working , but is there any better option ??
    here is the part of code:
       FileReader fin;
        al=new ArrayList();
         try
              fin=new FileReader(filename);
         catch(FileNotFoundException e)
           System.out.println("File not foumn");
         return;
    while((i=fin.read())!=-1)
           al.add(new Character((char)i));
         fin.close(); 
         Object obj[]=al.toArray();plz help me
    --santosh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Tomcat Error: "java.lang.OutOfMemoryError: Java heap space"

    Hi,
    We are on BOXI 3.1 SP3. We are using Tomcat as a application server.
    After certain time interval tomcat server hangs and users are unable to login to Infoview. When we checked in catalina.out file, we got error "java.lang.OutOfMemoryError: Java heap space". As a workaround, we restart tomcat server. That time we are unable to stop tomcat server using tomcatshutdown.sh script and we need to kill it forcefully. Once we restart the tomcat server, occupied memory free up and users are able to login to Infoview.
    Below are my observations on this issue:
    1. We have observed that this is not happening only during peak time/heavy load on system, but is happening during weekend as well which shows that it is not related to user load.
    2. Issue occurs intermittently.
    3. Tomcat is unable to release unused memory. It just adds the memory and reaches it's maximum allocated memory.
    I raised SAP case for this and they suggested to add parallet garbage collector parameter. but that did not help.
    Below is heap size setting for Java under /Install Dir/setup/env.sh:
    JAVA_OPTS="$JAVA_OPTS -Xmx1024m -XX:MaxPermSize=256m -XX:+UseParallelGC"
    Below are my environment details:
    Product : BOXI R3.1 SP3
    Linux: Redhat 5.3
    RAM: 10 GB
    Web Application Server : Apache - Tomcat
    I am thinking that somehow tomcat is unable to free up it's occupied memory which is not used by any object further. It just keeps adding memory and reaches its maximum threshold limit which is 1024 MB.
    We have installed SP3 on server last Sunday. Issue was there before SP3 installation as well and it was occuring very rarely. But after SP3 installation, it is occuring on daily basis. Is there any known bug in SP3.
    Any help would be greatlt appericiated.
    Thanks,
    Swapnil Rodge.

    Hi Sebastian,
    Did you use the -Xmx2048m setting for Tomcat? If yes, how did it work for you? When I do the same tomcat refuses to start.
    Thanks,
    Vinayak

  • Java.lang.OutOfMemoryError when click on the  "performance" tab in dbconsol

    THis is 10.2.0.3 DB on Oracle-Linux Rel5. I got the error "java.lang.OutOfMemoryError" in "emoms.log" whenever I click on the "performance" Tab in DBCONSOLE. The rest of the dbconsole features is working fine.
    Please help...
    Thanks!

    It was and Oracle bug#6469196/5880921. I installed patch#5880921 and It foxed the proble.

  • Error 500--Internal Server Error  java.lang.OutOfMemoryError: PermGen space

    I use Jdeveloper 11g to create and run simple ADF application.
    However, it always shows the error of java.lang.OutOfMemoryError.
    I have to restart Jdeveloper.
    Could anyone tell me how to avoid this problem?
    Error 500--Internal Server Error
    java.lang.OutOfMemoryError: PermGen space
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:335)
         at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:288)
         at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:335)
         at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:288)
         at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:335)
         at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:288)
         at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

    Hello,
    This is fixed now,
    1. cleared the classpath in the environment variables(my computer) ,
    2. uninstalled jdev and weblogic,
    3. deleted the oracle/middleware folder
    4. searched under registry entries as middleware and deleted all of them,
    5. rebooted and reinstalled, worked...
    Thanks for your inputs...............

  • Error: java.lang.NoClassDefFoundError when Automatic Import Service loads

    Hi
    The netware server running NW 6.5sp4a has been reloaded due to hardware
    failure.
    All the data was restored to all volumes.
    When I run zfdstart I get the following error:
    error: java.lang.NoClassDefFoundError when Automatic Import Service loads.
    Help !!!
    Thanks
    Minesh

    [email protected] wrote:
    > error: java.lang.NoClassDefFoundError when Automatic Import Service loads.
    hmm... would say that the zeninstall wasn't correctly done... try
    reinstalling importing..
    Marcus Breiden
    If you are asked to email me information please change -- to - in my e-mail
    address.
    The content of this mail is my private and personal opinion.
    http://www.edu-magic.net

  • How to solve 'java/lang/OutOfMemoryError' when apply weblogic patch 10.3.6.0.10?

    Hi All:  Our platform is IBM AIX power system 64 bit, os level 6.  Oracle Fusion Middleware version is 10.3.6.0.8.  We tried to patch 10.3.6.0.10 on it, but encounter ‘out of memory error’ when  applied WebLogic patch 10.3.6.0.10 on UAT report server.  Currently UAT has 3GB memory (currently is 3G) .
    JVMDUMP006I Processing dump event "systhrow",
    detail "java/lang/OutOfMemoryError
    JVMDUMP032I JVM requested Heap dump using
    '/ora_bin01/u01/oracle/Middleware/utilhd' in response to an event
    JVMDUMP010I Heap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/heapdump.20150224.152727.6422620.0001.phd
    JVMDUMP032I JVM requested Java dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152727.6422620.0002.txt'
    in response to an event
    JVMDUMP010I Java dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152727.6422620.0002.txt
    JVMDUMP032I JVM requested Snap dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152727.6422620.0003.trc'
    in response to an event
    JVMDUMP006I Processing dump event "systhrow",
    detail "java/lang/OutOfMemoryError" - please wait.
    JVMDUMP010I Snap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152727.6422620.0003.trc
    JVMDUMP013I Processed dump event "systhrow",
    detail "java/lang/OutOfMemoryError".
    JVMDUMP032I JVM requested Heap dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/heapdump.20150224.152735.6422620.0004.phd'
    in response to an event
    JVMDUMP010I Heap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/heapdump.20150224.152735.6422620.0004.phd
    JVMDUMP032I JVM requested Java dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152735.6422620.0005.txt'
    in response to an event
    JVMDUMP010I Java dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/javacore.20150224.152735.6422620.0005.txt
    JVMDUMP032I JVM requested Snap dump using
    '/ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152735.6422620.0006.trc'
    in response to an event
    Exception in thread "main"
    java.lang.OutOfMemoryError at
    java.lang.StringBuffer.ensureCapacityImpl(StringBuffer.java:335)
    at
    java.lang.StringBuffer.append(StringBuffer.java:201)
    at
    java.lang.Class.throwNoSuchMethodException(Class.java:278)
    at
    java.lang.Class.getMethod(Class.java:845)
    at
    com.bea.cie.common.dao.xbean.XBeanDataHandler.isValueSet(XBeanDataHandler.java:958)
    at
    com.bea.cie.common.dao.xbean.XBeanDataHandler.getValueFromObject(XBeanDataHandler.java:589)
    at
    com.bea.cie.common.dao.xbean.XBeanDataHandler.getSimpleValue(XBeanDataHandler.java:431)
    at
    com.bea.plateng.patch.dao.cat.PatchDependency.getRule(PatchDependency.java:48)
    at
    com.bea.plateng.patch.dao.cat.PatchCatalogHelper.getInvalidatedPatchMap(PatchCatalogHelper.java:1625)
    at com.bea.plateng.patch.PatchSystem.updatePatchCatalog(PatchSystem.java:436)
    at
    com.bea.plateng.patch.PatchSystem.refresh(PatchSystem.java:130)
    at
    com.bea.plateng.patch.PatchSystem.setCacheDir(PatchSystem.java:201)
    at
    com.bea.plateng.patch.Patch.main(Patch.java:281)
    JVMDUMP010I Snap dump written to
    /ora_bin01/u01/oracle/Middleware/utils/bsu/Snap.20150224.152735.6422620.0006.trc
    JVMDUMP013I Processed dump event "systhrow",
    detail "java/lang/OutOfMemoryError".
    Exception in thread "Attach API wait loop"
    java.lang.OutOfMemoryError
       at
    com.ibm.tools.attach.javaSE.CommonDirectory.waitSemaphore(CommonDirectory.java:222)
    at
    com.ibm.tools.attach.javaSE.AttachHandler$WaitLoop.waitForNotification(AttachHandler.java:329)
    at com.ibm.tools.attach.javaSE.AttachHandler$WaitLoop.run(AttachHandler.java:396)
    bsu.sh -install -patch_download_dir=/ora_bin01/u01/oracle/Middleware/utils/bsu/cache_dir -patchlist=12UV -prod_dir=/ora_bin01/u01/oracle/Middleware/wlserver_10.3
    we followed the README.txt instructions, and stop/start weblogic service before/after apply patch. Can anyone suggest a solution or Doc ID for helping us?
    thank you very much!

    Solutions: Bounce the applications and check the arguments if you can increase it.  It is due to memory issue
    You can set these values in CommEnv.sh (.cmd for windows) file located in the weblogic_home/common/bin directory.
    This gets applied to all the domains under that wls home.
    If you want to make the changes to specific domain then edit the SetDomainEnv.sh file located under the domain/bin directory.
    How to solve java.lang.OutOfMemoryError: Java heap space
    solutions:  export JVM_ARGS="-Xms1024m -Xmx1024m"
    How to solve java.lang.OutOfMemoryError: PermGen space
    solution : export JVM_ARGS="-XX:PermSize=64M -XX:MaxPermSize=256m"

  • Getting java.lang.OutOfMemoryError when updating our application

    Hi Experts,
    When we update our application which is an heavy EAR file we get the following errors in the logs. But the same applications works well when we deploy it for the first few times why is this happening we have enough space in RAM still we get this error and when we restart our server it again works for sometime.
    ServletContext@16428923[app:jccrbxt module:jccrbxt path:/jccrbxt spec-version:null]] Root cause of ServletException.
    java.lang.OutOfMemoryError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:328)
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:285)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
    at weblogic.servlet.jsp.JspClassLoader.findClass(JspClassLoader.java:48)
    at weblogic.servlet.jsp.JspClassLoader.loadClass(JspClassLoader.java:33)
    at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:531)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:281)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:216)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
    at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174)
    at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
    at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:192)
    at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
    at org.springframework.security.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:99)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:527)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)
    Thanks

    Hi,
    Now as you can see that you are getting *"java.lang.OutOfMemoryError: PermGen space"* during the activation on an application it means that you are application needs more space in the non-heap part of the JVM which is PermGen to create the Classes, Class Structures, Methods and Reflection Objects of this applications hence you are getting this issue.
    Now how to solve this issue you try the following check list which would help you resolve this issue and overcome same type of issue in future
    Point-1). Make Sure that the PermGen Area is not set to a very less value.
    Point-2). Usually if an Application has Many JSP Pages in that case every JSP will be converted to a *.class file before JSP Request Process. So a large number of JSPs causes generation of a Large number of *.class files all these classes gets loaded in the PermGen area.
    Point-3). While allocating the -XX:MaxPermSize make sure that you follow a rough Formula… which works in most of the Application Servers.
    MaxPermSize = (Xmx/3) —- Very Special Cases (One Third of maximum Heap Size)
    MaxPermSize = (Xmx/4) —- Recommended (One Fourth Of maximum Heap Size
    To get more information on this I would suggest you to have look at the below link which would surely help you in this case
    Topic: OutOfMemory Causes and First Aid Steps?
    http://middlewaremagic.com/weblogic/?p=4464
    Regards,
    Ravish Mody

  • Java.lang.OutOfMemoryError when viewing JSP with records from Oracle DB

    Hi,
    I did an import of data from my damp file.I have exported the file from my other Oracle10g database I have the following error after I try to access data from my table I populated with import:
    javax.servlet.ServletException: Servlet execution threw an exception
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    java.lang.OutOfMemoryError: Java heap space
         oracle.jdbc.driver.DateTimeCommonAccessor.getDate(DateTimeCommonAccessor.java:105)
         oracle.jdbc.driver.OracleResultSetImpl.getDate(OracleResultSetImpl.java:737)
         oracle.jdbc.driver.OracleResultSet.getDate(OracleResultSet.java:1637)
         org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getDate(DelegatingResultSet.java:255)
         com.myapp.app.OrderHelper.getAllOrders(OrderHelper.java:4137)
         com.myapp.app.GetOrderDO.execute(GetOrderDO.java:172)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    a fragment of my OrderHelper with line where error occurs (line 4137):
    public class Orders {
    public List getAllOrders(){
    List lineOrders = new ArrayList();
    Connection conn = null;
    Statement stat = null;
    ResultSet rst = null;
    OrdersDTO order = null;
    String select = "SELECT * FROM TBL_ORDERS";
    DbConnection dbConn = new DbConnection();
    try {
    conn = dbConn.getDbConnection(Constants.MY_JNDI);
    stat = conn.createStatement();
    rst = stat.executeQuery(select);
    while(rst.next()){
    order = new OrdersDTO();
    order.setOrderAsmtDate(rst.getDate("order_asmt_date"));////line: 4137
    lineOrders.add(order);
    }catch (SQLException ex) {
    ex.printStackTrace();
    } finally{
    SQLHelper.cleanUp(rst, stat, conn);
    return lineOrders;
    GetOrderDO.java is just my action class which calls the getAllOrders method for my JSP to list orders. Am using Apache Tomcat/5.5.17 and struts 1.2.9 and Orcale10g.
    thnx,
    xsiyez

    thank you Avi and Bipin for the responce. I have installed Oracle on my RedHat Enterprise Linux 4 box and did an export of the TBL_ORDERS table from my database on Windows Vista . Am not getting this error when running my application on this machine. I get the error on when I run it on windows vista where I have also installed Oracle 10g and running tomcat.
    Yes Avi the ArrayList object is actually getting to big. Its returning more than 100 000 rows. I am using displaytag to do pegination. Any guidelines on how I can increase jvm heap memory on of tomcat?
    Thanx.

  • Weblogic server start error: java.lang.OutOfMemoryError

    Hi:
              when i start weblogic server, i met following error !
              java.lang.OutOfMemoryError
              <<no stack trace available>>
              why?
              thanks!
              starting output as follow :
              C:\bea7\user_projects\zhudomain>startweblogic
              C:\bea7\user_projects\zhudomain>echo off
              CLASSPATH=C:\bea7\jdk131_03\lib\tools.jar;C:\bea7\weblogic700\integration\li
              b\wl
              pi-worklist.jar;C:\bea7\weblogic700\samples\server\eval\pointbase\lib\pbserv
              er42
              ECF172.jar;C:\bea7\weblogic700\server\lib\weblogic_sp.jar;C:\bea7\weblogic70
              0\se
              rver\lib\weblogic.jar;
              PATH=.;C:\bea7\weblogic700\server\bin;C:\bea7\jdk131_03\bin;C:\PROGRA~1\RATI
              ONAL
              \RATION~1\NUTCROOT\bin;C:\PROGRA~1\RATIONAL\RATION~1\NUTCROOT\bin\x11;C:\PRO
              GRA~
              1\RATIONAL\RATION~1\NUTCROOT\mksnt;c:\Oracle\Ora81\bin;C:\WINNT\system32;C:\
              WINN
              T;C:\WINNT\System32\Wbem;C:\PROGRA~1\ULTRAE~1;C:\CTEX\MiKTeX\TeXMF\miktex\bi
              n;C:
              \CTEX\MiKTeX\LocalT~1\cct\bin;C:\Program Files\Rational\common;C:\Program
              Files\
              Rational\ClearQuest;C:\Program Files\Rational\Rose\TopLink\;C:\Program
              Files\Rat
              ional\Rational Test;C:\bea7\jdk131_03\bin
              * To start WebLogic Server, use a username and *
              * password assigned to an admin-level user. For *
              * server administration, use the WebLogic Server *
              * console at http://[hostname]:[port]/console *
              C:\bea7\user_projects\zhudomain>"C:\bea7\jdk131_03\bin\java" -hotspot -Xms32
              m -X
              mx200m -Dweblogic.security.SSL.trustedCAKeyStore=C:\bea7\weblogic700\server\
              lib\
              cacerts -Dweblogic.Name=myserver -Dbea.home="C:\bea7" -Dweblogic.management.
              user
              name= -Dweblogic.management.password= -Dweblogic.ProductionModeEnabled= -Dja
              va.s
              ecurity.policy="C:\bea7\weblogic700\server\lib\weblogic.policy"
              weblogic.Server
              <2002-11-13 ÏÂÎç04ʱ21·Ö01Ãë> <Info> <Security> <090065> <Getting boot
              identity
              from user.>
              Enter username to boot WebLogic server:system
              Enter password to boot WebLogic server:
              Starting WebLogic Server...
              <2002-11-13 ÏÂÎç04ʱ21·Ö08Ãë> <Notice> <Management> <140005> <Loading
              configurat
              ion C:\bea7\user_projects\zhudomain\.\config.xml>
              java.lang.OutOfMemoryError
              <<no stack trace available>>
              

    Hi JLK,
    Now as you can see that you are getting "java.lang.OutOfMemoryError: PermGen space" during the activation on an application it means that you are application needs more space in the non-heap part of the JVM which is PermGen to create the Classes, Class Structures, Methods and Reflection Objects of this applications hence you are getting this issue.
    Now how to solve this issue you try the following check list which would help you resolve this issue and overcome same type of issue in future
    1). Make Sure that the PermGen Area is not set to a very less value.
    2). Usually if an Application has Many JSP Pages in that case every JSP will be converted to a *.class file before JSP Request Process. So a large number of JSPs causes generation of a Large number of *.class files all these classes gets loaded in the PermGen area.
    3). While allocating the -XX:MaxPermSize make sure that you follow a rough Formula… which works in most of the Application Servers.
    MaxPermSize = (Xmx/3) —- Very Special Cases (One Third of maximum Heap Size)
    MaxPermSize = (Xmx/4) —- Recommended (One Fourth Of maximum Heap Size
    To get more information on this I would suggest you to have look at the below link which would surely help you in this case
    Topic: OutOfMemory Causes and First Aid Steps?
    http://middlewaremagic.com/weblogic/?p=4464
    Regards,
    Ravish Mody

  • BPEL 10.1.3.x deployment error: java.lang.OutOfMemoryError: Java heap spac

    I am using IBPELDomainHandle.deploySuitcase() API to deploy a bpel process. Each time, I got ServerException with the following error message: java.lang.OutOfMemoryError: Java heap spac
    What configurations should I perform to the BPEL server in order to get rid of the outofmemeory error?
    BTW: I was able to deploy the same bpel process by uploading the jar file to $OH/bpel/domains/default/deploy directory.
    Thanks,
    Qian

    Hi Qian,
    Check the -Xmx JVM setting in the OC4J_BPEL configuration. Raise the amount of MB to allow JVM to use more memory.
    Regards,
    René

  • Servlet.service() Error. java.lang.OutOfMemoryError: Java heap space

    Hi All,
    I would be very grateful if you would draw some light for this error I got from running a online database connected image viewer (applet).
    The application is quite simple, applet connect to servlet, servlet send 3 SQL statements to MySQL and retrieve image info (Strings) and 50 Files (- JPEG image) from a online database, and then pass all of data to applet from servlet. The size of total of images is around 3.5 MB, and I've increased JVM memory to 128 MB by using code "-xmx128m".
    ? Do I need send images from servlet to applet individually rather than push them in one go
    ? Is there memory leak in my codes
    Please see the codes below:
    private ExamViewerApplet.CaseInfo[] getCaseInfoArray(int examID, Connection conn) throws SQLException{...}   
    private ExamViewerApplet.ExamInfo getExamInfo(int examID, Connection conn) throws SQLException{...}
    private String processObject(Object object, ObjectOutputStream oos)    {
        Integer examID = (Integer) object;
        Connection conn  = null;    
        ExamViewerApplet.ExamInfo examInfo = null;
        ExamViewerApplet.CaseInfo caseInfoArray[] = null;
        int[][] imageIndexArray = new int[30][5];
        ImageIcon[] imageArray = null;
        try {
            conn = new DBConnection().getConnection();
            examInfo = this.getExamInfo(examID, conn);
            caseInfoArray = this.getCaseInfoArray(examID, conn);
            PreparedStatement ps = conn.prepareStatement(RETRIEVE_IMAGES);
            ps.setInt(1,examID);
            ResultSet rs = ps.executeQuery();
            rs.last();
            int size = rs.getRow();
            rs.beforeFirst();
            imageArray = new ImageIcon[size];
            int imageIndex = 0;
            while(rs.next()){
                int caseID = rs.getInt("CaseID");
                int imageID = rs.getInt("ImageID");
                InputStream stream = null;
                ByteArrayOutputStream output = null;
                try {
                    stream = rs.getBinaryStream("Image");
                    output = new ByteArrayOutputStream();
                    byte buf[] = new byte[1024];
                    int len;
                    while((len = stream.read(buf)) > 0){
                        output.write(buf, 0, len);
                    ImageIcon icon = new ImageIcon(output.toByteArray());
                    imageArray[imageIndex] = icon;
                    imageIndexArray[caseID][0] += 1;
                    imageIndexArray[caseID][imageID] = imageIndex;
                    ++imageIndex;
                } catch (IOException ex) {
                    log("Error, when reading byte array from image input stream from database");
                } finally{
                    try {
                        stream.close();
                        output.close();
                    } catch (IOException ex) {
                        log("Error, when tring to close image input stream from Database");
        } catch (ClassNotFoundException classNotFoundException) {//somecode...
        } catch (SQLException sQLException) {//somecode...
        }finally{
            try {
                conn.close();
            } catch (SQLException ex) {//somecode...
        String result;
        if(examInfo != null && caseInfoArray != null && imageIndexArray != null && imageArray != null ){
            result = "The transaction was successed!";
            try {
                oos.writeObject(examInfo);
                oos.writeObject(caseInfoArray);
                oos.writeObject(imageIndexArray);
                oos.writeObject(imageArray);
            } catch (IOException ex) {
                result = "The transaction was failed!";
        }else{
            result = "The transaction was failed!";
        return result;
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {      
        ObjectInputStream inputStreamFromApplet = null;
        Object object = null;
        try {
            inputStreamFromApplet = new ObjectInputStream(request.getInputStream());
            object = inputStreamFromApplet.readObject();
            ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
            String returnValue = this.processObject(object, oos);           
            oos.writeObject(returnValue);
            oos.flush();
            oos.close();       
        } catch (ClassNotFoundException classNotFoundException) {
            classNotFoundException.printStackTrace();
        } finally{            
            inputStreamFromApplet.close();
    } And the error messages I got here is:
    SEVERE: Servlet.service() for servlet ExamViewerServlet threw exception
    java.lang.OutOfMemoryError: Java heap space
            at javax.swing.ImageIcon.writeObject(ImageIcon.java:411)
            at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:592)
            at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
            at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
            at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
            at ExamViewerServlet.processObject(ExamViewerServlet.java:147)
            at ExamViewerServlet.processRequest(ExamViewerServlet.java:176)
            at ExamViewerServlet.doPost(ExamViewerServlet.java:217)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
            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.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            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:849)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
            at java.lang.Thread.run(Thread.java:595)Please help.
    Linqing
    Edited by: discovery_java on Feb 1, 2010 2:12 PM

    wire the code into a simple unit test, then run a profiler on it to see where the memory is going. You need the help of these kind of tools to track down memory issues, before that it is only guesswork what might be soaking it all up.

Maybe you are looking for