Search code examples
javajenkinsbuildartifactsjenkins-job-builder

Jenkins job failed with error java.lang.NoClassDefFoundError


We have scheduled a Jenkins Build to create AWS VM, VM is successfully online but while archiving the Artifacts, job got failed with below error message.

Archiving artifacts
ERROR: Step ‘Archive the artifacts’ aborted due to exception: 
java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.LinuxNativeDispatcher
    at sun.nio.fs.LinuxUserDefinedFileAttributeView.copyExtendedAttributes(LinuxUserDefinedFileAttributeView.java:291)
    at sun.nio.fs.LinuxFileSystem.copyNonPosixAttributes(LinuxFileSystem.java:72)
    at sun.nio.fs.UnixCopyFile.copyFile(UnixCopyFile.java:267)
    at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:581)
    at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)
    at java.nio.file.Files.copy(Files.java:1274)
    at hudson.FilePath$31$1.visit(FilePath.java:2296)
    at hudson.util.DirScanner.scanSingle(DirScanner.java:44)
    at hudson.FilePath$ExplicitlySpecifiedDirScanner.scan(FilePath.java:2991)
    at hudson.FilePath$31.invoke(FilePath.java:2290)
    at hudson.FilePath$31.invoke(FilePath.java:2283)
    at hudson.FilePath.act(FilePath.java:1042)
    at hudson.FilePath.act(FilePath.java:1025)
    at hudson.FilePath.copyRecursiveTo(FilePath.java:2283)
    at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61)
    at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:235)
    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1823)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)

What is causing this issue and how to resolve it?


Solution

  • I had the same problem in a Centos7 system and solved it installing a new jdk and setting the default jdk with /usr/sbin/alternatives --config java

    After that, restart Jenkins and that's all