Java.lang.outofmemory exception

Hello,
I have an application, that writes several thousands of records into a file and transfers the same to the server. I am encountering an exception "java.lang.OutOfMemoryError" exception.
I had checked this forum earlier and found a solution that recommended an increase in the memory slot allocated to the JVM. Despite, an increase in this slot from 256MB (eclipse's default) to 1024 MB, my problem still persists. I had updated the eclipse.ini field from "-vmargs -Xms40m -Xmx256m" to "-vmargs -Xms40m -Xmx1024m". Is there anything else that I need to do, to take care of this problem? I am using green threads in the application, does this have anything to do with the above mentioned exception?
Thanks!

I am using
green threads in the application, does this have
anything to do with the above mentioned exception?It wouldn't be hard to find out. Create a new java class where the main method does the same work; writing several thousands of records into a file and transferring it to the server.
Maybe it's all the other variables you have in your application that are cutting into the memory. But can you really reduce them?
Are you loading all thousands of records to memory (I'd imagine in a hashmap or a list) all at once? Like said, do this in smaller chunks, store the records in memory just one at a time and see if that works. It will be slow but it won't run out of memory. Then increase your "batch size" until you find the optimum.

Similar Messages

  • Weblogic 8.1 SP4 getting Java.lang.outofMemory exception

    Dear experts,
    We are running WL8.1 SP4 on our Solaris 5.9 Server.
    We want to do MQ implementatin on this server and for the same some kernel parameters were changed.
    now our system has below parameters in /etc/system:
    set semsys:seminfo_semmsl=1000
    set semsys:seminfo_semvmx=32767
    set shmsys:shminfo_shmmax=4294967295
    set shmsys:shminfo_shmmin=1
    set shmsys:shminfo_shmseg=2048
    set shmsys:shminfo_shmmni=2048
    set semsys:seminfo_semmni=1024
    set semsys:seminfo_semaem=16384
    set semsys:seminfo_semmap=1026
    set semsys:seminfo_semmns=16384
    set semsys:seminfo_semopm=100
    set semsys:seminfo_semmnu=16384
    set semsys:seminfo_semume=256
    set msgsys:msginfo_msgmni=50
    set msgsys:msginfo_msgmap=1026
    set msgsys:msginfo_msgmax=4096
    set msgsys:msginfo_msgmnb=65535
    set msgsys:msginfo_msgtql=4096
    set msgsys:msginfo_msgssz=16
    set msgsys:msginfo_msgseg=8192
    set rlim_fd_cur=10000
    set rlim_fd_max=10000
    and below in /etc/profile:
    ulimit -s unlimited
    ulimit -d unlimited
    but as soon as server was rebooted and we tried to start the weblogic we got java.lang.outofmemory exception.
    details as below:
    admin_trace:
    java.lang.OutOfMemoryError
         at java.util.zip.ZipFile.open(Native Method)
         at java.util.zip.ZipFile.<init>(ZipFile.java:112)
         at java.util.zip.ZipFile.<init>(ZipFile.java:72)
         at weblogic.servlet.internal.WebAppHelper.makeImplicitMapFromJars(WebAppHelper.java:479)
         at weblogic.servlet.internal.WebAppServletContext.extractClassFiles(WebAppServletContext.java:5436)
         at weblogic.servlet.internal.WebAppServletContext.setDocroot(WebAppServletContext.java:5253)
         at weblogic.servlet.internal.WebAppServletContext.init(WebAppServletContext.java:545)
         at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:496)
         at weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:637)
         at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:619)
         at weblogic.j2ee.J2EEApplicationContainer.prepareWebModule(J2EEApplicationContainer.java:3191)
         at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.java:1581)
         at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1227)
         at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1070)
         at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareContainer(SlaveDeployer.java:2513)
         at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(SlaveDeployer.java:2463)
         at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2379)
         at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:866)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:594)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:508)
         at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    --------------- nested within: ------------------
    weblogic.management.ManagementException: [Deployer:149233]An unexpected error was encountered during the deployment process. - with nested exception:
    [java.lang.OutOfMemoryError]
         at weblogic.management.deploy.slave.SlaveDeployer.convertThrowable(SlaveDeployer.java:1017)
         at weblogic.management.deploy.slave.SlaveDeployer.access$500(SlaveDeployer.java:124)
         at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2395)
         at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:866)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:594)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:508)
         at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    managed2_trace:
    [java.lang.OutOfMemoryError].
    java.lang.OutOfMemoryError
         at java.util.zip.ZipFile.open(Native Method)
         at java.util.zip.ZipFile.<init>(ZipFile.java:112)
         at java.util.zip.ZipFile.<init>(ZipFile.java:72)
         at weblogic.servlet.internal.WebAppHelper.makeImplicitMapFromJars(WebAppHelper.java:479)
         at weblogic.servlet.internal.WebAppServletContext.extractClassFiles(WebAppServletContext.java:5436)
         at weblogic.servlet.internal.WebAppServletContext.setDocroot(WebAppServletContext.java:5253)
         at weblogic.servlet.internal.WebAppServletContext.init(WebAppServletContext.java:545)
         at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:496)
         at weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:637)
         at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:619)
         at weblogic.j2ee.J2EEApplicationContainer.prepareWebModule(J2EEApplicationContainer.java:3191)
         at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.java:1581)
         at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1227)
         at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:1070)
         at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:823)
         at weblogic.management.deploy.slave.SlaveDeployer$Application.prepare(SlaveDeployer.java:3029)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareAllApplications(SlaveDeployer.java:967)
         at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:349)
         at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229)
         at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
         at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:966)
         at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:361)
         at weblogic.Server.main(Server.java:32)
    --------------- nested within: ------------------
    weblogic.management.ManagementException: [Deployer:149233]An unexpected error was encountered during the deployment process. - with nested exception:
    [java.lang.OutOfMemoryError]
         at weblogic.management.deploy.slave.SlaveDeployer.convertThrowable(SlaveDeployer.java:1017)
         at weblogic.management.deploy.slave.SlaveDeployer.access$500(SlaveDeployer.java:124)
         at weblogic.management.deploy.slave.SlaveDeployer$Application.prepare(SlaveDeployer.java:3034)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareAllApplications(SlaveDeployer.java:967)
         at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:349)
         at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229)
         at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
         at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:966)
         at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:361)
         at weblogic.Server.main(Server.java:32)
    >
    need help to identify what exactly went wrong and where.
    Thanks

    Hi,
    As you are using WLS8.1 It means your JDK will be JDK1.4 and there is a Bug already available with JDK1.4 for the Same issue ... Please find the below link:
    http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4705373 (For Sun JDK1.4)
    AND
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6373059 (For Sun JDK 1.5.0_05)
    Please try to switch to JRockit JDK.
    Thanks
    Jay SenSharma
    http://weblogic-wonders.com/weblogic (WebLogic Wonders Are Here)

  • Why do I get  a java.lang.OutOfMemory exception

    Thanks, in advance, for you help.
    I just wrote a fairly large program. Every time I run it, I get a java.lang.OutOfMemory exception. I have no idea how to debug my code. Why would I get such an exception and how would I debug it?

    put more debug statements
    and see which line its giving that exception and see whether some where u have any line which is kind of looping or memory allocation .
    As i havent seen ur code thats vague idea iam giving
    java.lang.OutOfMemory exception is Thrown when the JVM cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.
    hope this might help

  • Java.lang outofmemory exception in IR

    Hi
       We are on XI 3.0 SP13 and involved in creating a message mapping. We have a big XCBL PO structure as the target - and while we do the mapping effort, every now and then, we get a java.lang outofmemory exception ( display error ) when we save the mapping.
    I notice that my CPU util is 100% and is taken up by javaw.exe.  I have a 1.6 G RAM desktop - but still face this problem. Any suggestions as to how to overcome this memory problem ? Am I missing any setting in my desktop ?? Or do we have to live with this problem since the target structure is a generic/big structure ??
    Thank you in advance for your time.

    Hi
    actually, this problem has nothing to do with the server at all. Also paging size and your desktop ram do not really matter. By default IB starts with the parameter -Xmx512M, what means that Java gets maximum 512M of RAM. You can change it saving JNLP file to your local file system and changing there this argument to -Xmx 800M or -Xmx 1024M.
    The second way is to reduce schema sizes. Usually there are a lot of "annotation" and "documentation" tags. They can be easily removed withoud damaging the mapping(the only problem that in design time you'll not see a documentation for fields). If you want to go this way, you can tell me and I'll find out how it can be done by some tool. Because we had this problem with other customers and as I remember there were some tool made for this purpose.
    Although it might help to install the latest SP, because there were made a number of changes to reduce a memory consumption for Message Mapping tool
    Best regards
    Dmitry

  • Cannot start OC4J instance - after java.lang.OutOfMemory errors

    Hi, I have successfully deployed an application (using Oracle Web Services, J2EE - EJB, TopLink ) to a new OC4J instance that we created. We use the OEM web site to manage the start/stop and deploy operations.
    Then we tried to run simultaneously 10 clients....against the server app... ran ok for a while and after approx. 5 to 10 min... java.lang.OutOfMemory errors were being thrown at the client.
    After a set of OutOfMemory errors, other clients received errors like the ones show below:
    Errors from the top link log
    2003.09.24 09:39:59.630--ClientSession(1337286)--Thread[ApplicationServerThread-6,5,main]--EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: Bigger type length than Maximum
    INTERNAL EXCEPTION: java.sql.SQLException: Bigger type length than Maximum
    ERROR CODE: 17412LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: Bigger type length than Maximum
    INTERNAL EXCEPTION: java.sql.SQLException: Bigger type length than Maximum
    ERROR CODE: 17412
    at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
    at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.selectOneRow(Unknown Source)
    at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRowFromTable(Unknown Source)
    at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRow(Unknown Source)
    2003.09.24 09:40:02.365--ClientSession(1337286)--Thread[ApplicationServerThread-6,5,main]--EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: Refcursor value is invalid
    INTERNAL EXCEPTION: java.sql.SQLException: Refcursor value is invalid
    ERROR CODE: 17442LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: Refcursor value is invalid
    INTERNAL EXCEPTION: java.sql.SQLException: Refcursor value is invalid
    ERROR CODE: 17442
    at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
    at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.selectOneRow(Unknown Source)
    at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRowFromTable(Unknown Source)
    at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRow(Unknown Source)
    at oracle.toplink.queryframework.ReadObjectQuery.execute(Unknown Source)
    at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
    at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
    2003.09.24 09:40:03.553--ClientSession(6073931)--Thread[ApplicationServerThread-23,5,main]--EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: Protocol violation
    INTERNAL EXCEPTION: java.sql.SQLException: Protocol violation
    ERROR CODE: 17401LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: Protocol violation
    INTERNAL EXCEPTION: java.sql.SQLException: Protocol violation
    ERROR CODE: 17401
    at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
    at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
    2003.09.24 09:41:15.173--ServerSession(3066938)--Thread[ApplicationServerThread-19,5,main]--EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-01403: no data found
    INTERNAL EXCEPTION: java.sql.SQLException: ORA-01403: no data found
    ERROR CODE: 1403LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.3 (Build 430)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-01403: no data found
    INTERNAL EXCEPTION: java.sql.SQLException: ORA-01403: no data found
    ERROR CODE: 1403
    at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
    at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
    Im not sure if this is due to a memory leak or something in my app ? Or does Oracle IAS / Toplink have any such issues for which any possible patches are available ?
    Could anyone please direct me in the possible right direction !
    Thanks,
    Krishna

    Hi,
    We have had this problem too, it only started after we deployed to production and got some load on our application server. We are using JRun as our application server.
    We found that Macromedia (JRun) already addressed the issue in general - that if you get java.lang.OutOfMemory errors, then you need to increase the heap size.
    Previously we had been using our own caching mechanism and never ran into this problem. Since we decided to go with TopLink (which has caching) we no longer use our own caching mechanism... but now we have this problem.
    We have chosen to use FullIdentityMap for caching, but didn't think we would run out of memory in the JVM. Is there a suggested or minimum JVM memory requirement to run TopLink?
    Thanks,
    Aaron

  • Java.lang.OutOfMemory error while retrieving data from a large table

    Hi,
    i am trying to fetch data using "executeQuery()" into a ResultSet from the database. But since the data in that table is large. i am recieving "java.lang.OutOfMemory" Error. So, to resolve that, i have used "setMaxRows()" for my statement object. This resolved the error but i don't recieve the entire data. If i call "executeQuery()" again, i recieve the same data. I don't even know a filtering criterion where by i can filter the data for each "executeQuery()"..
    How can i resolve this problem
    Thanx in advance
    --Chaitanya                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Either use some criteria you develop related to one of the keys on the table or use some sort of record limiting method.
    Note the method of limiting will vary related to the database you are using. You will have to look at the documentation.
    For example I am told this will work in MySQL to get 200 records starting at record 100.
    SELECT * FROM myTable ORDER BY whatever ASC LIMIT 100,200
    Because you are running out of memroy I assume the table is large,
    I am not sure what the impact of the above will have on performance because if in the above if the order by is not based on an index at the server level all the records will be selected and sorted before the records are limited.
    I would make sure you have an appropriate index.
    If you use the advanced search over the user forums using "resultset paging" and possibility the database you are using you should be able to get some ideas.
    I hope this makes sense to you.
    rykk

  • Java.lang.NullPointer Exception in File-RFC-File wtihout BPM scenario

    Hi All,
    I have implemented scenario File - RFC - File without BPM in PI7.1 according to below link by bhavesh
    [File - RFC - File without a BPM - Possible from SP 19.;
    but I am getting error java.lang.NullPointer Exception  in Audit log of sender communication channel when it enters in ResponseOnewayBean.
    I had implemented the same in PI 7.0 but there it was working fine.
    Is there any limitations on the use of the above beans in PI7.1 as I could see two more threads on the same unanswered yet.
    Please help me in resolving as it is priority task for me
    Thanks,
    Amit

    Sometime back I saved this SAP Note 1261159 for this error. Not sure if it is still valid. Try to get it implemented.
    Regards,
    Prateek

  • Java.lang.NoClassDefFoundError: Exception in thread "main"

    Hello People,
    I am aware that this topic has been raised before. I have browsed through all the postings of this particular question, but i have not found the solution.
    While compilign i get no errors but this is what i get when i run the java program.
    java.lang.NoClassDefFoundError: Exception in thread "main"
    Tool completed with exit code 1
    The following is my path and classpath files under autoexec.bat
    SET PATH=%PATH%;C:\j2sdk1.4.0_03\bin
    SET CLASSPATH=.;%CLASSPATH%;C:\j2sdk1.4.0_03\bin
    These are the settings i have in MY COMPUTER properties/environments
    SYSTEM VARIABLES
    Variable - classpath
    Value - C:\Program Files\TextPad 4
    USER VARIABLES
    Variable - PATH
    Value - C:\j2sdk1.4.0_03\bin
    SYSTEM VARIABLES
    Variable - path
    Value - C:\PROGRA~1\PVCS\VM\win32\bin;C:\WINNT4\system32;C:\WINNT4;C:\WINNT4\system32\nls\ENGLISH;C:\WINNT4\system32\nls;C:\Program Files\Rational\common
    USER VARIABLES
    Variable - PATH
    Value - C:\j2sdk1.4.0_03\bin
    I hope this infromation will help.
    Thanks
    Regards,
    Shah

    SET PATH=%PATH%;C:\j2sdk1.4.0_03\bin
    SET CLASSPATH=.;%CLASSPATH%;C:\j2sdk1.4.0_03\bin
    These are the settings i have in MY COMPUTER
    properties/environments
    SYSTEM VARIABLES
    Variable - classpath
    Value - C:\Program Files\TextPad 4I am concerned that the classpath in the autoexec.bat is different from what you posted under System variables. What version of Windows are you running? autoexec.bat is used by 98. Others use the system variables. The classpath you show for autoexec.bat looks OK but the classpath you show for system variables looks wrong. It should be the same as what you show for autoexec.bat You do not need the sdk\bin directory in your classpath unless you plan to put classes there.
    The NoClassDefFound error means that the java.exe command could not find the class that you specified. You did not post the command that you entered. You may have specified the class wrong. Otherwise, it is probably a classpath problem.

  • Java.Lang.NullPoint.Exception in OWB Mapping

    Hello Everybody
    We are building Data Warehouse using OWB Repository 9.2.0.2.0. When we are validating or deploying the created map we are getting Java.Lang.NullPoint.Exception. This leads to blank screen. We are unable to recover the map. Sometimes, synchronization works to recover the map, but not all the times.
    Is there any solution to it?

    Mark
    Is it possible to solve the problem without migrating? I have the details of error as follows --
    java.lang.NullPointerException
    java.lang.NullPointerException
         at oracle.wh.service.impl.mapping.metadata.WBMappingGraphImpl.<init>(WBMappingGraphImpl.java:43)
         at oracle.wh.service.impl.mapping.metadata.WBMappingGraphHelper.createMappingGraph(WBMappingGraphHelper.java:31)
         at oracle.wh.ui.mapping.MappingGraphNew.drawStage(MappingGraphNew.java:2660)
         at oracle.wh.ui.mapping.MappingGraphNew.setStage(MappingGraphNew.java:484)
         at oracle.wh.ui.mapping.MappingEditorCanvas.refresh(MappingEditorCanvas.java:287)
         at oracle.wh.ui.common.WhFolderEditor.refreshCanvas(WhFolderEditor.java:951)
         at oracle.wh.ui.common.WhFolderEditor.refresh(WhFolderEditor.java:604)
         at oracle.wh.ui.common.WhFolderEditor$1$MyRefresh.run(WhFolderEditor.java:424)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
    I appreciate your feedback.
    Cheers, Bana

  • Java.lang.thread exception while using Xalan 2.0 in WLS 6.0

    Hi, I'm trying to use Xalan 2.0 in a servlet hosted by WLS. Ive
    modified Xalan's SimpleTransform sample to be a servlet. I
    create a Transformer with the .xsl, then call tranform() to
    print the tranformed xml to the response stream. The xml is
    tranformed correctly, but it throws a java.lang.thread
    exception. The standalone Xalan sample doesn't do this. Anyone
    else seen this problem?
    Here's the code of interestest, I apologize if its not formatted very well:
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
         PrintWriter out = res.getWriter();
         res.setContentType("text/html");
         out.println("<html><head><title>XalanTest<title></head>");
         out.println("<body><h1>XalanTest</h1>");
         try{
         TransformerFactory tFactory = TransformerFactory.newInstance();
         StreamSource ss = new StreamSource("file:\\\\My-path\\birds.xsl");
         Transformer transformer = tFactory.newTransformer(ss);
         StreamResult SR = new StreamResult(out);
         transformer.transform(new StreamSource("file:\\\\My-path\\birds.xml"), SR );
         catch(Exception e){
         out.println("<p>" + e.toString() + "</p>");
         e.printStackTrace(out);
         out.println("<p>Exception</p>");
              out.println("</body></html>");

    It also looks like the workaround suggested does not work.
    I put the following code as workaround:
         response.setContentType("text/html");
         response.setHeader ("Pragma", "no-cache");
         Transformer transformer;
         TransformerFactory factory = TransformerFactory.newInstance();
         String stylesheet = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.xsl";
         String sourceId = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.xml";
         String outputFile = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.html";
         String outputDirectFile = "config\\closs\\applications\\webroot\\jsp\\example\\Load2_Direct.html";
         try
              PrintWriter fout = new PrintWriter (new FileOutputStream (outputFile));
              OutputStream os = new ByteArrayOutputStream();
              transformer = factory.newTransformer(new StreamSource(stylesheet));
              transformer.transform(new StreamSource(sourceId), new StreamResult(outputDirectFile));
              transformer.transform(new StreamSource(sourceId), new StreamResult(os));
              os.flush ();
              os.close();
              out.print(os.toString());
              fout.print (os.toString ());
              fout.flush ();
              fout.close ();
         catch (Exception e)
              // Error Handler
         e.printStackTrace();
    The two .html files produced look exactly the same, which is good.
    However, the screen output to my html browser (Internet Explorer 5.50 sp1) produces
    different output.
    That is strange, but that shows that this bug does not have a known workaround
    "Rabinowitz" <[email protected]> wrote:
    >
    I have the same problem with java sun xml parser (jaxp 1-1)
    It is interesting to know that all this perfectly works under weblogic
    5.1, so
    I cannot migrate my application to 6.0
    So, the functionality of weblogic 6.0 degraded since 5.1.
    I cannot buy the explanation that that is not bea's fault, because it
    perfectly
    worked with the same version of xml parser.
    Now, their customer support is saying they have not decided whether this
    is a
    bug or a feature.
    Interesting to know that degradation of functionality could be a feature!
    It is now June 21, 3 months since this bug was reported, sp2 was shipped
    since
    that time, and this bug is still there.
    "Chuck H. Zhao" <[email protected]> wrote:
    I am having the exact same problem you are having. If we analyze the
    stack
    trace:
    javax.xml.transform.TransformerException: java.lang.Thread
    at
    org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1212)
    at
    org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
    at java.lang.Thread.run(Thread.java:484)
    java.lang.ClassCastException: java.lang.Thread
    at
    weblogic.servlet.internal.ResponseHeaders.setDateHeader(ResponseHeaders.java
    :273)
    at
    weblogic.servlet.internal.ServletResponseImpl.setDateHeader(ServletResponseI
    mpl.java:449)
    at
    weblogic.servlet.internal.ServletResponseImpl.writeHeaders(ServletResponseIm
    pl.java:637)
    at
    weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamI
    mpl.java:124)
    at
    weblogic.servlet.internal.WLOutputStreamWriter.flush(WLOutputStreamWriter.ja
    va:124)
    at java.io.PrintWriter.flush(PrintWriter.java:120)
    at
    org.apache.xalan.serialize.SerializerToXML.flushWriter(SerializerToXML.java:
    1431)
    at
    org.apache.xalan.serialize.SerializerToXML.endDocument(SerializerToXML.java:
    629)
    at
    org.apache.xalan.transformer.ResultTreeHandler.endDocument(ResultTreeHandler
    ..java:180)
    at
    org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1194)
    at
    org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
    at java.lang.Thread.run(Thread.java:484)
    What happened is: to support incremental output, Xalan-Java performs
    the
    transformation in a second thread while building the source tree inthe
    main
    thread. So Transformer.transform() creates a new thread to run the
    transformer.run() method, which will write to weblogic's internal
    ServletOutputStreamImpl, and in the end calls flush() on it.
    ServletOutputStreamImpl determines that the headers haven't been written
    yet, and the headers need to be written before any servlet output, so
    it
    calls ServletResponseImpl.writeHeaders(), which eventually calls
    ResponseHeaders.setDateHeader(). The last method assumes the thread
    is
    weblogic's internal ExecuteThread and tries to cast the thread as such,
    maybe to get the date from it. But the thread is a plain java.lang.Thread
    created by xalan, thus we get the java.lang.ClassCastException:
    java.lang.Thread
    This suggests a second workaround: call ServletResponse.flushBuffer()
    before any xalan stuff, which will force the headers to be written in
    weblogic's ExecuteThread. The shortcoming of this is that this will
    cause
    the response to be commited, and if the xalan stuff throws exception
    you can
    not forward to another page.
    Another thing is that xalan should not directly call flush() on
    ServletOutputStreamImpl at all. I will report it to xalan and see if
    they
    consider that a bug. If they fix that then we have a third workaround:
    set
    the buffer size of ServletResponse big enough to accomodate everything
    including the xslt outputs, so the ServletOutput does not need to be
    flushed
    during xalan code.
    I do not consider this problem a weblogic bug, since the servlet container
    has to right to expect any thread inside it to be its own. Serlvet2.2
    spec
    says:
    1.2 What is a Servlet Container?
    A Servlet Container may place security restrictions on the environment
    that
    a servlet executes in. In
    a Java 2 Platform Standard Edition 1.2 (J2SE) or Java 2 Platform Enterprise
    Edition 1.2 (J2EE)
    environment, these restrictions should be placed using the permission
    architecture defined by Java 2
    Platform. For example, high end application servers may limit certain
    action, such as the creation of
    a Thread object, to insure that other components of the container are
    not
    negatively impacted.
    Weblogic should explicitly warn the developers that creating threads
    inside
    the servlet container may have adverse effects, the same kind of problem
    we
    are having. (or maybe they already did somewhere in their documentation?)
    On the xalan side, I would suggest them to either give the option to
    switch
    the two threads, or to give the option to buffer the output and write
    it out
    in the main thread, which is exactly what you did in your first workaround.
    Any comments or thoughts on the subject are welcome.
    -- Chuck Zhao
    "MK Parini" <[email protected]> wrote in message
    news:[email protected]...
    I found, what I think to be a bug, and a work-around for it.
    When doing an XSLT Transformation, you must specify a StreamResult
    to which to write the output. I was doing my transformation in
    a
    servlet so I was writing my output to the HttpResponse
    (The variable res is a javax.servlet.http.HttpServletResponse
    object)
    StreamResult htmlTarget = new StreamResult(res.getWriter());
    If I use this, when I perform the transformation using the TRAX
    APIs,
    InputStream xslFile = context.getResourceAsStream(fileName);
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Templates xslTemplates = tFactory.newTemplates(new StreamSource(xslFile));
    transformer = xslTemplates.newTransformer();
    transformer.transform(xmlSource, htmlTarget);
    I receive the ClassCastException from the class
    weblogic.servlet.internal.ResponseHeaders.setDateHeader(ResponseHeaders.java
    :273),
    as seen in my previous posting.
    I discovered, if I write my output to a StringBuffer, and then
    I write
    the StringBuffer to the HttpResponse, I do not get the ClassCastException.
    For example,
    StringWriter myWriter = new StringWriter(2400);
    StreamResult htmlTarget = new StreamResult(myWriter);
    <Same transformation code as above>
    myWriter.close();
    PrintWriter out = res.getWriter();
    out.print(myWriter.toString());
    Is this a bug in the weblogic internal servlet class or am I just
    missing something?
    Also, one concern that I have with the workaround is that it might
    hurt performance.
    Any comments or thoughts on the subject are welcome.

  • Java.lang.indexoutofbound Exception

    HI all
    i am trying to convert multiple jpg images to single tiff image..i am getting an exception that is
    "java.lang.indexoutofbound Exception"..can anyone help me
    import com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.Locale;
    import javax.imageio.IIOImage;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.ImageWriteParam;
    import javax.imageio.ImageWriter;
    import javax.imageio.metadata.IIOMetadata;
    import javax.imageio.stream.ImageInputStream;
    import javax.imageio.stream.ImageOutputStream;
    public class mergeImages
    public void execute(ArrayList<File> imageFiles , File newTIFF)
    throws IOException
    Iterator iterator = imageFiles.iterator();
    Iterator writers = ImageIO.getImageWritersByFormatName("tif");
    ImageWriter writer = (ImageWriter)writers.next();
    ImageOutputStream ios = ImageIO.createImageOutputStream(newTIFF);
    writer.setOutput(ios);
    TIFFImageWriteParam tiffWriteParam = new TIFFImageWriteParam(Locale.US);
    tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    tiffWriteParam.setCompressionType("JPEG");
    boolean firstImage = true;
    while (iterator.hasNext())
    File imageFile = (File) iterator.next();
    ImageInputStream iis = ImageIO.createImageInputStream(imageFile);
    Iterator readers = ImageIO.getImageReaders(iis);
    ImageReader reader = (ImageReader)readers.next();
    reader.setInput(iis);
    try
    for(int i = 0;i<imageFiles.size();i++)
    IIOMetadata iioImageMetadata = reader.getImageMetadata(i);
    int imageHeight = reader.getHeight(i);
    int imageWidth = reader.getWidth(i);
    tiffWriteParam.setTilingMode(ImageWriteParam.MODE_EXPLICIT);
    tiffWriteParam.setTiling(imageWidth, imageHeight, 0, 0);
    BufferedImage bi = reader.read(i, null);
    IIOImage image = new IIOImage(bi, null, iioImageMetadata);
    if(firstImage==false)
    writer.writeInsert(-1,image, tiffWriteParam);
    else {
    writer.write(null, image, tiffWriteParam);
    firstImage = false;
    catch (Exception e)
    System.out.println("Exxxxxxxxx"+e);
    reader.dispose();
    writer.dispose();
    public static void main(String[] args)throws IOException
    ArrayList filesList=new ArrayList();
    File destFile = new File("c:\\TEST.tif");
    //your logic to get the list of files.
    // set the file list to 'filesList'
    File in1 = new File("c:\\a.jpg");
    File in2 = new File("c:\\b.jpg");
    filesList.add(0,in1);
    filesList.add(1,in2);
    mergeImages mI=new mergeImages();
    mI.execute(filesList,destFile);
    }

    To expand on that a little, so that you get better information next time:
    This line tells you what, ultimately, failed.
    java.lang.IndexOutOfBoundsExceptionYou then get the stack trace from most recent method called to least recent method called. The most recent method will contain the line of code that actually failed, but as here may be in an external library:
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:448)The last external package after your own code will be the method call that failed. Here you were calling the getImageMetadata() method of the com.sun.imageio.plugins.jpeg.JPEGImageReader class. Documentation on this class is available from the [Sun API documentation|http://java.sun.com/j2se/1.5.0/docs/api/javax/imageio/ImageReader.html] .
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageMetadata(JPEGImageReader.java:851)The next entry indicates which line of your own code failed. Here it was line 45 which is within a method called execute (mediocre name - it should describe what it's doing, execute is too abstract) of your own class called mergeImagesHCL (also a poor name - classes should always start with a capital letter):
    at mergeImagesHCL.execute(mergeImagesHCL.java:45)The rest of the stack trace tells you how you got there - here by calling mergeImagesHCL at line 84 of the main method of the same class:
    at mergeImagesHCL.main(mergeImagesHCL.java:84)Stack traces tell you exactly what line of code your error is on, what you were calling when it failed, and why it failed. Use them.

  • Java.lang.ClassNotFound Exception whenever I include .send()

    Everything runs fine, but when I add the .send(message); [it is in bold] I get a java.lang.ClassNotFound Exception.
    It still compiles, it just won't allow me to launch the program in the emulator. If I take that one piece of code out, everything runs fine again. I've been messing with it, and searching for a long time in an attempt to solve the problem but I've yet to come across a solution.
    I'm also using Bluej
    import java.io.*;
    import java.lang.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;//Add SMS text, Map selection (upload image/altitude-scale)
    import javax.microedition.lcdui.Font;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.wireless.messaging.*;
       public class cardcanvas extends GameCanvas implements Runnable, CommandListener {
        Image i, Mortar, Target, paintballcharleston, selectimg, Cursor;
        SendSMS sendtext;
        Thread t = new Thread(this);
        Command cmdfire=new Command("Fire", Command.BACK, 1 );
        Command cmdreset=new Command("Reset", Command.ITEM, 2 );
        String text, message;
        static Image Map;
        MessageConnection messageConnection;
        TextMessage textMessage;
        int mortarX=5500, mortarY=5500, targetX=5500, targetY=5500, distanceX, distanceY, delay, mapx=-250, mapy=-250, xvel=115, yvel=130, gameAction=0, timer=0;
        double A, B, C, b, degreeX, degreeY, degreeV, voltageX, voltageY, scale=1.4235, findDegree=90;//get scale of pixel:realtime feet
        boolean paintdown=false, paintup=false, paintright=false, paintleft=false, left, finish, firemor, initiate, click, bottom=true, noYdegree, reset, sms=false;
        public cardcanvas(){
            super(false);
            this.addCommand(cmdfire);
            this.addCommand(cmdreset);
            this.setCommandListener(this);
        public void intit() {}
        public void start() {
            t.start() {}
        public void run()
            try{
                while(true)
                    if(paintright) {
                        timer++;
                        if(timer>1&&timer<4) xvel=xvel+5;
                        if(timer>=4&&timer<6) xvel=xvel+10;
                        if(timer>=6) xvel=xvel+20;
                    if(paintleft) {
                        timer++;
                        if(timer>1&&timer<4) xvel=xvel-5;
                        if(timer>=4&&timer<6) xvel=xvel-10;
                        if(timer>=6) xvel=xvel-20;
                    if(paintup) {
                        timer++;
                        if(timer>1&&timer<4) yvel=yvel-5;
                        if(timer>=4&&timer<6) yvel=yvel-10;
                        if(timer>=6) yvel=yvel-20;
                    if(paintdown) {
                        timer++;
                        if(timer>1&&timer<4) yvel=yvel+5;
                        if(timer>=4&&timer<6) yvel=yvel+10;
                        if(timer>=6) yvel=yvel+20;
                    if(mapy<-320) mapy=-320;
                    if(mapx>0) mapx=0;
                    if(mapy>0) mapy=0;
                    if(mapx>197) mapx=197;
                    if(xvel>225)
                        mapx=mapx-5;
                        targetX=targetX-5;
                        mortarX=mortarX-5;
                        xvel=225;
                    if(xvel<5)
                        mapx=mapx+5;
                        targetX=targetX+5;
                        mortarX=mortarX+5;
                        xvel=5;
                    if(yvel>260)
                        mapy=mapy-5;
                        targetY=targetY-5;
                        mortarY=mortarY-5;
                        yvel=260;
                    if(yvel<5)
                        mapy=mapy+5;
                        targetY=targetY+5;
                        mortarY=mortarY+5;
                        yvel=5;
                        if(reset) {
                            mapx=-250;
                            mapy=-250;
                            xvel=115;
                            yvel=130;
                            left=false;
                            firemor=false;
                            finish=false;
                            initiate=false;
                            click=false;
                            bottom=true;
                            noYdegree=false;
                            reset=false;
                            targetX=5500;
                            targetY=5500;
                            mortarX=5500;
                            mortarY=5500;
                            A=0;
                            B=0;
                            C=0;
                            b=0;
                            degreeX=0;
                        if(initiate) {
                           distanceX=targetX-mortarX;
                           distanceY=targetY-mortarY;
                           A=distanceY;
                           B=distanceX;
                               if(distanceY<0)
                                    A=distanceY*-1;
                                    bottom=false;
                               if(distanceX<0)
                                    B=distanceX*-1;
                                    left=true;
                            A=A*scale;
                            B=B*scale;
                            C=Math.sqrt((A*A)+(B*B));
                                while(((A*(Math.tan(b)))<B+.00002))
                                    b=b+.0001;
                            b=b*180/3.1415926535897932384626435;
                            degreeX=b;
                                if(bottom)
                                    b=90-b;
                                    b=b+90;
                                    degreeX=b;
                                if(left)
                                    degreeX=360-b;
                            initiate=false;
                            text=("DegreeX is "+degreeX+" Range is "+C);
                             sendTextMessage();
                     verifyGameState();
                     paint(getGraphics());
                     Thread.currentThread().sleep(1);
                catch (Exception E) {}
        private void verifyGameState() {}
        public void sendTextMessage()
            try
                String message = " ";
                MessageConnection messageConnection = (MessageConnection)Connector.open("sms://18433036060");
                TextMessage textMessage = (TextMessage)messageConnection.newMessage(
                        MessageConnection.TEXT_MESSAGE, "18433036060");
                textMessage.setPayloadText(message);
                *messageConnection.send(textMessage);*
            catch (Exception e) {}
    }If I remove messageConnection.send(texstMessage); the error is gone.
    Thanks in advance for your time

    cardmidlet:
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import java.io.IOException;
    import java.lang.*;
    public class cardmidlet extends MIDlet implements CommandListener {
        private Display display; Display map;
        cardmidlet midlet;
        private Form form; Form mapselection;
        private List menuList ;
        String[] elements=new String[]{"Initiate Program","Select Map","Help","About"};
        private Command selectCommand;
        Alert alert;
            private Command fnext=new Command("NEXT",Command.ITEM,1);
            private Command fback=new Command("BACK",Command.BACK,1);
            private Command mapnext=new Command("Next",Command.ITEM,1);
        private TextField uname; TextField mapchoice;
        public String nname, nmap;
        cardcanvas cd;
        protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
        protected void pauseApp() {
        public cardmidlet() {
             menuList();
             cd = new cardcanvas();
        public void menuList(){
             display = Display.getDisplay(this);
             menuList = new List("Menu", List.IMPLICIT, elements, null);
             selectCommand=new Command("open",Command.ITEM,1);
             menuList.setSelectCommand(selectCommand);
             menuList.setCommandListener(this);  
        protected void startApp() throws MIDletStateChangeException {
            display.setCurrent(menuList);
        public void about(){
            alert = new Alert("Option Selected", "This program is created by"+"\n"+" Chris Furlong.", null, null);
              alert.setTimeout(Alert.FOREVER);
              alert.setType(AlertType.INFO);
              display.setCurrent(alert);
        public void help() {
            alert = new Alert("Option Selected", "Use the 4 d-pad keys to move the cursor. Press the center button once to select the mortar position, and a second time to select the target position. When both the mortar and the target are on screen, press the upper left key to begin the firing process. If you place one on the map by mistake, simply reset the program with the upper right key and start over.", null, null);
            alert.setTimeout(Alert.FOREVER);
            alert.setType(AlertType.INFO);
            display.setCurrent(alert);
        public void InitiateProgram(){
            display=Display.getDisplay(this);
            uname=new TextField("Enter your name","",50,TextField.ANY);
            form =new Form("New User");
            form.append(uname);
            form.addCommand(fnext);
            form.addCommand(fback);
            form.setCommandListener(this);
            display.setCurrent(form);
        public void selectmap()
           /* display=map.getDisplay(this);
            mapchoice=new TextField("Enter Map Name","",50,TextField.ANY);
            mapselection=new Form("Map Selection");
            mapselection.append(mapchoice);
            mapselection.addCommand(mapnext);
            mapselection.addCommand(fback);
            mapselection.setCommandListener(this);
            display.setCurrent(mapselection);*/
            display = map.getDisplay(this);
            map choose=new map();
        public String name(){
            nname=uname.getString();
            return nname;
    /*   public String mapname() {
            nmap=mapchoice.getString();
            return nmap;
        public void commandAction(Command com, Displayable arg1) {
             if(com==selectCommand)
                if(menuList.getSelectedIndex()==3)
                    about();
                if(menuList.getSelectedIndex()==2)
                    help();
                if(menuList.getSelectedIndex()==1)
                    selectmap();
                if(menuList.getSelectedIndex()==0)
                    InitiateProgram();
            if(com==fback)
                display.setCurrent(menuList);
            if(com==fnext){
                display = Display.getDisplay(this);
                cd.start();
                display.setCurrent(cd);
            if(com==mapnext)
                display = map.getDisplay(this);
                map choose=new map();
                display.setCurrent(choose);
    }

  • Unable to read big files into string object  and java.lang.OutOfMemory Prob

    Hi All,
    I have an application that uses applet and servlet communication. On the client side I am reading an large xml file of 12MB size (using JFileChooser) and converting the file to an string object using below code. But I am getting java.lang.OutOfMemory on the client side . But the same below code works fine for small xml files which are less than 4MB sizes:
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF8"), 1024*12);
    String s, s2 = new String();
    while((s = in.readLine())!= null)
         s2 += s + "\n";
    I even tried below code but still java.lang.OutOfMemory is coming:
    while (true)
         int i = in.read();
         if (i == -1)
              break;
         sb.append(i);
    Please let me know what am I doing wrong here ...
    Thanks & Regards,
    Sony.

    Using a String is bad for the following reason:
    When you initially create the String, it has a certain memory size (allocated length if you will). As you keep appending to this String, then memory reallocation will occur over and over, slowing your program down dramatically (ive seen with a 16k x 8 Char file taking 30 secs to read into memory using Strings in this way)
    A Better way would be if you knew the number of characters in the XML file (Using some File size method for example) Then you can use a StringBuffer, which will pre allocate enough space (or try to, it may just be that you cannot create a string as large as you need). You can use toString() method to get the resultant in a String Object (the extra allocated space at the end of the Buffer will be removed)
    StringBuffer strBuf = new StringBuffer(xxxx);
    Where xx is the length (int). Assuming that you are only allowed to enter an int to the constructor then (platform depedant) an int is 2^31 at maximum (or whatever) which allows 2.14e9 characters, therefore an xml file being totally filed would allow a size of ~2048 MB to be read in.
    Try it and see.

  • Unable to read big files into string object & java.lang.OutOfMemory Problem

    Hi All,
    I have an application that uses applet and servlet communication. On the client side I am reading an large xml file of 12MB size (using JFileChooser) and converting the file to an string object using below code. But I am getting java.lang.OutOfMemory on the client side . But the same below code works fine for small xml files which are less than 4MB sizes:
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF8"), 1024*12);
    String s, s2 = new String();
    while((s = in.readLine())!= null)
    s2 += s + "\n";
    I even tried the below code but still java.lang.OutOfMemory is coming:
    while (true)
    int i = in.read();
    if (i == -1)
    break;
    sb.append(i);
    Please let me know what am I doing wrong here ...

    Hi,
    I could avoid the java.lang.OutOfMemory error using below code. But using below code I could read small files of sizes less than 4MB
    but with large files of 12 MB the below code just simply hangs and I am unable to print the string object namely 's'.
    My purpose is to construct an String or StringBuffer object out the user uploaded xml file at the client side and pass that object to server for processing. So how can I construct such object avoid memory problem and increasing the performance of such operations.
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
    byte[] b = new byte[in.available()];
    in.read(b, 0, b.length);
    String s = new String(b, 0, b.length);
    in.close();
    Thanks & Regards,
    Sony.

  • Reason of java.lang.NoSuchMethodError exception

    Hi,
    I observed some strange (I suppose) behaviour. I made some helper class, which works as a factory to some EIS. When I use it in test desktop Java client, works correct, but if I try to involve it into the some servlet than I'll get an
    java.lang.NoSuchMethodError
    exception. Why it doesn't work as a servlet?
    Thanks for som help
    Krzysztof

    Hi,
    I observed some strange (I suppose) behaviour. I made some helper class, which works as a factory to some EIS. When I use it in test desktop Java client, works correct, but if I try to involve it into the some servlet than I'll get an
    java.lang.NoSuchMethodError
    exception. Why it doesn't work as a servlet?
    Thanks for som help
    Krzysztof

Maybe you are looking for