Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JNDI exception question under WSAD

Posted on 2004-08-13
8
2,714 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

-Xmx and -Xms are the two JVM options often used to tune JVM heap size.   Here are some common mistakes made when using them:   Assume BigApp is a java class file for the below examples. 1.         Missing m, M, g or G at the end …
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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