VisualVM how to use 'JConsole Plugins Container' plugin - visualvm

I have installed VisualVM JConsole plugin. not able to find any document to how to invoke jconsole from VisualVM. I get below option.
my question is: What Jar file I need to add?, and how to use Jconsole from VisualVM?

VisualVM is replacement for JConsole, so it does not make sense to use Jconsole from VisualVM. JConsole Plugins Container adds support for using existing JConsole plugins (like JTop) inside VisualVM.

Related

log4j2 for MULE 3 CE patch update

I need some information of log4j2 for updating our central versions of Mule CE 3.9.0 and Mule CE 3.9.5 (CE=Community Edition).
What is the best way to protect them and does downloading only jar files from Apache site https://dlcdn.apache.org/logging/log4j/2.12.3/ be useful to patch Mule CE 3.9?
Regards
As a summary you only need to find the vulnerable jars in the mule-server and in the mule flows deployed in the apps folder.
A Java project is a set of java class and libraries with complex dependencies relationship, but easy to replace one of them (manually or automated with maven), so no matter how or where log4j is being used, we just need replace the jar file.
mule community server 3.9.0
In this version, with this command find . -type f -iname "*log4j*" we will get the log4j jars:
As we can see, the version prior to the 2.14.x
log4j-jul-2.8.2.jar
log4j-jcl-2.8.2.jar
log4j-slf4j-impl-2.8.2.jar
log4j-core-2.8.2.jar
log4j-api-2.8.2.jar
log4j-1.2-api-2.8.2.jar
But according to the official maven repository, this version is affected too :(
Just the 2.17.0 is safe to use
Source: https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
If this change breaks your mule, just delete the specific vulnerable class:
zip -q -d
log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
Source: https://www.docker.com/blog/apache-log4j-2-cve-2021-44228/
mule flow or mule app
This is not the server, is the app developed by programmers, packaged as .zip and deployed to the mule apps folder in the server.
In this layer, the app can ignore completely the server configurations and has its own jar versions.
If you don't use maven (rare), you need to search and replace the jar, app by app, similar to the server with find command but in the specific app folder:
/opt/mule_server/apps/my-mule-app
If you use maven, you could find if the jar is used with the pom.xml previewer of Eclipse Ide or with command mvn dependency:tree. Check this:
https://stackoverflow.com/a/68916675/3957754
Remember: If you not use directly this jar, you need to check if mule esb server uses it.
Here some tips from manual to automated pipelines:
mule esb monolithic with manual deployment
In this case you need to fix the server and your apps.
for the server, backup, stop, search the jar on lib folder and replace it with the 2.17 (after vulnerability fix) and start. Test if everything is working
for the mule apps, the process is the same: stop the mule server, go to your mule apps and one by one, search the jar and replace it. Start the mule server and test if everything is working
git repository , maven and one mule app by server
In this case, you don't have a big server with a big mule containing a lot of mule apps/flows. You have one light server for just one mule app.
Just search the dependency in your pom with maven and replace it.
Push your changes and in the next deploy( manual or automated) your mule app will be fixed.
Also note that this approach fix the app, not the server.
git, docker
If you are using docker, the things are easy. Just search the Dockerfile (usually in a git repository). In this file there are a lot of sentences, since the java installation until the star of mule server.
Choose the exact line between the download of mule and the start of server and put a sentence which replace the jar file
Next deploy will pick you new image version and that's all.
automated flow(devops)
Here you are using maven, gi, docker and some ci server. You just need:
update the git repository of your mule app (maven)
update the git repository of your docker image
deploy your fix using the ci server.
With this, you will not need human access to the production servers to fix your java application ( mule)

Java VisualVM MBeans plugin

I am running JDK 1.8.0_66 JVisualVM utility and want to use MBeans browser to Monitor my Coherence applications.
According to the Oracle tutorial I have to install the MBeans plugin first. So I went to Tools-Plugins-Available Plugins and there were no any available plugins. I checked my JDK installation for *.nbm files and found nothing.
What do I need to do to install MBeans plugin for JVisualVM? Thank you in advance.
When accessing https://visualvm.java.net I get redirected to http://www.oracle.com/splash/java.net/maintenance/index.html which states that the page has been closed.
Thus I think you have to download and install the plugins manually.
Go to https://visualvm.github.io/pluginscenters.html
Choose the link to "Java VisualVM" according to your JDK version
Download the tool manually
Select "Tools" -> "Plugins" -> "Downloaded" tab to install the downloaded file
Worked for me.
It appears the visualvm site has moved to github.io, so the links are broken. I just updated mine to the correct one on found on
https://visualvm.github.io/pluginscenters.html
In VisualVM go to Tools -> Plugins -> Settings, Edit Java VisualVM Plugins Center, and change the URL to the correct URL for your VisualVM, ex:
https://visualvm.github.io/archive/uc/8u40/updates.xml.gz
After this I was able to update & install plugins using the UI again.
You need to be connected to internet and you should have access to https://visualvm.java.net

Logback beagle does not work under Spring tool suite

I have STS 3.6.3 running on 64bit windows 7, java 1.8u25. According to the http://logback.qos.ch/beagle/index.html I have installed the following plugins:
Logback Beagle Feature 1.1.4.201209042005
Logback Feature 1.0.7
Nebula Grid Feature 1.0.0.201412230843
SLF4J Feature 1.6.6
Unfortunatelly the Beagle window does not show up and the following error is written in the STS log: http://pastebin.com/YpL00TZ3
Can you help ?
You'll need to clean up conflicting SLF4J libraries in eclipse, then modify the manifest of the Beagle jar to depend on the version of SLF4J already in eclipse.
In spite of the documentation, you need to remove the Logback Feature and SLF4J Feature from Eclipse (They can be removed via Help > About Eclipse > Installation Details > Install Software). You should only have "Nebula Grid Feature" and "Logback Beagle Feature" installed for Beagle.
Then you need to browse to your eclipse/plugins folder and open 'ch.qos.logback.beagle_1.1.4.201209042005.jar' in your favorite zip tool, then edit WEB-INF/MANIFEST.MF' to change the textslf4j.api;bundle-version="1.6.6"toorg.slf4j.api;bundle-version="1.7.2"`. Make sure to save the updated file back in the jar.
Finally, restart eclipse from the command line using eclipse.exe -clean.
Source: The discussion here and commit here.

To use ServiceMix my project has to be an OSGi bundle?

I' starting to use ServiceMix and Camel and I've run through many examples.
It seems that the examples that are OSGi can be deployed in ServiceMix via hot deploy or via console, but I don't know how to deploy a project that is not an OSGI. Can it be done?
For example, I'm looking at the example project from Camel 2.10.0 called camel-example-cxf-proxy. I did some alterations and now I wanted to load it in ServiceMix. If I copy/paste to the deploy directory it is loaded but when I try to run it via osgi:start id it fails.
However if I run it from the IDE as a standalone it runs just fine and I can send and receive requests via SoapUI.
When I'm done with the examples I'll want to create my own project in eclipse and do tests in the IDE and in ServiceMix. I don't really understand the advantage of OSGi yet. SO I'm not too compelled to use OSGi for my project.
My main question is: Can I deploy a non-OSGi non-JBI compliant project in servicemix? Something like the camel-example-cxf-proxy. If yes, how can I do it? If no, how can I OSGi-fy the camel-example-cxf-proxy?
Thank you :)
Apache ServiceMix which uses Apache Karaf as its kernel, support pluggable deployment units. Though OSGi is the main unit.
You can deploy JBI artifacts (eg JBI was used as deployment units for Apache ServiceMix 3.x). So we offer that as a migration path to run JBI in SMX 4.x.
A plain WAR file can be deployed as well. You can for example just drop a .war file in the deploy directory. If you deploy from the shell, you need to prefix the deployer with war so it knows to use the war deployer.
There is some documentation about the various pluggable deployers here
http://fusesource.com/docs/esbent/7.0/esb_deploy_osgi/UrlHandlers.html
For example to install an Apache Wicket WAR example using Maven you can do from the shell:
osgi:install war:mvn:org.apache.wicket/wicket-examples/1.4.7/war?Web-ContextPath=wicket
The Apache documentation about deployer is mainly documented at Apache Karaf
http://karaf.apache.org/manual/2.2.9/users-guide/deployer.html
Now to deploy OSGi applications can be a bit of pain to assemble. And that is why FuseSource created FAB to make it much easier. I blogged about this a bit, which references to videos and more material: http://www.davsclaus.com/2012/08/osgi-deployment-made-easy-with-fab.html
With FAB you can just deploy regular Maven projects out of the box without any OSGi pain.
If your project is a maven project, you can try :
mvn install
Then start your servicemix, and in servicemix command line :
install mvn:groupId/artifactId/version
This will prompt a bundle ID. Then, juste start the bundle :
start <bundle_id>
You can check the state of your bundle with command "list"
The project has to be a bundle to be installed in servicemix / karaf. So the steps to make a camel project work in OSGi are the following.
Use the maven bundle plugin in the pom and configure it to import / export the necessary packages if necessary.
Make sure your camel context is defined in a way that OSGi can start. This is either in the activator of the bundle or in a spring config in the right location or with a blueprint config in the right location.
See two of my karaf tutorials for the details:
CXF: http://www.liquid-reality.de/x/EoBk
Camel: http://www.liquid-reality.de/x/G4Bk

maven tomcat plugin or cargo plugin?

The spring source code examples use maven tomcat plugin and i am able to run these projects using the command mvn tomcat:run but what i dont see the application is not deployed in local tomcat server("C:\apache tomcat\webapps\")..
And how it is different from cargo plugin? (In this case when i ran the command mvn cargo:redeploy, i see the application deployed in the location "C:\apache tomcat\webapps\")
If i add cargo plugin to the POM of spring examples (like mvn-showcase,petclinic)..will it screw up the things?
The spring source code examples use maven tomcat plugin and i am able to run these projects using the command mvn tomcat:run but what i dont see the application is not deployed in local tomcat server("C:\apache tomcat\webapps\")
The command tomcat:run starts an embedded Tomcat, it doesn't deploy an application to your local Tomcat (why does it matter anyway?).
And how it is different from cargo plugin?
Cargo is a container agnostic tool so you could configure it to use a remote container, a locally installed container, an embedded container (as long as implementations are provided for a given container) and still use an unified API (or set of commands).
In this case when I ran the command mvn cargo:redeploy, I see the application deployed in the location "C:\apache tomcat\webapps\"
Cargo doesn't support running Tomcat+6.x in embedded mode. So you are very likely using it with a locally installed container and your app gets physically deployed on it.
If i add cargo plugin to the POM of spring examples (like mvn-showcase,petclinic)..will it screw up the things?
It won't screw up anything, why would it.
You can use tomcat maven plugin and deploy it to external tomcat server.
see this link for all the available goals. tomcat-run will start a embedded server but tomcat:deploy works for external tomcat.