JNDI exception question under WSAD

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.
helloyipAsked:
Who is Participating?
 
damonfCommented:
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
 
damonfCommented:
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
 
helloyipAuthor Commented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
helloexpCommented:
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
 
damonfCommented:
log4j isn't going to solve it ... this is WebSphere's own internal logging that's generating the error.  
0
 
fschutteCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.