netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

UNC paths are not supported. Defaulting to Windows directory

Open mitkola opened this issue 6 months ago • 11 comments

Apache NetBeans version

Apache NetBeans 26

What happened

After upgrading from Netbeans 24 to Netbeans 26 my Maven project located on mapped network drive stopped to build. The reason is that network mapped drive is always referred by UNC Path. As result starting build of project reports "UNC paths are not supported. Defaulting to Windows directory." After trying to change directory to UNC path instead of mapped drive path. cd \server\path to project instead of X:\path to project

I have tried different options to disable UNC path converting as -J-Duse.unc.paths=false -J-Duse.mapped.drives=true but without success.

Language / Project Type / NetBeans Component

No response

How to reproduce

  1. The problem exists in Windows 11 environment.
  2. Create Simple Maven project on SMB (Windows share) mapped network drive x:\path\to\project.
  3. Save project and exit from Netbeans.
  4. Start netbeans again. After reopen project, the path is converted to UNC \server\path\to\project.
  5. The project can't be build.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 11

JDK

JDK 24

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

mitkola avatar Jun 23 '25 09:06 mitkola

Could you elaborate on the following:

  • Is the UNC \server\path\to\project or \\server\path\to\project, in particular the number of back-slash (\) characters at the beginning.
  • Is it possible to start maven on the command line on your machine. If so, open the directory of the project (both in the drive mapped and the server mapped version) and try mvn validate followed by mvn compile and report on the results.

The way NetBeans uses maven is by building a command line from the properties and location of several parts, such as maven itself, the location of your configured JDK and the working directory. You can find that command line in the output window, at the top, directly after you started the maven command (in NetBeans). Something like

cd /home/hom/jristretto/recordswithbenefits; JAVA_HOME=/usr/lib/jvm/jdk-21.0.7+6 M2_HOME=/usr/share/apache-maven-3.9.9 /usr/share/apache-maven-3.9.9/bin/mvn test

Note that I am on a Linux machine, but the concept is similar. In the command line that is used, the first step is to move to the working directory.: cd /home/hom/jristretto/recordswithbenefits;

Yours should contain something similar.

homberghp avatar Jun 23 '25 11:06 homberghp

For a stack overflow search it looks as if the message is generated by Windows itself or the command line processor (cmd) . Look at https://stackoverflow.com/questions/56257565/unc-paths-are-not-supported/56258149

Also prepping in the netbeans sources or in my maven does not produce a file with the text 'UNC paths are not supported'.

That leaves the point that the project appears to be modified, as you say, after closing and re-opening it. So there might still be something going on in NetBeans.

homberghp avatar Jun 23 '25 11:06 homberghp

I can successfully to compile from command-line, but not in IDE.

I will try to explain in short descriptive way.

I'm opening project from mapped drive, but after open mapped drive is transformed to UNC path.

Image

Image

When start build the following result is in Output window.

Image

mitkola avatar Jun 23 '25 12:06 mitkola

"unc paths are not supported" wondering where that message is coming from. That string is not in the NB repo.

found something similar though: https://github.com/apache/netbeans/blob/68e420dcd08d0e1a3bb7fc1687dd0722881e9422/java/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java#L120

which might indicate that this was never supported.

Are you using the same maven + java version in both cases? Might be worth to check on NB 25 too.

mbien avatar Jun 23 '25 12:06 mbien

There's also a recent unanswered discussion post that relates to this at #8498

neilcsmith-net avatar Jun 23 '25 13:06 neilcsmith-net

This might be https://bugs.openjdk.org/browse/JDK-8355342 ??

neilcsmith-net avatar Jun 23 '25 13:06 neilcsmith-net

A 'quick' fix for the reporters might be to use JDK 21, which is the current LTS, so that might be satisfactory, and usable as a workaround. @PeppoDX, @mitkola.

homberghp avatar Jun 23 '25 13:06 homberghp

that JDK bug would affect JDK 24 which is used in the netbeans windows bundle and is therefore used for everything by default.

You could try to download latest JDK 21, then change the project properties to switch to it.

If it still happens, try starting NB itself on JDK 21. For that, change the netbeans shortcut properties by editing the path behind -jdkhome and let it point to JDK 21.

mbien avatar Jun 23 '25 14:06 mbien

A 'quick' fix for the reporters might be to use JDK 21, which is the current LTS, so that might be satisfactory, and usable as a workaround. @PeppoDX, @mitkola.

I've changed Netbeans to use JDK 21 and problem was fixed. Thank you!

mitkola avatar Jun 23 '25 14:06 mitkola

Thanks for the confirmation it's working on JDK 21.

We should keep an eye on that bug, and also that it reports that "this behavior can be avoided by using the more modern Path.toRealPath instead of File.getCanonicalPath -- which does not expand to UNC paths" should it remain and we need to find a workaround instead. Sticking a milestone on this to help with tracking and assessment in the release process.

neilcsmith-net avatar Jun 23 '25 14:06 neilcsmith-net

Hi,

I changed NetBeans IDE 26 to JDK 21, and the error persists.

Image Image

I even adjusted the conf so that NetBeans should use jdk21 by default.

Image

Do you have any tips on what else I can do?

Thiwico avatar Sep 22 '25 09:09 Thiwico