2 Replies Latest reply on Nov 16, 2015 8:17 PM by joyousjavadev

    WFLYCTL0158: Operation handler failed: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile

    joyousjavadev Newbie

      Hello,

       

      This error... WFLYCTL0158: Operation handler failed: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile

       

      occurred when deploying (copy to /standalone/deployments) an ear file to OpenShift Wildfly 9 app server.  This .ear file was previously able to successfully deploy.

        • 1. Re: WFLYCTL0158: Operation handler failed: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile
          Jay SenSharma Master

          Looks like your application or some third party API present in your application needs access to class "" which is present inside the "$JAVA_HOME/jre/lib/rt.jar". However all the packages are not exported from the "sun.jdk" module hence by default the applications deployed on WildFly 9 will not be able to access that class.

           

          So try the following,

           

          Option-1) Edit the "wildfly-9.0.1.Final/modules/system/layers/base/sun/jdk/main/module.xml" file and then add the following line there <path name="sun/nio/fs" />  as highlighted below:

           

                          <path name="sun/io"/>
                          <path name="sun/nio"/>
                          <path name="sun/nio/ch"/>
                          <path name="sun/nio/cs"/>
                          <path name="sun/nio/fs" />   <!-- ADDED HERE MANUALLY -->
                          <path name="sun/nio/cs/ext"/>
          
          



          Option-2). Add the following kind of "jboss-deployment-structure.xml" file inside your EAR's "META-INF" directory:

           

          <?xml version="1.0"?>
          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <deployment>
              <dependencies>
                <system export="true">
                  <paths>
                    <path name="sun/nio/fs"/>   <!-- ADDED HERE MANUALLY -->
                  </paths>
                </system>
              </dependencies>
            </deployment>
          </jboss-deployment-structure>
          
          

           

           

           

          Additionally can you please post the complete stackTrace of the error which you were getting during deployment so that we can check which API was actually trying to access that class. Or what kind of operation requires that class access (just to check if WildFLy related APIs need it or your application specific APIs)

          • 2. Re: WFLYCTL0158: Operation handler failed: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile
            joyousjavadev Newbie

            Thank you for the response.  With Option 1, I was able to deploy the .ear to the OpenShift Wildfly 9 server. Please note that the issue was not reproducible locally on Win 10, Wildfly 9.01,  Oracle JDK 1.8.0

             

            It may be because OpenShift env is using...

             

            openjdk version "1.8.0_65"

            OpenJDK Runtime Environment (build 1.8.0_65-b17)

            OpenJDK Server VM (build 25.65-b01, mixed mode)

             

            A stacktrace was not found in the server.log. This error was reported in a *.ear.failed file

             

            {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "WFLYCTL0158: Operation handler failed: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.UnixCopyFile"}}

             

            It is possible that the dependency comes from the jasperreports (a module that I have created) lib or one of its transitive dependency.

             

            Thanks