title: Tomcat 7.0.33 JAVA_OPTS configuration
body: <p>I want to use JMX to monitoring tomcat and ActiveMQ with a remote connection.</p>
  
  <p>For activeMQ I added this in JAVA_OPTS in startup.bat:</p>
  
  <pre><code>JAVA_OPTS=
  -Dwebconsole.type=properties \
  -Dwebconsole.jms.url=tcp://localhost:61616 \
  -Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/ jmxrmi
  </code></pre>
  
  <p>When i'm starting the tomcat server and ActiveMQ, in Jconsole i can connect to url :</p>
  
  <pre><code>service:jmx:rmi:///jndi/rmi://x.x.x.x:1099/jmxrmi
  </code></pre>
  
  <p>For tomcat monitoring i added:</p>
  
  <pre><code>-Dcom.sun.management.jmxremote ^
  -Dcom.sun.management.jmxremote.port=9004 ^
  -Dcom.sun.management.jmxremote.ssl=false ^
  -Dcom.sun.management.jmxremote.authenticate=false ^
  -Djava.rmi.server.hostname=x.x.x.x
  </code></pre>
  
  <p>Then, when i'm trying to connect to url <code>service:jmx:rmi:///jndi/rmi://x.x.x.x:9004/jmxrmi</code> in Jconsole,the connection fail.
  I tried with Netbeans (who seems to use catalina.bat rather than startup.bat) and moved the java_opts from startup.bat to catalina.bat and here the logs when I start the server:</p>
  
  <pre><code>'-Dcom.sun.management.jmxremote' n'est pas reconnu en tant que commande interne
  Using CATALINA_BASE:   "C:\Program Files\apache-tomcat-7.0.33"
  Using CATALINA_HOME:   "C:\Program Files\apache-tomcat-7.0.33"
  Using CATALINA_TMPDIR: "C:\Program Files\apache-tomcat-7.0.33\temp"
  Using JRE_HOME:        "C:\Program Files\Java\jdk1.7.0_07"
  Using CLASSPATH:       "C:\Program Files\apache-tomcat-7.0.33\bin\bootstrap.jar;C:\Program Files\apache-tomcat-7.0.33\bin\tomcat-juli.jar"
  ou externe, un programme ex‚cutable ou un fichier de commandes.
  '-Dcom.sun.management.jmxremote' n'est pas reconnu en tant que commande interne
  ou externe, un programme ex‚cutable ou un fichier de commandes.
  </code></pre>
  
  <p>Sorry for the french stuff, the important part says that -Dcom.sun.management.jmxremote is not recognize as an internal or external command.</p>
  
  <p>Jconsole debug output:</p>
  
  <pre><code>java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.117.31; nested exception is: 
      java.net.ConnectException: Connection refused: connect]
      at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:357)
      at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:267)
      at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:226)
      at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:354)
      at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:314)
      at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:295)
  Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.117.31; nested exception is: 
      java.net.ConnectException: Connection refused: connect]
      at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:118)
      at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:203)
      at javax.naming.InitialContext.lookup(InitialContext.java:411)
      at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1924)
      at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1891)
      at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:274)
      ... 5 more
  Caused by: java.rmi.ConnectException: Connection refused to host: 192.168.117.31; nested exception is: 
      java.net.ConnectException: Connection refused: connect
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
      at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:340)
      at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
      at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:114)
      ... 10 more
  Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.DualStackPlainSocketImpl.connect0(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
      at java.net.Socket.connect(Socket.java:579)
      at java.net.Socket.connect(Socket.java:528)
      at java.net.Socket.&lt;init&gt;(Socket.java:425)
      at java.net.Socket.&lt;init&gt;(Socket.java:208)
      at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
      at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146)
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
      ... 15 more
  </code></pre>
  
  <p>I left the activeMQ part in startup.bat and I still can connect to it. I really don't know where is the problem... If someone can help me</p>