Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9257

Could not create Groovysh with JDK 11 and Spring-Boot

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.8
    • 2.5.9, 3.0.0-rc-2
    • Groovysh
    • None
    • openjdk version "11.0.1" 2018-10-16
      OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

      macOS 10.14.4

    Description

      Can't create instance of class org.codehaus.groovy.tools.shell.Groovysh from the application created  with SpringBoot (self contained jar) 

      Exception:

       

      Exception in thread "main" java.lang.reflect.InvocationTargetExceptionException in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)Caused by: java.nio.file.NoSuchFileException: file:/Users/olegkotov/work/ctr/backend/ctr-test/target/gshell-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/groovy-2.5.8.jar at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55) at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:145) at java.base/java.nio.file.Files.readAttributes(Files.java:1763) at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1222) at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:726) at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:843) at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:246) at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:176) at java.base/java.util.jar.JarFile.<init>(JarFile.java:346) at java.base/java.util.jar.JarFile.<init>(JarFile.java:317) at java.base/java.util.jar.JarFile.<init>(JarFile.java:283) at org.codehaus.groovy.tools.shell.util.PackageHelperImpl.getPackageNames(PackageHelperImpl.groovy:254) at org.codehaus.groovy.tools.shell.util.PackageHelperImpl.getPackages(PackageHelperImpl.groovy:115) at org.codehaus.groovy.tools.shell.util.PackageHelperImpl.initializePackages(PackageHelperImpl.groovy:59) at org.codehaus.groovy.tools.shell.util.PackageHelperImpl.<init>(PackageHelperImpl.groovy:49) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:237) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:249) at org.codehaus.groovy.tools.shell.Groovysh.<init>(Groovysh.groovy:112) at org.codehaus.groovy.tools.shell.Groovysh.<init>(Groovysh.groovy:101) at org.codehaus.groovy.tools.shell.Groovysh.<init>(Groovysh.groovy:97) at org.codehaus.groovy.tools.shell.Groovysh.<init>(Groovysh.groovy:128) at org.codehaus.groovy.tools.shell.Groovysh.<init>(Groovysh.groovy:132) at org.codehaus.groovy.tools.shell.Groovysh.<init>(Groovysh.groovy:136) at org.codehaus.groovy.tools.shell.Groovysh.<init>(Groovysh.groovy:144) at com.farpost.test.Main.main(Main.java:25) ... 8 more
      

       

      Code to reproduce error:

       

      package test;
      
      import org.codehaus.groovy.tools.shell.Groovysh;
      import org.springframework.boot.autoconfigure.SpringBootApplication;
      
      import java.io.IOException;
      
      @SpringBootApplication
      public class Main {
      
       public static void main(String[] args) throws IOException {
         Groovysh groovysh = new Groovysh();
       }
      }
       
      

       

      The error cause:

      PackageHelperImpl.getPackageNames tries to get packages from the jar inside self-contained application jar by means java.util.zip.ZipFile. Java 8 zip file API throws FileNotFoundException which was handled in PackageHelperImpl. The new Java 11 ZipFile API throws NoSuchFileException in case file is not found on filesystem. That exception is not handled in code.

       

       

      Attachments

        1. maven-spring-boot.zip
          4 kB
          Eric Milles

        Issue Links

          Activity

            People

              emilles Eric Milles
              koleg Oleg
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h