Disk Space "leaking" in Java Application Using java.io.RandomAccessFile

I have noted this behaviour in both java version 1.2.1 and 1.3.1 on Solaris 5.8.
I have a java application that is essentially "tailing" a very large log file.
The program opens a RandomAccessFile in read-only mode and calls readLine on the file as long as the file is getting written to.
If the file stops getting updated the program assumes the logfile has been moved/rotated/wrapped (by an external process) and the program the calls close and then reopens the file to allow the program to start reading from the new file and to allow the O/S to free up the system resources.
It appears that the program is not actually closing the filehandle or releasing the disk space and eventually the disk fills up.
When this happens the program is stopped and restarted and the disk space is freed up.
We have run the pfiles command against the running process and have confirmed that the old filehandles are still open.
I have attached what I think to be the relevant code lines below:
RandomAccessFile filehandle = null;
boolean reopen = true;
boolean connected = true;
while(connected)
if (reopen)
while(! new File(filename).exists())
     doSleep (filewaittime);
          filehandle = new RandomAccessFile(filename, "r");
while (file_being_updated)
// read from the file etc.
filehandle.close();
filehandle = null;
reopen = true;
The reopen flag is set to false in code not shown here.
I have verified that the block of code that calls close() on the filehandle and sets it to null is being executed when the logfile is moved externally.

Hmmmm. Sounds like a hint to me :)
I am still experimenting but I will certainly try moving to the latest JDK and report a bug if I don't figure this out on my own.
Thanks.

Similar Messages

  • Deploying no java applications using Java Web Start

    Hi,
    I am new to java web start. Is it possible to distribute non java applications using java web start. I have an APP which can run on a desktop in standalone mode. The app has jusy HTML and Java script files. Is it possible to package this app and deploying using java web start? I am assuming If it is possible, I can make updates to the packaged app in the web servers and the updates will be downloaded next time the app is used provided configurations are correct?
    thx

    The app has jusy HTML and Java script files. Is it possible
    to package this app and deploying using java web start? Not really. Resources for JWS need to be zipped,
    while this HTML/JS app. will (I guess) not work from
    inside the depths of a Jar (or Zip) archive.
    Note that you can organise for those files to be
    downloaded and expanded onto a known place
    on the user's disk, by using an 'installer' element,
    but..
    ...I am assuming If it is possible, I can make updates to the
    packaged app in the web servers and the updates ..installers are only called once, and do not 'update'.

  • How can i built a java application using java debug class on Log4J

    Hi,
    As java API support the MethodEntryEvent, using which I can get the automatic logging statements when the method is entered or exited as HelloExample.main(with argument type).
    Where HelloExample is the class name.
    Main is the method entered with its argument types.
    In some cases I have the o/p as
    -- VM Started --
    ====== main ======
    main -- HelloExample
    callerMethod -- HelloExample
    ====== main end ======
    -- The application exited --
    By using Log4J is there any possibility of getting these sort of o/p along with the loggers supported by Log4J. i mean to say can i built an java application which supports the MethodEntryEvent and MethodExitEvent from java API and also uses the Log4J debugging. I took an e.g. trace example, which (in J2SE 1.4.x or 5.x) will be found in $JAVA_HOME/demo/jpda/examples.jar and unpacking it by
    jar -xvf $JAVA_HOME/demo/jpda/examples.jar i found the com/sun/tools/example/trace/Trace.java and passed the class constructed with logger taken from Log4J. In this case the logging message is displayed on the console. As per the requirement i need to transfer the whole o/p to an output file along with Log4J logger statements. in this case i should not give any command in the cosule except compiling and executing the programme. the programm also should able to run without the main() as i need to integrate Log4J with an application and the code must me application server independent. i need the output as i got using MethodEnteryEvent (shown as above) in case of java application built using Log4J.
    Can any one help me in this regard. can any one give me some suggestion or any programme of this sort. All suggestions are welcomed.
    Thanks & Regards,

    hi,
    can someone help me how to implement logging for method entry parameters and
    method exit return value.
    can someone help me how to use log4j and integrate it to the method entry
    logging and method exit logging.
    Here what i need is without writing the log statements for the method entry and
    method exit i need to log it to the file
    along with other log4j debug statements i provide in the file.I should be able
    to configure whether to enable/disable the logging
    for method entry and method exit. In method entry i should be able to log the
    parameters the method take and in method exit
    i should be able to log te return value to the log file, before the method is
    returned to the callee.
    i hope i am clear
    Thanks in advance.

  • Executing Jar Application using Java Programs

    Hello there,
    How can I run a java application using java programs.
    Desc:
    public class someapp {
       public static void main(String[] ext) {
           // How can I execute a jar application from here through java code
    }

    You could use java.lang.Runtime.exec(). Another way could be loading the main class of the jar file and invoking its main method dynamically.

  • I want to create a Ajax based Chating application using java .

    hi . I want to create an chating Application , and ajax based chatting application using java as my server side language ..i have some idea about it .. but one thing that i m not understanding is that how i will communicate with other users because each user has its own session so what i will do to send one messge to all the users ???? . i m new to JavaEE and i have chosen this as my semester project .. i need some help regarding this .

    First get it working without AJAX.

  • How can i call a VB6 project from my java application using JNI

    hi
    can anyone tell me the procedure of calling a VB6 project from any java application using JNI
    if anyone does know then tell me the detail procedure of doing that. I know that i have to create a dll of that VB6 project then to call it from the java application.
    if anyone know that procedure of creating dll file of an existing VB6 project please reply
    please if anyone know then let me know

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Can we run a java application using Runtime.exec()?

    Can we run a java application using Runtime.exec()?
    If yes what should i use "java" or "javaw", and which way?
    r.exec("java","xyz.class");

    The best way to run the java application would be to dynamiically load it within the same JVM. Look thru the class "ClassLoader" and the "Class", "Method" etc...clases.
    The problem with exec is that it starts another JVM and moreover you dont have the interface where you can throw the Output directly.(indirectly it can be done by openong InputStreams bala blah............). I found this convenient. I am attaching part of my code for easy refernce.
    HIH
    ClassLoader cl = null;
    Class c = null;
    Class cArr[] ;
    Method md = null;
    Object mArr[];
    cl = ClassLoader.getSystemClassLoader();
    try{
         c = cl.loadClass(progName.substring(0,progName.indexOf(".class")) );
    } catch(ClassNotFoundException e) {
    System.out.println(e);
         cArr = new Class[1] ;
         try{
         cArr[0] = Class.forName("java.lang.Object");
         } catch(ClassNotFoundException e) {
         System.out.println(e);
         mArr = new Object[1];
         try{
         md = c.getMethod("processPkt", cArr);
         } catch(NoSuchMethodException e) {
         System.out.println(e);
         } catch(SecurityException e) {
         System.out.println(e);
    try {            
    processedPkt = md.invoke( null, mArr) ;
    } catch(IllegalAccessException e) {
              System.out.println(e);
    } catch(IllegalArgumentException e) {
              System.out.println(e);
    }catch(InvocationTargetException e) {
              System.out.println(e);
    }catch(NullPointerException e) {
              System.out.println(e);
    }catch(ExceptionInInitializerError e) {
              System.out.println(e);
    }

  • Java Application using Swig Running Visual C++ 6.0

    i,
    I am using Swig with Java ,I'm trying launch a Java application using a Windows executable,
    I'm using VC++6.0, and followed the instruction in Swig Documentation chaper 20,Section 20.2.8.
    I Build my dll in Vc++ i get this error Anyone know this,please help me.
         SWIG
         Compiling resources...
         Compiling...
         StdAfx.cpp
         Compiling...
         example.c
         Generating Code...
         Compiling...
         example_wrap.cpp
    c:\program files\java\jdk1.5.0_01\include\jni.h(46) : error C2146: syntax error : missing ';' before identifier 'jsize'
    c:\program files\java\jdk1.5.0_01\include\jni.h(46) : fatal error C1004: unexpected end of file found
    Generating Code...
    Error executing cl.exe.
    example.dll - 2 error(s), 0 warning(s)
    Regards
    Devi

    check on line 46, there might be a missing ";"
    c:\program files\java\jdk1.5.0_01\include\jni.h(46) : error C2146: syntax error : missing ';' before identifier 'jsize'

  • Is it possible to cal web dynpro java application using portal application?

    Hi,
    is it possible to cal web dynpro java application using j2ee portal application?
    If possible, how can it be done the parameter mapping over context area?
    Regards.

    you can just append parameter to the url as usual.
    you will write some code in the controller to get the parameters and set them to the context.

  • Problem Web Dynpro Java applications using JasperReports

    Hello all,
    We have followed the footsteps of these blogs but we can not make it work.
    Part I --> Part-I: Print Web Dynpro Java applications using JasperReports
    Part II --> Part-II: Print Web Dynpro Java applications using JasperReports
    Part III --> Part-III: Print Web Dynpro Java applications using JasperReports
    Details system: 7.02 SP3
    We believe that the problem is in the library, because it finds them.
    1) We created project as a DC external library with *.jars
    2) Public part DC external library.
    3) Add public part of DC Library into new project DC WebDynpro Java.
    4) Development Component -> Build is OK
    5) Development Component -> Deploy is OK
    6) Test app ERROR.
    When we run the application shows the error:
    The initial exception that caused the request to fail, was:
       java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at com.unisys.tmb.View01.onActiongenerarPDF(View01.java:161)
        at com.unisys.tmb.wdp.InternalView01.wdInvokeEventHandler(InternalView01.java:140)
        at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
        ... 28 more
    See full exception chain for details.
    Regards,
    Luis.

    Hello John,
    Thanks for the link. We have performed the steps in this blog:
    1) Create DC Project "External Library" with name js/jars:
    - Add *.jars in folder Libraries.[Screenshot Libraries|http://img846.imageshack.us/img846/8395/jsjars.jpg]
    - Add archives (*.jar) to public part with name ExternalLib. Which option to choose?
    a- Provides an API for developing/compiling other DCs (Option chosen)
    b- Can be packaged into other build results (eg SDAs)
    - Development Component -> Build
    Step 1 is OK.
    2) Create "J2EE Server Component / Library" DC with name js/lib:
    - Add Used DC -> public part project ExternalLibrary -> "ExternalLib"
    - Specify both build time and run-time dependency here and strong.
    - Generated SDA file in <var>gen/default/deploy</var> How do we check that it contains <var>js.jar</var>?
    - folder gen/default/plublic/defLib/lib/java then you meet *.jars files again. is OK.
    - Development Component -> Deploy.
    - Go to Visual Administrator. We found the library js/lib, but has no associated *. jar. It is the problem.[Screenshot Visual Administrator|http://img542.imageshack.us/img542/5537/visualadminlib.jpg]
    3) Create "WebDynpro" DC with name pdf_jasper
    - Add used DC (defLib) to WebDynpro DC with option "Build time".
    - WebDynpro References -> Library references --> add <var>jslib
    - Deploy
    - Run error: java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
    Regards,
    Luis.

  • Testing WD Java Applications using eCATT tool

    Hi All,
    We are trying to simulate the runtime tests of WD java Applications using the tool eCATT. I would like to know the current procedure followed to achieve the same.
    We have ample users using eCATT tool for testing their WD ABAP Applications. Do you have any information about the team or users using the eCATT tool for the WD Java Applications?
    Also, i need some information about the WD Java Runtime team.
    Could you please provide me with some inputs?
    Thanks in Advance.
    Best Regards,
    Yogi
    Edited by: Yoganand P on Mar 11, 2011 11:20 AM
    Edited by: Yoganand P on Mar 11, 2011 11:21 AM

    Hi Thanks for u r reply Dude,this is the simple algo ,could you tell me how can i test my algo using junit in eclipse only rather every time deploye and test in ccb. Your help will be appreciated.
    package com.splwg.cm.domain.bills;
    * @author *
    @AlgorithmComponent ()
    public class CMGoodCustomer_Impl extends CMGoodCustomer_Gen implements
              DepositClassGoodCustomerAlgorithmSpot {
         private static final Logger logger=LoggerFactory.getLogger(CMGoodCustomer_Impl.class);
    private Account account;
    private DepositClass depositClass;
    private Bool customerStatus;
    private boolean flag;
         @Override
         public void invoke() {
              // TODO Auto-generated method stub
              CustomerClass customerClass=account.getCustomerClass();
              CustomerClass_Id customerClass_Id=customerClass.getId();
         if(customerClass_Id.toString().trim().equals("CAT-VIII")||customerClass_Id.toString().trim().equals("HT- VIII")||customerClass_Id.toString().trim().equals("SCATVIII")||customerClass_Id.toString().trim().equals("SHT-VIII"))
    flag=true;
              else
    flag=false;
         @Override
         public Bool getIsGoodCustomer() {
              // TODO Auto-generated method stub
              if(flag==true)
              return Bool.TRUE;
              else
                   return Bool.FALSE;
         @Override
         public void setAccount(Account accoutnt) {
              // TODO Auto-generated method stub
              this.account=account;
         @Override
         public void setDepositClass(DepositClass depositClass) {
              // TODO Auto-generated method stub
              this.depositClass=depositClass;
    }

  • Load java applications using PXE or bootp

    hi... i was trying to test the option of booting up a java application using PXE or bootp.. is it possible to do so?? what are the rcommended ways to do it??
    Thanks
    Leonard

    Normal CORBA (as in Java IDL) is probably way too complicated for what you're trying to do, unless you're thinking of someday having the programs talk with non-Java programs.
    I'd start with Java RMI rather than RMI-IIOP since you can probably find more tutorials and docs on it (though the RMI-IIOP 1.4 docs here are really quite good). That way, you're writing everything in Java, at least.
    For remote object systems, all the advantaged of object oriented programming come into play, especially extensibility. What if you need to change the wire format to add more information in your socket system but need to maintain compatibility with older clients? What if you need to add security or handle multiple clients at once? What if you'd rather rely on existing serialization methods rather than code your own wire format for everything you want to send (making you write more code)? You can serialize any Java Serializable over Java RMI. That lets you send things without violating encapsulation. What if you want to talk to programs that aren't written in Java? What about automatic failure recovery if the server crashes? etc etc.

  • Building java applications using UML

    Hi all
    I want to get experience for building java applications using UML.
    Pls advice what is the best text book should I purchase??
    thanks
    madura

    I do not use UML to auto-generate codes either. Take a look at Martin Fowler's bliki on some quite good views about UML: http://www.martinfowler.com/bliki/uml.html
    What I do use UML for:
    1. To visualise the system being built during the analysis and design phases - both to help improve understanding and to keep the stakeholders happy.
    2. To reverse-engineer existing code that's weak on both design documents and code design. Makes understanding the code easier.
    3. To highlight areas in existing code that might benefit from the application of design patterns.
    As for how UML converts to Java code, the main diagrams are the Class Diagram and the Interaction Diagrams - Collaboration and Sequence. These diagrams translate to code very well.
    Hth.

  • GIS applications using Java/SDO/MapViewer

    Hi everybody !
    First of all, sorry if my english is not soo good.
    I had installed MapViewer in my computer. It4s working perfectly.
    After view the JSP demo page and the Java demo program, I4m trying to create my own program, using the MapViewer.
    Well, before start my job, I wonder if there is anyone who has already create a application using Java, MapViewer and SDO.
    Is it really possible ?
    How is the productivity ?
    What are the major problems ?
    What are the alternatives ?
    Thanks,
         Rodrigo

    What XML Parser are you using to get an atributte4s value ?
    The JSP Demo makes a string comparison, but I want to use the XML Parser. How can I do this ?
    Response DTD Example:
    ~~~~~~~~~~~~~~~~~~~~
    <?xml version="1.0" encoding="UTF-8" ?>
    <map_response>
         <map_image>
              <map_content url="http://map.oracle.com/output/map029763.bmp" />
              <box srsName="default">
                   <coordinates>-122.260443,37.531621 -120.345,39.543</coordinates>
              </box>
              <WMTException version="1.0.0" error_code="SUCCESS"/>
         </map_image>
    </map_response>
    Questions:
    ~~~~~~~~~~~~~~
    - How can I get the value of the url atributte (http://map.oracle.com/output/map029763.bmp) ?
    - How can I get the value of the error_code atributte (SUCCESS) ?
    I4m holding the response DTD sending by MapViewer on a String variable.
    Thanks,
    Rodrigo

  • How to make destop application using java

    how to make destop application using java
    i mean to say when we double click on the exe file the program should lounch the application
    for windows

    when i double click ii got the msg
    Failed to lad main class manifest attribute from
    x/x/xyz.jar
    what exatly it meansIt means that your Manifest.MF for the JAR file should contain an attribute called Main-Class pointing to a class containing the main() method.
    Something like this should be present in META-INF/Manifest.MF :
    Main-Class: MyApplicationMain

Maybe you are looking for

  • Assign a matrix to a JTable?  Possible?

    OK. I will not know the incomming data matrix untill it is assigned. Is there anyway to put the following matrix into a JTable without a headache? All I see are examples of Object class variables assigned to JTables. If anyone knows how to make this

  • Game center break down ... help needed!

    I just cannot get my game center to work, therefore my games won't save. eg, The Sims freeplay tells me I'm not signed in to game center so I open up GC app. I see the "Me" screen, with me on it! I tap on games and nothing will load. I tap on "friend

  • Numbers instead of names

    My messages and calls are suddenly showing up with contact numbers instead of contact names.  How do I get the names back?

  • Email editable PDF form

    We're on 46c and currently using an existing sapscript to generate and email PDF output. The new requirement is to make this form editable so that certain fields (say comments) can be updated in adobe and later printed/emailed. Is it possibile withou

  • Firefox timing out and won't reconnect

    I have done some searching on existing posts, and am not sure I have found a solution to my problem. I am a new FIOS customer with land line, Internet and TV service.  I have the MI424WR Router.  All is well except the Internet connection.  I am runn