glassfish-hk2 icon indicating copy to clipboard operation
glassfish-hk2 copied to clipboard

Could not delete existing inhabitant file

Open glassfishrobot opened this issue 7 years ago • 1 comments

Cloned glassfish this week and ran into the following error during mvn install

HK2 configuration module - FAILURE hk2-inhabitant-generator:2.5.0-b57:generate-inhabitants Could not delete existing inhabitant file C:\GitRepository\glassfish5\nucleus\hk2\hk2-config\target\class\META-INF\hk2-locator\default in the noSwap case

I had successfully executed "mvn install" (against glassfish) a few weeks prior; not sure what changed to have caused this error to surface.

Something screwy with the Java being unable to File.delete() within hk2-inhabitant-generator ... Creating a local version of hk2-inhabitant-generator which doesn't throw the IOException allows maven to limp along.

org.jvnet.hk2.generator.internal.GeneratorRunner.writeToDirectory()

            File noSwapFile = null;
            boolean directWrite = false;
            if (noSwap || !outputFile.exists()) {
                directWrite = true;
                if (outputFile.exists()) {
                    if (!outputFile.delete()) {
                        // swallow the error to allow maven to limp along
                        // throw new IOException("Could not delete existing inhabitant file " +
                        //        outputFile.getAbsolutePath() + " in the noSwap case");
                    	System.out.println("Could not delete existing inhabitant file " +
                                        outputFile.getAbsolutePath() + " in the noSwap case");
                    }
                }

Fails on both swap/noswap variant.

There have been prior Issues (i.e dc33a5f, 8b04e7b) related to Windows holding a lock on the File, and Java not being able to successfully delete()... typically resolved by judicious use of close(). Have seen other cases (at work) where delete() works fine on Linux but not Windows.

It seems like hk2-inhabitant-generator has already been fixed to work on Windows. Anyone know why I am now experiencing the issue?

glassfishrobot avatar Jan 20 '18 23:01 glassfishrobot

  • Issue Imported From: https://github.com/javaee/hk2/issues/378
  • Original Issue Raised By:@jimyikes
  • Original Issue Assigned To: Unassigned

glassfishrobot avatar Aug 30 '18 10:08 glassfishrobot