Solved

JNDI exception question under WSAD

Posted on 2004-08-13
8
2,717 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
[X]
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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

732 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