[WAS 5.1.1.8] get the Node Instance name
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > WebSphere > WebSphere Application Server > [WAS 5.1.1.8] get the Node Instance name




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    [WAS 5.1.1.8] get the Node Instance name  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-06 12:53 PM

Hello,

Have you any idea to get (in Java Language) the name of the instance or the 
node which is used ?

In fact I want to add a trace in my log file, when I have a Exception in one
 servlet deployed in one node, I want to log the error with the name of the 
current node.

Thanks for your help,

Best regards,

Pierre Chauvin





[ Post a follow-up to this message ]



    Re: [WAS 5.1.1.8] get the Node Instance name  
Ken Hygh


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-06 12:53 PM

pierre_c@editus.lu wrote:

>Hello,
>
>Have you any idea to get (in Java Language) the name of the instance or the
 node which is used ?
>
>In fact I want to add a trace in my log file, when I have a Exception in on
e servlet deployed in one node, I want to log the error with the name of the
 current node.
>
>Thanks for your help,
>
>Best regards,
>
>Pierre Chauvin
>
>
Servlet to display node name (tested on v6):
--------------------------------------------------
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Set;

import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.websphere.management.AdminServiceFactory;

public class ShowNode extends HttpServlet implements Servlet {

protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html><head><title>Show Node</title></head><body>");
out.println("<h2>Port Name</h2>");
MBeanServer server =
AdminServiceFactory.getMBeanFactory().getMBeanServer();

try {
Set objectNames = server.queryMBeans(new
ObjectName("WebSphere:type=JVM,*"), null);
for (Iterator iter = objectNames.iterator(); iter.hasNext() ;) {
ObjectInstance oName = (ObjectInstance)iter.next();
String node = oName.getObjectName().getKeyProperty("node");
out.println("<br/>Node name: '" + node + "'");
}
} catch (MalformedObjectNameException e) {
out.println("<font color=\"red\">Exception: " + e + "<pre>");
e.printStackTrace(out);
out.println("</pre></font>");
}
out.println("</body></html>");
}
}





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:36 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register