SimpleDateFormat or TimeZone Problem.

Y

Yongsub Chung

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 tcs.Tcs
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.ThrowableVM 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 tcs.Tcs
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.ThrowableVM 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;
 
K

klynn47

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
 
Y

Yongsub Chung

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?
 
K

klynn47

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
 
Y

Yongsub Chung

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.
 
L

loosecannon_1

Yongsub said:
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.
 
T

Thomas Weidenfeller

Yongsub said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top