maven-build-cache-extension icon indicating copy to clipboard operation
maven-build-cache-extension copied to clipboard

Unable to save to remote cache with an IOException "Is a directory"

Open juliojgd opened this issue 6 months ago • 6 comments

Affected version

1.2.0

Bug description

We are observing several stacktraces like this one:

[INFO] Unable to save to remote cache https://mycompany.jfrog.io/artifactory/build-cache-maven/v1.1/com.mycompany.myapplication/my-application-plugin/212345678909325087e5a322c792aa5b6c7b2c9a66002d1a4df26458e9e8a26f/my-application-plugin.jar
java.io.IOException: Is a directory
    at sun.nio.ch.FileDispatcherImpl.read0 (Native Method)
    at sun.nio.ch.FileDispatcherImpl.read (FileDispatcherImpl.java:48)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer (IOUtil.java:330)
    at sun.nio.ch.IOUtil.read (IOUtil.java:296)
    at sun.nio.ch.IOUtil.read (IOUtil.java:273)
    at sun.nio.ch.FileChannelImpl.read (FileChannelImpl.java:232)
    at sun.nio.ch.ChannelInputStream.read (ChannelInputStream.java:65)
    at sun.nio.ch.ChannelInputStream.read (ChannelInputStream.java:107)
    at sun.nio.ch.ChannelInputStream.read (ChannelInputStream.java:101)
    at java.io.InputStream.read (InputStream.java:218)
    at org.eclipse.aether.spi.connector.transport.AbstractTransporter.copy (AbstractTransporter.java:164)
    at org.eclipse.aether.spi.connector.transport.AbstractTransporter.utilPut (AbstractTransporter.java:134)
    at org.eclipse.aether.transport.http.HttpTransporter.access$400 (HttpTransporter.java:101)
    at org.eclipse.aether.transport.http.HttpTransporter$PutTaskEntity.writeTo (HttpTransporter.java:689)
    at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity (DefaultBHttpClientConnection.java:156)
    at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity (CPoolProxy.java:152)
    at org.apache.http.protocol.HttpRequestExecutor.doSendRequest (HttpRequestExecutor.java:238)
    at org.apache.http.protocol.HttpRequestExecutor.execute (HttpRequestExecutor.java:123)
    at org.apache.http.impl.execchain.MainClientExec.execute (MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute (ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute (RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute (RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute (InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:72)
    at org.eclipse.aether.transport.http.HttpTransporter.execute (HttpTransporter.java:441)
    at org.eclipse.aether.transport.http.HttpTransporter.implPut (HttpTransporter.java:425)
    at org.eclipse.aether.spi.connector.transport.AbstractTransporter.put (AbstractTransporter.java:107)
    at org.apache.maven.buildcache.RemoteCacheRepositoryImpl.putToRemoteCache (RemoteCacheRepositoryImpl.java:250)
    at org.apache.maven.buildcache.RemoteCacheRepositoryImpl.saveArtifactFile (RemoteCacheRepositoryImpl.java:142)
    at org.apache.maven.buildcache.LocalCacheRepositoryImpl.saveArtifactFile (LocalCacheRepositoryImpl.java:359)
    at org.apache.maven.buildcache.CacheControllerImpl.save (CacheControllerImpl.java:534)
    at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute (BuildCacheMojosExecutionStrategy.java:160)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:840)

Our maven build cache configuration seems to work OK but this stackttrace is printed several times in the build.

Is it expected?

juliojgd avatar Jun 25 '25 15:06 juliojgd

Not expected but It looks your remote storage is returning a directory while a file is expected. I can't tell how your remote artifactory works or is configured but this need to be a raw http server not a maven repository.

https://mycompany.jfrog.io/artifactory/build-cache-maven/v1.1/com.mycompany.myapplication/my-application-plugin/212345678909325087e5a322c792aa5b6c7b2c9a66002d1a4df26458e9e8a26f/my-application-plugin.jar

olamy avatar Jun 27 '25 00:06 olamy

Not expected but It looks your remote storage is returning a directory while a file is expected. I can't tell how your remote artifactory works or is configured but this need to be a raw http server not a maven repository.

https://mycompany.jfrog.io/artifactory/build-cache-maven/v1.1/com.mycompany.myapplication/my-application-plugin/212345678909325087e5a322c792aa5b6c7b2c9a66002d1a4df26458e9e8a26f/my-application-plugin.jar

Thanks for your answer @olamy , we are testing by changing to a raw http server to validate if the error log disappears. We'll post here this test result.

Thanks again

juliojgd avatar Jul 02 '25 19:07 juliojgd

@juliojgd do you have some good news?

olamy avatar Jul 14 '25 07:07 olamy

We are testing it right now. I hope in the coming days I can report the result

juliojgd avatar Jul 16 '25 15:07 juliojgd

Result of our tests:

Test 1:

  • repo: test-build-cache-maven, type: maven, layout: maven-1-default
  • Result: the error appears

Test 2:

  • repo: test-build-cache-maven, type: maven, layout: simple-default
  • Result: the error appears

Test 3:

  • repo: test-build-cache-maven2, type: GENERIC, layout: simple-default
  • Result: the error appears

It seems that the error appears in every type of repository we've tested, but we observed that it happens only in several module that we have this configuration in them:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>default-jar</id>
            <phase>none</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <configuration>
          <skipSource>true</skipSource>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

IDK if the behavior is correct but if it is, maybe the log message should be clearer as it seems the problem is not merely a directory not existing but that the module simply is not going to be deployed, right?

juliojgd avatar Jul 17 '25 11:07 juliojgd

TBH I have no idea what is Artifactory configuration repo: test-build-cache-maven2, type: GENERIC, layout: simple-default :) But I have no issue using Nexus with a raw repository or a simple WebDAV server. It looks like we need to test with Artifactory.

olamy avatar Jul 20 '25 02:07 olamy