Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

datasource lookup

 
deepak sm
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Thomas Risberg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Java compiler/JDK are you using?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic