[
https://issues.apache.org/jira/browse/GROOVY-9257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16964192#comment-16964192
]
Eric Milles commented on GROOVY-9257:
-------------------------------------
[^maven-spring-boot.zip]
This should be enough to recreate the issue. Execute "mvn package" from the
root dir, then "java -jar target/maven-spring-boot-0.0.1-SNAPSHOT.jar". If
java is 8, it runs fine. If java is 9+, there is a ZipFile exception as in
description. I am unable to continue because Windows is having a problem with
the ":" in the file path. {{java.nio.file.InvalidPathException: Illegal char
<:> at index 4:
file:\C:\Users\name\workspace\maven-spring-boot\target\maven-spring-boot-0.0.1-SNAPSHOT.jar!\BOOT-INF
\lib\groovy-2.5.8.jar}}
> Could not create Groovysh with JDK 11 and Spring-Boot
> -----------------------------------------------------
>
> Key: GROOVY-9257
> URL: https://issues.apache.org/jira/browse/GROOVY-9257
> Project: Groovy
> Issue Type: Bug
> Components: Groovysh
> Affects Versions: 2.5.8
> Environment: 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
> Reporter: Oleg
> Priority: Major
> Attachments: maven-spring-boot.zip
>
>
> Can't create instance of class org.codehaus.groovy.tools.shell.Groovysh from
> the application created with SpringBoot (self contained jar)
> Exception:
>
> {code:java}
> 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}
>
> h3. Code to reproduce error:
>
> {code:java}
> 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();
> }
> }
>
> {code}
>
> h3. 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.
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)