Solved

JNDI exception question under WSAD

Posted on 2004-08-13
8
2,711 Views
Last Modified: 2013-12-10
Dear all.

I am running JNDI service on WSAD 5.01 and I coded something like this:

NamingEnumeration ee = null;
try  {
      String path = "path1/path2/item1";
       ee = ctx.list(path);
} catch (Throwable e) {
      e.printStackTrace();
}

I got the following exception:

[8/13/04 19:54:11:984 GMT+08:00] 4a380a7c Helpers       W NMSV0610I: A NamingException is being thrown from a javax.naming.Context implementation. Details follow:
Context implementation: com.ibm.ejs.ns.jndi.CNContextImpl
Context method: list
Context name: domainRoots/UnspecifiedDomainName/legacyRoot
Target name: path1/path2/item1
Other data:
Exception stack trace: javax.naming.NotContextException: path1/path2/item1
      at com.ibm.ejs.ns.jndi.CNContextImpl.doList(CNContextImpl.java:2280)
      at com.ibm.ejs.ns.jndi.CNContextImpl.list(CNContextImpl.java:982)
      at com.ibm.ws.naming.util.WsnInitCtx.list(WsnInitCtx.java:268)
      at javax.naming.InitialContext.list(InitialContext.java:399)
      at java.lang.Thread.run(Thread.java:512)

javax.naming.NotContextException: path1/path2/item1
      at com.ibm.ejs.ns.jndi.CNContextImpl.list(CNContextImpl.java:987)
      at com.ibm.ws.naming.util.WsnInitCtx.list(WsnInitCtx.java:268)
      at javax.naming.InitialContext.list(InitialContext.java:399)
      at java.lang.Thread.run(Thread.java:512)
      at java.lang.Thread.run(Thread.java:512)


Acutally throwing exception is my expected result.  My question is, I want to handle the exception by myself, therefore I wrote a try & catch block in between.  However, I don't know why it would disaply the stack trace twice.  Does anyone know how I can suppress the first stack trace display?

Thanks all.
0
Comment
Question by:helloyip
8 Comments
 
LVL 7

Expert Comment

by:damonf
ID: 11792109
you can't surpress the first one.  It's being thrown by the naming service.  But just because it prints a stack trace doesn't mean you can't handle the error.  It's just informational.
0
 

Author Comment

by:helloyip
ID: 11792617
Well.....Thanks for your reply first.

But is it really I can't suppress the first message? How about if I want to absorb this exception in my program logic?  I just want to treat it as normal case and don't want to alert anybody!

Thanks.
0
 
LVL 7

Accepted Solution

by:
damonf earned 250 total points
ID: 11792834
I'm not going to say categorically that it can't be suppressed.  But in my experience I frequently get JNDI and JDBC exceptions that are thrown by the service provider.  I handle them in my code, but the provider still prints a stack trace to the console.  For example, in my JDBC code I'll frequently see something where it says something like "DB2 JDBC provider is mapping the following exception to a StaleConnectionException ... blah blah" ... this is printed to the console.  When my code actually gets the exception, I will try the JDBC call again and everything is fine.  The user sees nothing.  All that happens is a little stuff gets written to the console.

When you say "don't want to alert anybody" ... what do you mean?  I mean, the user can't see the console.  Now if you have various monitoring tools viewing your log, you could just tell them to ignore this message.  

You might try playing with TraceSettings.properties ... if the JNDI provider is using ras for logging, this would affect the output.  Also keep in mind that what you see in WSAD log might not be the same as what you see on the server.  Usually the logging is set for more detail in WSAD.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Expert Comment

by:helloexp
ID: 11847077
hello,

i would suggest redirect it to a logger like log4j and configure the properties of log4j using the FileAppender.
You can use various modes of log4j to control the output to file too by setting it to modes like ALL, DEBUG, INFO, WARN, ERROR.

- h
0
 
LVL 7

Expert Comment

by:damonf
ID: 11850917
log4j isn't going to solve it ... this is WebSphere's own internal logging that's generating the error.  
0
 
LVL 1

Expert Comment

by:fschutte
ID: 11907674
Yes, it is informational. The I in NMSV0610I say it is. The W in front of the id says it is a warning and not an error. If you are expecting the exception, the message can be ignored. In the end the log will end up with lots of useless messages anyway..
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Verbose logging is used to diagnose garbage collector problems. By default, -verbose:gc output is written to either native_stderr.log or native_stdout.log.   It is also possible to redirect the logs to a user-specified file. This article will de…
This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now