开发者

Connect to a Tomcat server on the same subnet with Java JMX

开发者 https://www.devze.com 2023-03-13 20:36 出处:网络
I have a problem with my Tomcat JMX connection. I have two hosts (i.e host1.mydomain.com, host2.mydomain.com) which are attached to the same subnet. On both of these machines the JmxRemoteLifecycleLis

I have a problem with my Tomcat JMX connection. I have two hosts (i.e host1.mydomain.com, host2.mydomain.com) which are attached to the same subnet. On both of these machines the JmxRemoteLifecycleListener running

<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="10010" rmiServerPortPlatform="10011"/>

As a user I want to communicate with Tomcat via Java JMX. From outside I can connect successfully and see attributes correctly. The URL I connect with is:

service:jmx:rmi://host1.mydomain.com:10011/jndi/rmi://host1.mydomain.com:10010/jmxrmi

But if I want to connect from one host to the Tomcat on the other host via jmx (service:jmx:rmi://host2:10011/jndi/rmi://host2:10010/jmxrmi) it doesnt work. I got a connection timed out:

java.rmi.ConnectException: Connection refused to host: ip-adress from host1; nested exception is:
    java.net.ConnectException: Connection timed out
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
    at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
    at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2327)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:279)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
    at com.myjmx.jmxtest.montor.Monitor.getInformation(Monitor.java:52)
    at com.myjmx.jmxtest.Start.main(Start.java:39)
Caused by: java.net.ConnectException: Connection timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
    at java.net.So开发者_如何学PythoncksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at java.net.Socket.<init>(Socket.java:375)
    at java.net.Socket.<init>(Socket.java:189)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
    ... 9 more

On line 52 in Monitor.java is the JMXConnector:

JMXConnector connector = JMXConnectorFactory.connect(url, environment);

Other ports like service:jmx:rmi:///jndi/rmi://host1:9008/jmxrmi work correctly. But I cant connect to the port 10010 (the Tomcat port) with this shorter URL above service:jmx:rmi:///jndi/rmi://host1:10010/jmxrmi

Also there is probe running on the Tomcat.

I dont know what could be the reason. I think it is a problem by Tomcat, that the port is disabled in the same subnet or something like this. But I dont know how to enable the port.

Does anyone have a solution or the same problem?

Edit:

The Tomcat is configured like in this thread: Tomcat 6, JMX and the dynamic port problem

Update: I think I have found the reason for the problem. There are two NIC's installed on the server. But I can only activate one NIC for the JMX of the Tomcat. Is there a way to activate both NIC? So I can connect from outside and from inner? I dont know maybe with the help of different ports? So the -Djava.rmi.server.hostname=$IP is running on the normal port and the java.rmi.server.useLocalHostname is runninng on 3333 for example.

Thanks

spinner0815

0

精彩评论

暂无评论...
验证码 换一张
取 消