• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

datasource lookup

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Java compiler/JDK are you using?
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic