0

I have basically the same problem explained here: Keep getting java.net.UnknownHostException after connecting to the internet

The problem is following, when my java application starts without Internet connection, it will forever continue throwing UnknownHostException, even in the casse when Internet connection is established.

The stack trace is quite huge:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://www.taxifcd.de/DebugWirelessDataWebService/wdws?wsdl. It failed with: 
www.taxifcd.de.
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:250)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:231)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:194)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:163)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:348)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:306)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:215)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:196)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:192)
    at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
    at javax.xml.ws.Service.<init>(Service.java:77)
    at de.dlr.ts.wirelessdata.ws.client.WirelessDataWebServiceImplService.<init>(WirelessDataWebServiceImplService.java:42)
    at de.dlr.ts.wirelessdata.ws.client.WirelessDataWebServiceClient.<init>(WirelessDataWebServiceClient.java:62)
    at de.dlr.dynamic.client.core.impl.bam.BAMImpl$PacketSender.init(BAMImpl.java:500)
    at de.dlr.dynamic.client.core.impl.bam.BAMImpl$PacketSender.run(BAMImpl.java:534)
Caused by: java.net.UnknownHostException: www.taxifcd.de
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    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 sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.http.HttpClient.New(HttpClient.java:326)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1169)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:933)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
    at java.net.URL.openStream(URL.java:1045)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:984)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:385)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:216)
... 13 more

If I run program with Internet connection and after some time disconnect and connect it works good. I tried also with changing caching parameters of the network like this:

java.security.Security.setProperty("networkaddress.cache.ttl" , "0");
java.security.Security.setProperty("networkaddress.cache.negative.ttl" , "0");

But that also didn't help. Any idea how to solve this? It is obvious to me that the problem is in Java not recognizing the change on the network.

Community
  • 1
  • 1
Nexy_sm
  • 211
  • 2
  • 9
  • If you set those properties at the initial launch of your JVM, then the problem is likely the OS DNS caching behavior. What OS are you using? Also, have you thoroughly studied the top links in the Google search for "java caching dns resolution"? There's a lot of info there and some of it may be applicable or contain a solution. – Jim Garrison Jul 14 '16 at 17:36
  • I tried all suggested solutions from the websites that I have found. Some suggests no caching, some suggest smal interval, 5 seconds or so, but nothing helped. I use RHEL6. – Nexy_sm Jul 15 '16 at 09:42
  • When the Java program is failing, what happens if you use the dig command to do the same lookup? – Jim Garrison Jul 15 '16 at 15:26
  • pinging for example www.google.com from terminal works, it is only that Java program can;t get through. Something like Java cached network options at the begining of the code and doesnt check that although I tried different values for networkaddress.cache.ttl and networkaddress.cache.negative.ttl. Who is responsible to update Java's information about state of the network, and why would java cache something like that, it could simply try by doing system call or whatever? – Nexy_sm Jul 17 '16 at 17:17
  • This was solution for me: http://stackoverflow.com/questions/38453462/how-to-check-if-propery-exists-in-java – Nexy_sm Jul 20 '16 at 10:58
  • Unfortunately that page is not available – Nikolay Klimchuk Aug 21 '17 at 23:57

0 Answers0