?
Solved

JNDI exception question under WSAD

Posted on 2004-08-13
8
Medium Priority
?
2,724 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 1000 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
Technology Partners: 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

765 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