11 Replies Latest reply on Oct 3, 2013 5:01 AM by Hirt-Oracle Branched to a new discussion.

    Error Connecting to Remote JVM

    fb8caed7-0043-463f-8b59-08057f8407a4

      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 ?

        • 1. Re: Error Connecting to Remote JVM
          Klara Ward, Java Mission Control Dev-Oracle

          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)

          1 person found this helpful
          • 2. Re: Error Connecting to Remote JVM
            fb8caed7-0043-463f-8b59-08057f8407a4

            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 ?

            • 3. Re: Error Connecting to Remote JVM
              Klara Ward, Java Mission Control Dev-Oracle

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

              • 4. Re: Error Connecting to Remote JVM
                fb8caed7-0043-463f-8b59-08057f8407a4

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

                • 5. Re: Error Connecting to Remote JVM
                  fb8caed7-0043-463f-8b59-08057f8407a4

                  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

                  • 6. Re: Error Connecting to Remote JVM
                    fb8caed7-0043-463f-8b59-08057f8407a4

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

                     

                    Thanks for your help.

                    • 7. Re: Error Connecting to Remote JVM
                      Klara Ward, Java Mission Control Dev-Oracle

                      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)?

                      • 9. Re: Error Connecting to Remote JVM
                        Hirt-Oracle

                        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

                        • 10. Re: Error Connecting to Remote JVM
                          Klara Ward, Java Mission Control Dev-Oracle

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

                          • 11. Re: Error Connecting to Remote JVM
                            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.