Tag Archives: JMX

Jetty JMX Example


via Jetty JMX Example | Examples Java Code Geeks.

JMX technology provides a simple, standard way of managing resources such as applications, devices, and services. Jetty itself does not provide a GUI based console for management/monitoring, however ii presents a solid integration with JMX, which enables us to monitor/manage Servers through JMX.

In this post we are going to discuss JMX integration of Jetty. We will start with an Embedded Jetty example. We will first configure our embedded server to be accessible through JMX; thereafter we are going to incorporate Managed Objects in Jetty style. After the embedded example, we are going to show how we can enable JMX in a standalone Jetty Server. During the example, we are going to monitor and administer our Jetty through JConsole.

In Jetty, the main constructs such as handlers and holders are also JMX beans. This makes almost every single piece of Jetty observable or controllable through JMX. In addition this, Jetty enables creation of JMX objects(MBeans) through annotations(which is an extension to standard MBean capabilities).

Maven Jetty Plugin Example


via Maven Jetty Plugin Example | Examples Java Code Geeks.

In this example, we shall show you how to integrate Apache Maven with Jetty. Apache Maven is a software project management and comprehension tool. It provides powerful features like superior dependency management including automatic updating and transitive dependencies.

It follows the principle of convention over configuration, due to which one can start with a minimal configuration and sensible defaults will be provided for all the missing configuration. Maven uses central repositories where various artifacts like JAR files can be hosted. It comes with a mechanism that resolves all project dependencies from these central repositories. So effectively you are resolved from keeping and providing JAR files on your project’s classpath.

Maven needs a file called ‘pom.xml’ where one can define dependencies as we will be seeing in the example below. Once you choose to build the project, these dependencies will be automatically fetched from central repository and put on your application’s classpath. Jetty is a web server and a servlet container. It also provides support for SPDY, WebSocket, OSGi, JMX, JNDI, JAAS etc. So it is quite similar to the likes of other application containers. However if differs from them by providing a really tiny memory footprint and being Embeddable.

This means we do not need to install Jetty and then deploy our application. We just need to start our application from command line and Jetty will be started as an embedded container inside our application.This makes Jetty quite handy for tasks like Micro Services implementation and integration tests writing.

For this example we will be using Apache Maven 3.2.5 and Jetty Version 9.2.6. The example is compilable on Java 5 and above.