File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes datasource lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "datasource lookup" Watch "datasource lookup" New topic
Author

datasource lookup

deepak sm
Greenhorn

Joined: Sep 28, 2004
Posts: 2
Hi,
I am trying to perform data source lookup from weblogic8.1 in linux platform and i am getting the following exception

"Exception in thread "main" class java.lang.ExceptionInInitializerError: java.lang.NullPointerException ".

This was the code i am trying to execute:

Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(ht);

javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("db2jndi");

java.sql.Connection con = ds.getConnection();

Statement stm = con.createStatement();
ResultSet rs=stm.executeQuery("select * from emp");
while(rs.next())
{
System.out.println("deptname........."+rs.getString(1));
}
}catch(Exception e)
{
e.printStackTrace();
}

Can any one help me out
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1132

Deepak,
Here is a quote from the javadoc for class "ExceptionInInitializer":

Signals that an unexpected exception has occurred in a static initializer

This means that the error may not be occurring in the code that you posted.

I may be able to help you if you post the entire error message and stack trace you are getting.

Good Luck,
Avi.
deepak sm
Greenhorn

Joined: Sep 28, 2004
Posts: 2
Originally posted by Avi Abrami:
Deepak,
Here is a quote from the javadoc for class "ExceptionInInitializer":

This means that the error may not be occurring in the code that you posted.

I may be able to help you if you post the entire error message and stack trace you are getting.

Good Luck,
Avi.



Hi Avi,

This is the full strace of the exception , I am getting this exception when i do the lookup of the jndi name

Exception in thread "main" class java.lang.ExceptionInInitializerError: java.lang.NullPointerException
at 0x4021aef2: _Jv_ThrowSignal (/usr/lib/./libgcj.so.3)
at 0x4021af26: ?? (??:0)
at 0xbfffb9e4: ?? (??:0)
at 0x40229471: _Jv_ResolvePoolEntry(java.lang.Class, int) (/usr/lib/./libgcj.
so.3)
at 0x40230699: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40246399: java.lang.Class.initializeClass() (/usr/lib/./libgcj.so.3)
at 0x40229397: _Jv_ResolvePoolEntry(java.lang.Class, int) (/usr/lib/./libgcj.
so.3)
at 0x402302ba: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40246399: java.lang.Class.initializeClass() (/usr/lib/./libgcj.so.3)
at 0x402296af: _Jv_ResolvePoolEntry(java.lang.Class, int) (/usr/lib/./libgcj.
so.3)
at 0x40230827: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40246399: java.lang.Class.initializeClass() (/usr/lib/./libgcj.so.3)
at 0x402296af: _Jv_ResolvePoolEntry(java.lang.Class, int) (/usr/lib/./libgcj.
so.3)
at 0x40230827: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x402f4176: java.security.AccessController.doPrivileged(java.security.Priv
ilegedAction) (/usr/lib/./libgcj.so.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40246399: java.lang.Class.initializeClass() (/usr/lib/./libgcj.so.3)
at 0x40244d04: java.lang.Class.forName(java.lang.String, boolean, java.lang.C
lassLoader) (/usr/lib/./libgcj.so.3)
at 0x40244d9f: java.lang.Class.forName(java.lang.String) (/usr/lib/./libgcj.s
o.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40364f97: javax.naming.spi.NamingManager.getInitialContext(java.util.Has
htable) (/usr/lib/./libgcj.so.3)
at 0x4036344f: javax.naming.InitialContext.getDefaultInitCtx() (/usr/lib/./li
bgcj.so.3)
at 0x40363568: javax.naming.InitialContext.getURLOrDefaultInitCtx(java.lang.S
tring) (/usr/lib/./libgcj.so.3)
at 0x4036368e: javax.naming.InitialContext.lookup(java.lang.String) (/usr/lib
/./libgcj.so.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/l
ib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40242dd8: gnu.gcj.runtime.FirstThread.call_main() (/usr/lib/./libgcj.so.
3)
at 0x402ad02d: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
at 0x4024fc4c: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
at 0x4021c8ac: _Jv_RunMain(java.lang.Class, byte const, int, byte const, bool
ean) (/usr/lib/./libgcj.so.3)
at 0x08048910: ?? (??:0)
at 0x42015574: __libc_start_main (/lib/tls/libc.so.6)
at 0x080486c1: ?? (??:0)

Can u figure out what is the cause for this
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

"deepak sm",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Thomas Risberg
Greenhorn

Joined: Aug 17, 2004
Posts: 4
What Java compiler/JDK are you using?


Thomas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: datasource lookup