You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "metatech (Updated) (JIRA)" <ji...@apache.org> on 2012/01/04 17:17:39 UTC

[jira] [Updated] (KARAF-1138) Hostname should be explicitly configured for RMI/JMX connections to work remotely with DHCP addresses

     [ https://issues.apache.org/jira/browse/KARAF-1138?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

metatech updated KARAF-1138:
----------------------------

    Description: 
JVM RMI logic to auto-guess its own IP address does not work well with default hostname settings (IP obtained via DHCP, but defined in /etc/hosts as "localhost") on Linux. When trying to call JMX remotely from a different machine, the caller receives "127.0.0.1" as server address, with the error below.
A workaround is to define the system property "java.rmi.server.hostname" to the real hostname.

This can be easily automated by adding in the script bin/karaf the following lines :
{code}
    IP_LOOKUP=`getent hosts \`hostname\` | wc -l`
    if [ $IP_LOOKUP -eq 0 ]; then
        JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=`hostname`"
    fi
{code}

Another solution is to define manually the property in $KARAF_HOME/etc/system.properties.

A third possibility is to extend the hinted solution in ActiveMQCommandSupport.java

{code}
smx@root> activemq:list --jmxurl service:jmx:rmi:///jndi/rmi://172.16.159.1:1099/karaf-root --jmxuser smx --jmxpassword smx
ERROR: java.lang.RuntimeException: Failed to execute list task. Reason: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
	java.net.ConnectException: Connection refused
java.lang.RuntimeException: Failed to execute list task. Reason: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
	java.net.ConnectException: Connection refused
	at org.apache.activemq.console.command.ListCommand.runTask(ListCommand.java:53)
	at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
	at org.apache.activemq.console.command.AbstractJmxCommand.execute(AbstractJmxCommand.java:316)
	at org.apache.activemq.karaf.commands.ActiveMQCommandSupport.doExecute(ActiveMQCommandSupport.java:46)
	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
	at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
	at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
	at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
	at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
	at org.apache.karaf.shell.console.jline.Console.run(Console.java:170)
	at java.lang.Thread.run(Thread.java:662)

Could not connect to JMX server.  This command requires that the remote JMX server be enabled.
This is typically done by adding the following JVM arguments: 
   -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false 
   -Dcom.sun.management.jmxremote.ssl=false 

The connection error was: java.net.ConnectException: Connection refused
{code}

http://forum.springsource.org/showthread.php?64670-Why-do-I-need-to-define-java-rmi-server-hostname&s=cd088bea049ead95d2cb3ff186babaef&p=219304#post219304


  was:
JVM RMI logic to auto-guess its own IP address does not work well with default hostname settings (IP obtained via DHCP, but defined in /etc/hosts as "localhost") on Linux. When trying to call JMX remotely from a different machine, the caller receives "127.0.0.1" as server address, with the error below.
A workaround is to define the system property "java.rmi.server.hostname" to the real hostname.

This can be easily automated by adding in the script bin/karaf the following lines :
    IP_LOOKUP=`getent hosts \`hostname\` | wc -l`
    if [ $IP_LOOKUP -eq 0 ]; then
        JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=`hostname`"
    fi

Another solution is to define manually the property in $KARAF_HOME/etc/system.properties.

A third possibility is to extend the hinted solution in ActiveMQCommandSupport.java

{code}
smx@root> activemq:list --jmxurl service:jmx:rmi:///jndi/rmi://172.16.159.1:1099/karaf-root --jmxuser smx --jmxpassword smx
ERROR: java.lang.RuntimeException: Failed to execute list task. Reason: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
	java.net.ConnectException: Connection refused
java.lang.RuntimeException: Failed to execute list task. Reason: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
	java.net.ConnectException: Connection refused
	at org.apache.activemq.console.command.ListCommand.runTask(ListCommand.java:53)
	at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
	at org.apache.activemq.console.command.AbstractJmxCommand.execute(AbstractJmxCommand.java:316)
	at org.apache.activemq.karaf.commands.ActiveMQCommandSupport.doExecute(ActiveMQCommandSupport.java:46)
	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
	at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
	at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
	at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
	at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
	at org.apache.karaf.shell.console.jline.Console.run(Console.java:170)
	at java.lang.Thread.run(Thread.java:662)

Could not connect to JMX server.  This command requires that the remote JMX server be enabled.
This is typically done by adding the following JVM arguments: 
   -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false 
   -Dcom.sun.management.jmxremote.ssl=false 

The connection error was: java.net.ConnectException: Connection refused
{code}

http://forum.springsource.org/showthread.php?64670-Why-do-I-need-to-define-java-rmi-server-hostname&s=cd088bea049ead95d2cb3ff186babaef&p=219304#post219304


    
> Hostname should be explicitly configured for RMI/JMX connections to work remotely with DHCP addresses
> -----------------------------------------------------------------------------------------------------
>
>                 Key: KARAF-1138
>                 URL: https://issues.apache.org/jira/browse/KARAF-1138
>             Project: Karaf
>          Issue Type: Improvement
>         Environment: ServiceMix 4.3
>            Reporter: metatech
>            Priority: Minor
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> JVM RMI logic to auto-guess its own IP address does not work well with default hostname settings (IP obtained via DHCP, but defined in /etc/hosts as "localhost") on Linux. When trying to call JMX remotely from a different machine, the caller receives "127.0.0.1" as server address, with the error below.
> A workaround is to define the system property "java.rmi.server.hostname" to the real hostname.
> This can be easily automated by adding in the script bin/karaf the following lines :
> {code}
>     IP_LOOKUP=`getent hosts \`hostname\` | wc -l`
>     if [ $IP_LOOKUP -eq 0 ]; then
>         JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=`hostname`"
>     fi
> {code}
> Another solution is to define manually the property in $KARAF_HOME/etc/system.properties.
> A third possibility is to extend the hinted solution in ActiveMQCommandSupport.java
> {code}
> smx@root> activemq:list --jmxurl service:jmx:rmi:///jndi/rmi://172.16.159.1:1099/karaf-root --jmxuser smx --jmxpassword smx
> ERROR: java.lang.RuntimeException: Failed to execute list task. Reason: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
> 	java.net.ConnectException: Connection refused
> java.lang.RuntimeException: Failed to execute list task. Reason: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
> 	java.net.ConnectException: Connection refused
> 	at org.apache.activemq.console.command.ListCommand.runTask(ListCommand.java:53)
> 	at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
> 	at org.apache.activemq.console.command.AbstractJmxCommand.execute(AbstractJmxCommand.java:316)
> 	at org.apache.activemq.karaf.commands.ActiveMQCommandSupport.doExecute(ActiveMQCommandSupport.java:46)
> 	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
> 	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
> 	at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
> 	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
> 	at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
> 	at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
> 	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
> 	at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
> 	at org.apache.karaf.shell.console.jline.Console.run(Console.java:170)
> 	at java.lang.Thread.run(Thread.java:662)
> Could not connect to JMX server.  This command requires that the remote JMX server be enabled.
> This is typically done by adding the following JVM arguments: 
>    -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false 
>    -Dcom.sun.management.jmxremote.ssl=false 
> The connection error was: java.net.ConnectException: Connection refused
> {code}
> http://forum.springsource.org/showthread.php?64670-Why-do-I-need-to-define-java-rmi-server-hostname&s=cd088bea049ead95d2cb3ff186babaef&p=219304#post219304

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira