SimpleDateFormat or TimeZone Problem.

Discussion in 'Java' started by Yongsub Chung, Jan 20, 2005.

  1. Hello.
    I have a java program which worked okay last week, but this week.
    I added several classes, but I didn't touch the codes related to this
    problem.

    The skeleton code pieces for the problem is attached at the end.
    When I just run the application, it stuck because appropriate init() was
    not done.
    So, I ran in debugging mode. Right after I ran in jdb, it gave me
    following:
    -------------------------------------------------------------------------
    litdream@lucky tcs4 $ run jdb
    Initializing jdb ...
    > run

    run tcs.Tcs
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >

    VM Started:
    Exception occurred: java.io.FileNotFoundException
    (uncaught)"thread=main", javaio.FileInputStream.open(), line=-1 bci=-1

    main[1] where
    [1] java.io.FileInputStream.open (native method)
    [2] java.io.FileInputStream.<init> (FileInputStream.java:106)
    [3] sun.util.calendar.ZoneInfoFile$1.run (ZoneInfoFile.java:920)
    [4] java.security.AccessController.doPrivileged (native method)
    [5] sun.util.calendar.ZoneInfoFile.readZoneInfoFile
    (ZoneInfoFile.java:914)
    [6] sun.util.calendar.ZoneInfoFile.createZoneInfo (ZoneInfoFile.java:526)
    [7] sun.util.calendar.ZoneInfoFile.getZoneInfo (ZoneInfoFile.java:496)
    [8] sun.util.calendar.ZoneInfo.getTimeZone (ZoneInfo.java:556)
    [9] java.util.TimeZone.getTimeZone (TimeZone.java:483)
    [10] java.util.TimeZone.setDefaultZone (TimeZone.java:578)
    [11] java.util.TimeZone.getDefault (TimeZone.java:534)
    [12] java.text.SimpleDateFormat.initialize (SimpleDateFormat.java:503)
    [13] java.text.SimpleDateFormat.<init> (SimpleDateFormat.java:446)
    [14] java.text.SimpleDateFormat.<init> (SimpleDateFormat.java:427)
    [15] tcs.Global.init (Global.java:68)
    [16] tcs.Tcs.main (Tcs.java:132)
    main[1]
    -------------------------------------------------------------------------

    16th element in stack, Tcs.java:132, is simply calling Global.init()
    function and
    15th, Global.java:68, is new SimpleDateFormat("format"); constructor.
    ( I left code at the bottom. )

    I tried by switching line Global.java:68 and Global.java:69.
    App. still stops at Global.java:68, therefore I concluded I am not using
    SimpleDateFormat right.
    I tested differently by commenting out line 68 and 69.
    Then, it stops at TimeZone code like following:
    -------------------------------------------------------------------------
    litdream@lucky tcs4 $ run jdb
    Initializing jdb ...
    > run

    run tcs.Tcs
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >

    VM Started:
    Exception occurred: java.io.FileNotFoundException
    (uncaught)"thread=main", java.io.FileInputStream.open(), line=-1 bci=-1

    main[1] where
    [1] java.io.FileInputStream.open (native method)
    [2] java.io.FileInputStream.<init> (FileInputStream.java:106)
    [3] sun.util.calendar.ZoneInfoFile$1.run (ZoneInfoFile.java:920)
    [4] java.security.AccessController.doPrivileged (native method)
    [5] sun.util.calendar.ZoneInfoFile.readZoneInfoFile
    (ZoneInfoFile.java:914)
    [6] sun.util.calendar.ZoneInfoFile.createZoneInfo (ZoneInfoFile.java:526)
    [7] sun.util.calendar.ZoneInfoFile.getZoneInfo (ZoneInfoFile.java:496)
    [8] sun.util.calendar.ZoneInfo.getTimeZone (ZoneInfo.java:556)
    [9] java.util.TimeZone.getTimeZone (TimeZone.java:483)
    [10] java.util.TimeZone.setDefaultZone (TimeZone.java:578)
    [11] java.util.TimeZone.getDefault (TimeZone.java:534)
    [12] tcs.Global.init (Global.java:143)
    [13] tcs.Tcs.main (Tcs.java:132)
    main[1]
    -------------------------------------------------------------------------

    line 143 is TimeZone querying.
    Interestingly, if I normally run this application, Main:69 actually
    produces log, even though Main:68 and beyond created this problem.

    May I beg some help from someone who has any clue about this?
    My code is attached at the bottom.


    CODE:
    ========================================================================
    Main Function:
    127: static public void main(String[] args) throws SQLException
    128: {
    ---
    132: Global.init();
    133: Global.printLog("TCS Started.");


    Global.java:
    22: public class Global {
    --
    27: static private SimpleDateFormat NumberOnlyDate = null;
    28: static private SimpleDateFormat NumberColon = null;
    29: static private ParsePosition pos = null;
    30:
    31: static public final long SEC = 1000;
    32: static public final long MIN = 60 * SEC;
    33: static public final long HOUR = 60 * MIN;
    34: static public final long DAY = 24 * HOUR;
    --
    66: static public void init() {
    67: pos = new ParsePosition(0);
    68: NumberColon = new SimpleDateFormat("MMddyyyy HH:mm:ss");
    69: NumberOnlyDate = new SimpleDateFormat("MMddyyyyHHmmss");
    --
    143: TimeZone tz = TimeZone.getDefault();
     
    Yongsub Chung, Jan 20, 2005
    #1
    1. Advertising

  2. Yongsub Chung

    Guest

    It looks like the first problem is that the system can't find or read
    the file you are trying to attach the FileInputStream to
     
    , Jan 20, 2005
    #2
    1. Advertising

  3. wrote:
    > It looks like the first problem is that the system can't find or read
    > the file you are trying to attach the FileInputStream to
    >


    Thanks for reply.
    However, all files are there and they are in try catch block.
    I didn't get any log for that, but I will make sure I am handling file
    correctly.

    I appreciate. I will focus on Files now.
    This problem, however, is not related to file.. So.. Any other idea, please?
     
    Yongsub Chung, Jan 20, 2005
    #3
  4. Yongsub Chung

    Guest

    >From this part of the stack trace

    [1] java.io.FileInputStream.open (native method)
    [2] java.io.FileInputStream.<init> (FileInputStream.java:106)
    [3] sun.util.calendar.ZoneInfoFile$1.run (ZoneInfoFile.java:920)

    it looks like there is a file that is trying to be read by an anonymous
    inner class of ZoneInfoFile
     
    , Jan 20, 2005
    #4
  5. wrote:
    >>From this part of the stack trace

    >
    > [1] java.io.FileInputStream.open (native method)
    > [2] java.io.FileInputStream.<init> (FileInputStream.java:106)
    > [3] sun.util.calendar.ZoneInfoFile$1.run (ZoneInfoFile.java:920)
    >
    > it looks like there is a file that is trying to be read by an anonymous
    > inner class of ZoneInfoFile
    >



    I appreciate your kind reply.
    Does this mean my jdk is corrupted?
    sun.util.calendar package failed to find a file, and the only reason
    that I can think is filesystem.

    I just tested on different box, with new JDK5. I got 29 warnings but
    any of them is related to File. The result was still the same...
    I am currently looking around my other static functions.

    I appreciate your reply.
     
    Yongsub Chung, Jan 20, 2005
    #5
  6. Yongsub Chung

    Guest

    Yongsub Chung wrote:
    > wrote:
    > >>From this part of the stack trace

    > >
    > > [1] java.io.FileInputStream.open (native method)
    > > [2] java.io.FileInputStream.<init> (FileInputStream.java:106)
    > > [3] sun.util.calendar.ZoneInfoFile$1.run (ZoneInfoFile.java:920)
    > >
    > > it looks like there is a file that is trying to be read by an

    anonymous
    > > inner class of ZoneInfoFile
    > >

    >
    >
    > I appreciate your kind reply.
    > Does this mean my jdk is corrupted?
    > sun.util.calendar package failed to find a file, and the only reason
    > that I can think is filesystem.
    >
    > I just tested on different box, with new JDK5. I got 29 warnings but
    > any of them is related to File. The result was still the same...
    > I am currently looking around my other static functions.
    >
    > I appreciate your reply.

    I don't know if this will help or not but inside the lib directory or
    the jre (or jdk) you will find a tzmappings file and a zi directory. I
    would check this file and this directory (and the files within) for
    corruption. You may also want to set the timezone yourself rather than
    using the default so you know what file it is looking for. Your locale
    info may be messed up for some reason.
     
    , Jan 20, 2005
    #6
  7. Yongsub Chung wrote:
    > main[1] where
    > [1] java.io.FileInputStream.open (native method)
    > [2] java.io.FileInputStream.<init> (FileInputStream.java:106)
    > [3] sun.util.calendar.ZoneInfoFile$1.run (ZoneInfoFile.java:920)


    Check if the contents of the jre/lib/zi directory of your Java
    installation is corrupt.

    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
     
    Thomas Weidenfeller, Jan 21, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Lin

    SimpleDateFormat problem

    Mike Lin, Apr 4, 2004, in forum: Java
    Replies:
    2
    Views:
    501
    Filip Larsen
    Apr 4, 2004
  2. Karl Vernet

    SimpleDateFormat Problem

    Karl Vernet, Nov 4, 2004, in forum: Java
    Replies:
    2
    Views:
    2,803
  3. asaf
    Replies:
    3
    Views:
    6,190
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Sep 11, 2006
  4. axrock
    Replies:
    8
    Views:
    977
    Roedy Green
    Mar 25, 2009
  5. Ami
    Replies:
    5
    Views:
    298
Loading...

Share This Page