• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Connection Refused exception upon reading/parsing a shortcut file present in network drive

Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here mart.xml is a shortcut present in C:\Param\Bin on a windows box. I get the following IOException:

Exception in thread "main" java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:524)
at java.net.Socket.connect(Socket.java:474)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.NetworkClient.openServer(NetworkClient.java:118)
at sun.net.ftp.FtpClient.openServer(FtpClient.java:488)
at sun.net.ftp.FtpClient.openServer(FtpClient.java:475)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:270)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:352)
at JDOMElementTextContent.parseXml(JDOMElementTextContent.java:36)
at JDOMElementTextContent.main(JDOMElementTextContent.java:47)

I tried to open Stream from URL using file: protocol but URLConnection.getInputStream throws the same connection refused exception.

Any recommendations would be appreciated?
Posts: 3225
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Path provided in the File constructor is not correct. You can either specify an absolute path or specify a relative path.

Update: I assumed that the program and the file which it tries to access are on the same machine.

Wrong interpretation, didn't notice the Network Drive in the Subject Please dont consider this.
Posts: 22683
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have access to that share and file? Does the user running the JVM have access (in case that isn't you)?
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Garden Master Course kickstarter
    Bookmark Topic Watch Topic
  • New Topic