JMX (Java Management Extensions) Interview Preparation Guide
Download PDF

JMX Interview Questions and Answers will guide us now that Java Management Extensions (JMX) is a Java technology that supplies tools for managing and monitoring applications, system objects, devices such as printers and service oriented networks. Those resources are represented by objects called MBeans, so learn more about JMX by this JMX Interview Questions with Answers guide

30 JMX Questions and Answers:

Table of Contents:

JMX Interview Questions and Answers
JMX Interview Questions and Answers

1 :: How is the application JVM configured?

The application JVM is configured with the following options:
☛ com.sun.management.jmxremote
☛ com.sun.management.jmxremote.port=1088
☛ com.sun.management.jmxremote.authenticate=false
☛ com.sun.management.jmxremote.ssl=false

2 :: What are the advantages of setter dependency injection?

Here are a few advantages of Setter:
☛ Natural for Java Beans
☛ Avoids overly long constructors
☛ Can be inherited
☛ Easier to understand in that properties have names
☛ Constructor args don't have names

3 :: How to access JMX (Java Beans) from a process running in docker container?

You have to expose the JMX port to the host and even used Sun specific options while running the Java process.
You are able to telnet to the host ip and the exposed JMX port, which tells that it is accessible. But I can't figure out a way to use JConsole and connect to the JMX service running in the container.
☛ Djava.rmi.server.hostname=$JMX_HOSTNAME
☛ Dcom.sun.management.jmxremote.port=$JMX_PORT
☛ Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT

4 :: What are the various actions performed when an application context is created?

Here are 5 steps:
☛ Read bean file XML (or process annotations). Build internal "map" of beans and determine dependency tree.
☛ Post process the definitions - e.g. resolve ${variables}
☛ Allocate objects - dependency inject constructor args and invoke setter.
☛ Perform any initialisation - 3 approachs: @PostConstruct, init-method, InitializingBean
☛ Bean post-processors - e.g. wrap with proxy, @Required

5 :: What is a named pointcut and why to use one?

A pointcut expression that has a name so it can be reused.
Resons To use:
☛ Annotation: @Pointcut applied to a dummy method - name of the dummy method is the name of the pointcut expression.
☛ XML aop:pointcut id=".." expression=".."

6 :: List some types of advice?

Types of advice:
☛ Before
☛ AfterReturning
☛ AfterThrowing
☛ After
☛ Around

7 :: What is an advice in JMX?

he code that implements the cross cutting-concern that will be inserted at each join-point.

8 :: What is a join-point?

Joint-point is an expression that defines zero or more join-points.

9 :: What is a cross-cutting concern?

A requirement that cuts across all the natural modules of your application.
Examples:
Tracing, security, transactions, business rules.
Two problems with cross-cutting concerns.
☛ Code tangling - method doing too many unrelated tasks
☛ Code scattering - code duplication leading to maintenance headache

10 :: What is lazy initialization?

Bean is not allocated until it is actually needed - dependency injected - or requested via getBean(). specify lazy="true" (false by default). Only useful if bean genuinely may never be used in most runs of the application.

11 :: What is a nested bean?

Scopes the bean within the bean that uses it. One less bean id in the set of bean names.

12 :: List 2 examples of anonymous bean?

Two examples:
☛ Nested or inner beans
☛ Configuration beans

13 :: What are the 5 scopes defined in Spring?

5 scopes defined in Spring:
☛ Singleton
☛ Prototype
☛ Session - only valid in a Web application context
☛ Request - ditto
☛ Custom

14 :: How does a Spring Factory Bean work?

It is created by Spring automatically, any setters are called on the factory then its getObject() method is called to allocate the actual bean.

15 :: What is the advantage of constructor dependency injection?

Here are a few advantages:
☛Constructor
☛Mandatory
☛Mutable
☛Natural Java approach.

17 :: How is dependency injection performed in the bean-file XML?

There are nested elements within each bean definition.

18 :: Why is dependency injection useful?

Different collaborators for different environments can be injected - test, production, test-database, real database. This allows classes to be tested independent of its collaborators (makes it easy to pass in stub or mock objects).

19 :: What is dependency injection?

A pattern (design) whereby collaborators are passed into an object from the outside - the object does not allocate them for itself.

20 :: How to run JMX Java application in uDeploy process?

Copy {WLHOME}/wlserver_**/server/lib/wlfullclient.jar file into {agent home}/opt/groovy-1.8.8/lib Then the Groovy script (that migrated from my JMX Java application) works.

21 :: How will you check if JMX agent is working in Tomcat?

When Tomcat is running as a service on Windows, you do not need setenv.bat, you need to use tomcat8w.exe and GUI toll for adding options.

22 :: What if there is no JMX data?

No JMX-related output in the logs. I can connect to the JVM with jconsole using the supplied credentials, browse to the configured mbean, jackhammer the Refresh button and get new values. Splunk, however, gets nothing, and leaves no indication as to why. Searching for "host=redacted" or "source='jmx://redacted'" yields nothing.
This is not a complicated setup, nor is it a complicated app. Single server test environment, just trying to get JMX data into Splunk directly instead of having to do some nasty search-time field extraction after indexing data output from JMXTrans text files. It's currently running on JDK 1.7, I tried 1.6 for science to no avail. No idea how to proceed since I'm not getting any errors and there doesn't appear to be a way to raise the log level.

23 :: How would you connect JMX monitoring to Tomcat?

You have to install the jmx_ta on a 6.2 forwarder and getting the following error"
12-04-2014 16:08:02.884 +0000 ERROR ModularInputs - Introspecting scheme=jmx: script running failed (exited with code 1).
12-04-2014 16:08:02.884 +0000 ERROR ModularInputs - Unable to initialize modular input "jmx" defined inside the app "jmx_ta":
Introspecting scheme=jmx: script running failed (exited with code 1).

24 :: How to connect to multiple jmx instances using Splunk for JMX?

Install Splunk 6 on your server which contains about 6 different JMX instances. you want to hook all of them up into our Splunk JMX plugin.
It is as easy as editing the config.xml file and adding a new jmx server host? Currently this is:
<jmxserver host="[[system name]]" jvmDescription="common_raw" jmxport="53632">

25 :: What is Managed Bean or MBean?

A managed bean - sometimes simply referred to as an MBean - is a type of JavaBean, created with dependency injection. Managed Beans are particularly used in the Java Management Extensions technology. But, with the Java EE 6 specification provides for a more detailed meaning of a managed bean.