Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error Connecting to Remote JVM

1044925Oct 2 2013 — edited Oct 3 2013

I want to connect to remote JVM using JavaMissionControl.

Remote Machine :

java -version

java version "1.7.0_40"

Java(TM) SE Runtime Environment (build 1.7.0_40-b43)

Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

Remote application is started with following vm flags

-Dcom.sun.management.jmxremote.autodiscovery=true -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=60s,filename=myrecording.jfr

Now i run JMC on my local machine and try to connect to remote JVM. I can connect to MBeansServer and browse everything there. But i can not access Flight Recorder data in my JMC. It gives following error :

java.lang.RuntimeException

  at com.jrockit.mc.flightrecorder.controlpanel.ui.FlightRecorderProvider.refresh(FlightRecorderProvider.java:107)

  at com.jrockit.mc.browser.views.JVMBrowserView$1.run(JVMBrowserView.java:99)

  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)

  at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)

  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)

  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)

  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

  at java.lang.Thread.run(Thread.java:724)

Caused by: com.jrockit.mc.rjmx.services.ServiceNotAvailableException

  at com.jrockit.mc.rjmx.internal.DefaultConnectionHandle.getServiceOrThrow(DefaultConnectionHandle.java:350)

  at com.jrockit.mc.flightrecorder.controlpanel.ui.FlightRecorderProvider.refreshRecordings(FlightRecorderProvider.java:119)

  at com.jrockit.mc.flightrecorder.controlpanel.ui.FlightRecorderProvider.refresh(FlightRecorderProvider.java:98)

  ... 8 more

When i right click on FlightRecorder and select "Start Flight Recording", it throws error

Could not register the Mission Control MBean in the MBeanServer.

Could not register the Mission Control MBean in the MBeanServer.

Any ideas what is wrong here ?

This post has been answered by Hirt-Oracle on Oct 2 2013
Jump to Answer

Comments

What kind of application are you running? I'm thinking possibly the issue is MBean server related somehow.

Do you get the same problem if you just run something really simple, like HelloWorld with a for(;;) loop.

(Or start JDK/bin/jdb with the same jvm flags, just prepend them all with -J)

1044925

My application is a daemon that accepts TCP Connections and processing data.

When i created a simple Main class that loops and sleeps on every iteration, it worked.

Any idea what could be wrong with MBean server ?

Is it possible to run it normally, ie. not in daemon mode, and see if that makes any difference?

1044925

I mean i am not doing anything special to run it in Daemon mode. My app runs infinitely loops on a blocking call ( accept() ).

1044925

I also get problem when doing HeapDump. It gives error

Problems when doing Heap Dump for JOverflow analysis

Problems when doing Heap Dump for JOverflow analysis

And when i try to use DTrace from within my JavaMissionControl. I get this error

com.jrockit.mc.dtrace.recorder.DTraceRecorderException: Remote machine not setup correctly for running DTrace.

  at com.jrockit.mc.dtrace.recorder.Factory.createRemoteDTraceRecorder(Factory.java:70)

  at com.jrockit.mc.dtrace.ui.DTraceStartJob.createRemoteRecorder(DTraceStartJob.java:112)

  at com.jrockit.mc.dtrace.ui.DTraceStartJob.startRemote(DTraceStartJob.java:79)

  at com.jrockit.mc.dtrace.ui.DTraceStartJob.run(DTraceStartJob.java:60)

  at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Caused by: java.lang.RuntimeException: Could not invoke operation SetupState on DTraceMBean

  at com.jrockit.mc.dtrace.recorder.internal.remote.MBeanToolkit.rethrowBadInvoke(MBeanToolkit.java:85)

  at com.jrockit.mc.dtrace.recorder.internal.remote.MBeanToolkit.invokeOperation(MBeanToolkit.java:62)

  at com.jrockit.mc.dtrace.recorder.internal.remote.RemoteRecorder.getSetupState(RemoteRecorder.java:95)

  at com.jrockit.mc.dtrace.recorder.Factory.createRemoteDTraceRecorder(Factory.java:63)

  ... 4 more

Caused by: javax.management.InstanceNotFoundException: com.oracle.management:type=DTrace

  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)

  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:643)

  at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:678)

  at com.sun.jmx.remote.security.MBeanServerAccessController.getAttribute(MBeanServerAccessController.java:320)

  at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1464)

  at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)

  at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)

  at java.security.AccessController.doPrivileged(Native Method)

  at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1427)

  at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:657)

  at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

  at java.lang.reflect.Method.invoke(Method.java:606)

  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)

  at sun.rmi.transport.Transport$1.run(Transport.java:177)

  at sun.rmi.transport.Transport$1.run(Transport.java:174)

  at java.security.AccessController.doPrivileged(Native Method)

  at sun.rmi.transport.Transport.serviceCall(Transport.java:173)

  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)

  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)

  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)

  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

  at java.lang.Thread.run(Thread.java:724)

  at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)

  at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)

  at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)

  at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)

  at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source)

  at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:902)

  at com.jrockit.mc.rjmx.subscription.internal.AttributeValueToolkit.getAttribute(AttributeValueToolkit.java:51)

  at com.jrockit.mc.rjmx.internal.MCMBeanServerConnection.getAttribute(MCMBeanServerConnection.java:153)

  at com.jrockit.mc.dtrace.recorder.internal.remote.MBeanToolkit.invokeOperation(MBeanToolkit.java:53)

  ... 6 more

1044925

So i experimented with different things and i realized that if i TURN OFF jmx authentication then Flight Recorder works.

Thanks for your help.

I was just about to suggest that it might be an issue with authentication. Does it work if you give readWrite permissions (if you had it set to readOnly before)?

1044925

Permission was readWrite and it didnt work

Hirt-Oracle
Answer

Hi there!

You need to ensure that the user you want to access the flight recorder has permission to create the relevant MBeans. You have probably defined the roles in the jmxremote.access file. Try adding:

<your-role-name-goes-here> readwrite \
  create com.sun.management.*,com.oracle.jrockit.* \
  unregister

Kind regards,

Marcus

Marked as Answer by 1044925 · Sep 27 2020

Ah, so that's how you do it. Must be many people having the same problem. We should add it to the FAQ.

Hirt-Oracle

Yep. I've been thinking about writing up a blog on how to safely navigate JMX configuration hell, as there are quite a few more thinks that can go wrong. It will have to wait a bit though. Too busy.

1 - 11
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 31 2013
Added on Oct 2 2013
11 comments
13,597 views