Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Run Time exception in Java Stored Procedure
A copy of this was sent to Anurag Minocha <anurag_at_synergy-infotech.com>
(if that email address didn't require changing)
On Thu, 06 Jan 2000 15:25:41 +0530, you wrote:
>Hi,
>I have written one stored procedure in java , but it is giving a run
>time exception (Null Pointer) . It only says that a null pointer
>exception has occured. How can i see the whole exception trace so that i
>can find out the problem.
>
>For exapmle while running a java application if an exception occurs the
>user can see it and based on that fix the problem.
>
>Thanks
>Anurag
>
>also reply at
>anurag_at_synergy-infotech.com
The exception stack trace is printed into a trace file on the server (in the directory specified in the USER_DUMP_DEST init.ora parameter).
Additionally, in sqlplus, you can redirect stdout (normally captured into this trace file on the server) to the screen. for example, say you have a java sp:
$ cat Hello.java import java.lang.*; import java.lang.Throwable;
static public String World() throws Throwable {
String foo;
foo = null; if ( foo.equals( "bar" ) ); return "Hello World";
}
it'll fail with NULL pointer right away... we compile it:
$ javac Hello.java
and load it:
$ loadjava -user tkyte/tkyte Hello.class
And now, we'll execute it:
$ sqlplus tkyte/tkyte
SQL*Plus: Release 8.1.5.0.0 - Production on Thu Jan 6 08:35:16 2000
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
tkyte_at_8i> set echo on
tkyte_at_8i> create or replace function HELLOWORLD return
2 varchar2 as
3 language java name 'Hello.World() return
4 java.lang.string';
5 /
Function created.
tkyte_at_8i> variable myString varchar2(25);
HERE we enable serveroutput and use dbms_java to tell the java runtime to put system output in the dbms_output buffer, not into the trace file...
tkyte_at_8i> set serveroutput on size 1000000 tkyte_at_8i> exec dbms_java.set_output( 1000000 )
PL/SQL procedure successfully completed.
Call the procedure... It'll fail...
tkyte_at_8i> call HelloWorld() into :myString
2 /
call HelloWorld() into :myString
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NullPointerException
Now, we would like to see the results (the stack trace). to do this, we need to successfully execute something -- null works fine for this...
tkyte_at_8i> exec null
java.lang.NullPointerException
at Hello.World(Hello.java:12)
PL/SQL procedure successfully completed.
and there is the stack trace....
--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Jan 06 2000 - 06:51:21 CST
![]() |
![]() |