[ 
https://issues.apache.org/jira/browse/KARAF-5084?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15961400#comment-15961400
 ] 

Michael Vorburger commented on KARAF-5084:
------------------------------------------

http://blog2.vorburger.ch/2017/04/java-local-rmi-using-jdks-inetaddress.html 
describes more background about what's going on here.

It turns out that I slightly confused two things: There are two strictly 
speaking separate problems in the log above - the first exception, from 
org.apache.karaf.management.ConnectorServerFactory, is a actually not directly 
impacting Pax Exam - it just means that Karaf Management JMX server hits a 
similar issue. Unless you need to use JMX, that is not a problem at least for 
running tests. The second exception is 
https://ops4j1.jira.com/browse/PAXEXAM-740,  and fixing that required no 
changes in Karaf, just in Pax Exam, after all.

I'll close this issue as my interest was to get PAXEXAM-740 resolved. If 
someone else is bothered by the NoRouteToHostException from Karaf JMX, then 
feel free to re-open. The big difference though is that one may WANT the Karaf 
JMX RMI server to be accessible on non-loopback network interfaces too, for 
remote monitoring & administration; contrary to Pax Exam's RMI which is always 
strictly local. So e.g. programmatically in Karaf code forcing 
System.setProperty("java.rmi.server.hostname", 
InetAddress.getLoopbackAddress().getHostAddress()) is most probably Not a Good 
Idea... you may want to simply set java.rmi.server.hostname to a "suitable" 
hostname for your system in your Karaf start-up script?

> Use of LocateRegistry in RmiRegistryFactory problematic due to 
> InetAddress.getLocalHost().getHostAddress()
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: KARAF-5084
>                 URL: https://issues.apache.org/jira/browse/KARAF-5084
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-management
>    Affects Versions: 4.1.1
>            Reporter: Michael Vorburger
>
> I'm hitting this error e.g. from the 
> KarafTestContainerITest.checkKarafSystemService in the 
> org.ops4j.pax.exam2/containers/pax-exam-container-karaf :
> {code}Exception in thread "JMX Connector Thread 
> [service:jmx:rmi://0.0.0.0:44444/jndi/rmi://0.0.0.0:1099/karaf-root]" 
> java.lang.RuntimeException: Could not start JMX connector server
>       at 
> org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:258)
> Caused by: java.io.IOException: Cannot bind to URL 
> [rmi://0.0.0.0:1099/karaf-root]: javax.naming.CommunicationException [Root 
> exception is java.rmi.ConnectIOException: Exception creating connection to: 
> 0.0.0.0; nested exception is: 
>       java.net.NoRouteToHostException: No route to host (Host unreachable)]
>       at 
> javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:827)
>       at 
> javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:432)
>       at 
> org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:245)
> Caused by: javax.naming.CommunicationException [Root exception is 
> java.rmi.ConnectIOException: Exception creating connection to: 0.0.0.0; 
> nested exception is: 
>       java.net.NoRouteToHostException: No route to host (Host unreachable)]
>       at 
> com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:161)
>       at 
> com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:228)
>       at javax.naming.InitialContext.bind(InitialContext.java:425)
>       at 
> javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:644)
>       at 
> javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:427)
>       ... 1 more
> Caused by: java.rmi.ConnectIOException: Exception creating connection to: 
> 0.0.0.0; nested exception is: 
>       java.net.NoRouteToHostException: No route to host (Host unreachable)
>       at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:631)
>       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:342)
>       at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
>       at 
> com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:155)
>       ... 5 more
> Caused by: java.net.NoRouteToHostException: No route to host (Host 
> unreachable)
>       at java.net.PlainSocketImpl.socketConnect(Native Method)
>       at 
> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
>       at 
> java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:204)
>       at 
> java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
>       at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
>       at java.net.Socket.connect(Socket.java:589)
>       at java.net.Socket.connect(Socket.java:538)
>       at java.net.Socket.<init>(Socket.java:434)
>       at java.net.Socket.<init>(Socket.java:211)
>       at 
> sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
>       at 
> sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
>       at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
>       ... 10 more
> 02:33:50.966 [main] INFO  o.o.p.e.spi.reactors.ReactorManager - suite finished
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 182.081 sec 
> <<< FAILURE! - in org.ops4j.pax.exam.karaf.container.KarafTestContainerITest
> checkKarafSystemService(org.ops4j.pax.exam.karaf.container.KarafTestContainerITest)
>   Time elapsed: 182.074 sec  <<< ERROR!
> java.net.NoRouteToHostException: No route to host (Host unreachable)
>       at java.net.PlainSocketImpl.socketConnect(Native Method)
>       at 
> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
>       at 
> java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
>       at 
> java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
>       at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
>       at java.net.Socket.connect(Socket.java:589)
>       at java.net.Socket.connect(Socket.java:538)
>       at java.net.Socket.<init>(Socket.java:434)
>       at java.net.Socket.<init>(Socket.java:211)
>       at 
> sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
>       at 
> sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
>       at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
>       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:342)
>       at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
>       at 
> org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.getRemoteBundleContext(RemoteBundleContextClientImpl.java:242)
>       at 
> org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.waitForState(RemoteBundleContextClientImpl.java:211)
>       at 
> org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.waitForState(KarafTestContainer.java:606)
>       at 
> org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.startKaraf(KarafTestContainer.java:240)
>       at 
> org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.start(KarafTestContainer.java:180)
>       at 
> org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:79)
>       at 
> org.ops4j.pax.exam.junit.impl.ProbeRunner$2.evaluate(ProbeRunner.java:267)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:98)
>       at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103){code}
> This is related to the (apparently) problematic use of 
> InetAddress.getLocalHost().getHostName() in 
> java.rmi.registry.LocateRegistry#getRegistry called by 
> org.apache.karaf.management.RmiRegistryFactory; see also:
> * https://bugs.opendaylight.org/show_bug.cgi?id=8176
> * https://issues.apache.org/jira/browse/JCS-40
> * http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4665037
> * https://ops4j1.jira.com/browse/PAXEXAM-740
> * https://docs.oracle.com/javase/8/docs/technotes/guides/rmi/faq.html
> I'll see if I can do something about contributing a fix for this...



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to