File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Why does java not report exception line numbers sometimes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why does java not report exception line numbers sometimes?" Watch "Why does java not report exception line numbers sometimes?" New topic

Why does java not report exception line numbers sometimes?

Ben Ethridge
Ranch Hand

Joined: Jul 28, 2003
Posts: 108
This may make me look a bit silly but I gotta ask coz I don't see the pattern in my code yet:

Notice in this stacktrace below, about the 5th and 6th elements in the stack, how the java line number is missing.

Why does java do that sometimes? i.e. under what circumstances java NOT report the line number that caused the exception?


Here's the stdout log:

[8/13/04 9:03:08:586 CDT] 58275827 ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "transformCommStmt" on bean "BeanId(ExtInterfaces#ExtInterfacesEJB.jar#TFGExternalInterfaceService, null)". Exception data: java.lang.IllegalArgumentException: Cannot format given Object as a Date
at java.lang.Throwable.<init>(
at java.lang.Throwable.<init>(
at java.text.DateFormat.format(
at java.text.Format.format(
at com.republic.externalinterface.commisStmtExport.TFGCommStmtExport.deleteOldXmlArchives(
at com.republic.externalinterface.commisStmtExport.TFGCommStmtExport.transformCommStmtXMLsToAFlatFile(
at com.republic.externalinterface.service.TFGExternalInterfaceServiceBean.transformCommStmt(
at com.republic.externalinterface.service.EJSRemoteStatelessTFGExternalInterfaceService_945f7a13.transformCommStmt(
at com.republic.externalinterface.service._EJSRemoteStatelessTFGExternalInterfaceService_945f7a13_Tie.transformCommStmt(
at com.republic.externalinterface.service._EJSRemoteStatelessTFGExternalInterfaceService_945f7a13_Tie._invoke(


(I thinking this is java doing it, and not something specific to WebSphere.)

Here is an edited version of the code that exhibits this behavior:

protected void deleteOldXmlArchives(String dB_Comm_XML_Arc_Path) throws TFGNestingException {

SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd");
String processDateString = getProcessDate();//Returns String in form yyyyMMdd.
String s = sdf1.format(processDateString);//This line causes the exception.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Some class files don't have line numbers in them. The line number table isn't generated if "-O" is passed to javac. In other cases, HotSpot/JIT compilation makes it impossible to report line numbers in some cases -- although this happens far less often then it used to.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Why does java not report exception line numbers sometimes?
It's not a secret anymore!