Connect visualvm to websphere 7 - java

I am trying to get visualvm and websphere 7 to work together on my local windows desktop. I try to connect through JMX but no luck. Has anybody managed to get visialvm and websphere 7 to work and ow did you do it?
Regards
FF

I got it to work with the help of the VisualVM team in Praha (Thanks Tomas!):
1) On the admin console (Click on Servers -> Server types -> WebSphere application servers -> server1 -> Java and Process Management -> Process definition -> Java Virtual Machine), add the following line into the field of
Generic JVM Argument (note that the first system property is equal to
nothing and no equal sign for the second system property):
-Djavax.management.builder.initial= -Dcom.sun.management.jmxremote
2) Add or uncomment the following three lines in file /opt/IBM/
WebSphere/AppServer/java/jre/lib/management/management.properties
(or / lib/management/management.properties):
com.sun.management.jmxremote.port=3333
com.sun.management.jmxremote.authenticate=false
com.sun.management.jmxremote.ssl=false
com.sun.management.jmxremote.local.only=false
3) Connect VisualVM!

It is possible to set these parameters port, authenticate and ssl as JVM Arguments like -Dcom.sun.management.jmxremote.port=1300
I have another issue: by using the mbean visualvm plugin I can not see any relevant Websphere mbean.

It depends on what you want to achieve and the constraints you have. What you need to know is that there are two MBean servers in WebSphere: in addition to the platform MBean server created automatically by the JRE, WebSphere also creates its own MBean server. Here are the two options you have:
Configure your WebSphere server as described in the answer given by user271858. This will allow you to connect to the platform MBean server. You will get access to the standard platform MBeans that provide process information (RAM, CPU, threads, etc.). On the other hand, you won't be able to access WebSphere's MBeans (implementing certain administrative actions, providing application metrics, etc.). You also need to be aware that by changing the configuration of the WebSphere server, you bypass WebSphere's security.
Connect to WebSphere's MBean server. WebSphere supports several protocols to do that (mainly SOAP and RMI), but none of them is completely standard. This means that you will need to add some of the WebSphere libraries (namely the admin thin client) to VisualVM. It is probably possible to do that (It works with JConsole, so in principle it should be possible with VisualVM as well), but it's tricky, especially it you need to connect to a WebSphere server that has security enabled.
A simpler option is to install the VisualWAS plugin into VisualVM. It relies on an Open Source implementation of one of the proprietary WebSphere protocols and therefore doesn't require any additional WebSphere library.
This will give you access to MBeans registered in WebSphere's MBean server, but not to the standard platform MBeans, i.e. the relevant parts (related to memory, CPU and threads) in VisualVM will be disabled. You can however cross-register the platform MBeans in WebSphere's MBean server, and the VisualWAS project provides a solution for this as well (in the form of a plugin to be installed into WebSphere). You will then have access to all features in VisualVM, and you don't need to bypass WebSphere's security.

Related

Reading common variable from J2EE and Java apps

I don't mess with WebSphere often enough to know if this will work. I would like my J2EE or plain Java apps to know on which box it is running, i.e PRODUCTION, DEVELOPMENT or TEST, and use PROD, DEVL or TEST resources accordingly. Since this info is common to all apps, I don't want to store it within any particular app. Is it possible to store an (environment?) variable on the Linux box or within WebSphere (outside of all apps) that is accessible to all J2EE (Struts2) apps and plain Java apps? I would appreciate any pointers in this regard. Thanks.
Yes. I'm not a WebSphere user, but a quick search provides this: Setting environment entries in WebSphere Application Server.
WebSphere Application Server 7.0, 8.0, 8.5 and 8.5.5
Open the administrative console.
Select Servers > (Expand Server Types) > WebSphere application servers > server_name > (Expand Java™ and Process Management) > Process Definition > Environment Entries > New.
Add entries to the Name/Value pairs.
Click OK.
Save changes to the master configuration and restart the Application Server.
WebSphere Application Server 6.1
Open the administrative console.
Select Servers > Application Servers > server_name > (Expand Java™ and Process Management) > Process Definition > Environment Entries > New.
Add entries to the Name/Value pairs.
Click OK.
Save changes to the master configuration and restart the Application Server.
I do nearly the same thing in JBoss/Wildfly. You are simply setting up an entry the JVM's Environment.
Edit in response to 1st comment:
I think it's a safe guess that your Java app doesn't run in the same JVM as your J2EE app on WebSphere. Separate JVMs = separate environments. We use Java Web Start to distribute and kick off local Java apps from different environments - each server environment writes a JNLP containing the appropriate app setup. If you just need apps on the same machine to know where they are you can set up an shell variable, as you said, that could be read by both WebSphere and Java apps.
Edit #2, regarding WebSphere - after further investigation:
I also found this, which is a partial duplicate of this question: Place for setting environment variables for WebSphere JVM process. The answer there notes that using the WebSphere GUI to enter the env variables is also preferable for clustering.
You might want to use use the WebSphere specific method in combination with the shell variables.

Many versions on one IBM Websphere server

Is it possible to deploy different versions of single application on one IBM Websphere Application Server (WAS)?
For example I have:
App1 with url binding http://app/1.0/service/
App2 with url binding http://app/2.0/service/
Is it possible?
I think not due to port listening issue, but maybe there is some chance...
It should be possible, but with some restrictions (depending on your application). If you have WAS ND 8.5.5, then you have Application Edition management feature. Read more details on that page.
If you are on the older version, you will have to change several things during deployment, e.g.:
context-root of the application
JNDI EJB binding names
if other version is using different database - update the JDBC references
if other version is using additional resources (like queues, qcf) update them also.
Actually, port listening has nothing to do with it, as both application will use same port, but different context-roots.
This of course assumes that application doesn't have hard coded values in it (like context root, jndi names, etc).

Use Jolokia to monitor JMX endpoint of webapp on same Tomcat server

Jolokia is uncharted territory for me, and after having read the documentation, I'm still not sure if it'll work with the scenario I have in mind.
Setup:
Tomcat application server (version ranges from 6.x to 7.x), usually on a Windows platform, occasionally a flavour of Linux.
Deployed third-party Java web application (SAP BusinessObjects) with JMX monitoring enabled (accessible through RMI).
Possible gotcha's:
The Java web application to be monitored is commercial and closed source, so modifications are not possible. The only thing that can be changed is the JMX port number
The JMX endpoint is a custom one, thus not the default jmxrmi endpoint.
The JMX connection requires authentication.
Goal:
What I'd like to do is to deploy the Jolokia WAR file onto the Tomcat server and then configure it so that I can read the MBean attributes from the other web application.
I would code the client myself using Python (version 3) and the Requests HTTP library.
I've been reading through the Jolokia documentation (again, I'm a complete newbie at this point), but can't figure out if this would be possible or not (as I can't seem to find where to enter the JMX/RMI url or the authentication information).
Questions:
Can I use the WAR agent for this setup?
If not, can you please explain why (so I can understand, not because I don't believe you). Also, is there another agent that's more suited for this scenario?
If yes, can you point me in the right direction how to configure the Jolokia to the web application to connect to?
First of all, Jolokia by passes the JSR-160 connector stuff completely, so there is no need for any JMX/RMI authentication. The whole purpose of Jolokia is to provide a bridge over HTTP/JSON to the internal JMX subsystem. Depending on the agent, you can secure Jolokia quite easily. For the WAR agent, securing is the same as for any Java EE web app: Setup some roles and users for tomcat (e.g. in tomcat-users.xml) and reference the role in the security contstraints within the jolokia.war's /WEB-INF/web.xml.
To your questions:
Yes, you can. If you don't have any specific authentication needs, simply drop the jolokia.war into tomcat's /webapps directory. I suggest to try this first before adding security. For deinstalling the agent, simply remove the war.
As an alternative, you could also use the JVM agent, which opens an own HTTP server on an extra port (default: 8778). More on this in the reference manual
There is no need for a dedicated connection to the web app since MBeans are registered globally and are accesible from anywhere in the JVM. A webapp should of course select carefully the management information it exposes. So, there is no extra step needed and you can access the MBeans for the WEB app directly (except when it does something unusual with Java security, but I don't think so).
To test the installation, simply connect to the Tomcat with your browser and the context /jolokia (e.g. "http://localhost:8080/jolokia"). You should see the version information about the agent itself.
The next step would be to explore the JMX namespace, either with the browser (and operation "list" like in http://localhost:8080/jolokia/list , but that's tedious) or with a client like j4psh or hawt.io. Hopefully you will find the MBeans of your webapp you are looking for.

How to manage JBoss Wildfly resources(server, applcation etc) in domain mode programmatically

In JBoss AS in domain mode how can I manage server resources programmatically, that is by my own client app?
That is - to create/remove start/stop servers, server groups, deploy/undeploy applications etc.
I read that this can be achieved by using JMX MBeans. However when running in standalone mode i could list all jboss MBeans, but in domain mode can see only ModuleLoader MBean. Anyway, i found by using JMX MBeans that have to write very long code. So here are the questions:
1) is there a client library for JBoss server resource management for Java?
2) if there is only by JMX to manage resources, then how can i list all MBeans of the server in domain mode? i put <remoting-connector/> in domain.xml but should i have to specify anything anywhere else?
The tools i am using are: JBoss Wildfly 8.1, IntelliJ IDEA 13.1, Java 8, Windows 8.1/Debian 7.
Thanks in advance.

Missing Websphere NodeAgent JMX MBean

I am trying to run the sample code from IBM (sample code link) to connect to Websphere Application Server v7.0 through a JMX client.
I could successfully connect to the Websphere MBeanServer by jconsole, and could see two domains exist (JMImplementation and WebSphere). However, I found that there is no NodeAgent MBean as specified in the sample code with ObjectName pattern WebSphere:type=NodeAgent,node=<some node>,*.
Does anybody know why the NodeAgent MBean is not there?
You can run such query "WebSphere:*" - so you will get all mbeans you have in time of query evaluated. Just print it out to get expression what you actually have. For example i have only server and portal mbeans in my configuration and no nodeAgent. So this sample will not work in my environment too.
Which edition of WebSphere are you running? WebSphere Express does not include node agents or a deployment manager. WebSphere Network Deployment includes these components to support a variety of features. It's filled with marketing speak, but IBM has a PDF listing high-level differences between the various editions.

Categories