Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkstyle-tester is not Java 11 compatible #352

Closed
Vampire opened this issue Mar 16, 2019 · 18 comments
Closed

checkstyle-tester is not Java 11 compatible #352

Vampire opened this issue Mar 16, 2019 · 18 comments

Comments

@Vampire
Copy link
Contributor

Vampire commented Mar 16, 2019

When launching the checkstyle tester with JAVA_HOME set to Java 11, it starts until it has built the base branch and then it aborts with this exception:

Caught: java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext
java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext
        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)
Caught: groovy.lang.GroovyRuntimeException: Error: !
groovy.lang.GroovyRuntimeException: Error: !
        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 diff.executeCmd(diff.groovy:342)
        at diff.executeCmd(diff.groovy:336)
        at diff$executeCmd$10.callCurrent(Unknown Source)
        at diff.generateCheckstyleReport(diff.groovy:186)
        at diff$generateCheckstyleReport$6.callCurrent(Unknown Source)
        at diff.run(diff.groovy:25)
        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)

javax.xml.bind.JAXBContext like all other JAXB stuff was removed from Java 11 in favor of using explicit dependencies.

@rnveach
Copy link
Member

rnveach commented Mar 16, 2019

@Vampire is that the full stack trace and error?
I am not seeing where jaxb is in our process for building the base. Checkstyle repo has a JDK11 travis build.
https://github.com/checkstyle/checkstyle/blob/master/.travis.yml#L210-L214

@Vampire
Copy link
Contributor Author

Vampire commented Mar 16, 2019

yes, it is the full stack trace
yes, it is the full error
as already mentioned above, it builds the base branch and then after that the exception comes
and as you can see from the stack trace above it is happening when calling executeCmd("""groovy launch.groovy --listOfProjects $cfg.listOfProjects --config $cfg.checkstyleCfg --ignoreExceptions --ignoreExcludes --checkstyleVersion $checkstyleVersion""")
I'm not sure what other information you need.

@rnveach
Copy link
Member

rnveach commented Mar 16, 2019

Just trying to determine where jaxb is located to see if it can be removed. I don't see it listed directly which means some plugin we are using in the POM must be calling it, unless somehow groovy is requesting it.

I will have to install Java 11 and see if I can find anything more.

@rnveach
Copy link
Member

rnveach commented Mar 16, 2019

I saw this when testing it out:

[INFO] --- maven-checkstyle-plugin:3.0.0:check (sevntu-checkstyle-check) @ checkstyle ---
Downloading: https://oss.sonatype.org/content/repositories/codehaus-snapshots/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.pom
Downloading: http://repo.maven.apache.org/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.pom

See https://github.com/apache/maven-checkstyle-plugin/blob/c4505ee038390f7f2ae90b441a0e0bbe963340d9/pom.xml#L433 .

The maven plugin is an integrate part of our regression until Issue #273 is completed. Our main repo assembly profile for Java 11 ignores any validation runs so that must be why it has gone unnoticed.

@rnveach
Copy link
Member

rnveach commented Mar 16, 2019

I cannot reproduce the error locally with windows and java 11.

> mvn -e --batch-mode site -X
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T12:37:52-05:00)
Maven home: C:\RickyPrograms\apache-maven-3.2.1\bin\..
Java version: 11.0.2, vendor: Oracle Corporation
Java home: C:\RickyPrograms\JDK11
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

Why do you think it has anything to do with maven-checkstyle or any maven run at all?
The downloading of the jaxb-api is probably fine, it contains the class that is missing and thus will probably work fine on Java 11.
Where it failed was some Groovy code.
"Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext"
Did you try to just set your JAVA_HOME to Java 11 and then call the diff.groovy?

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

It also depends on the Groovy version.
With 2.4.7 it runs through without error.
But as the documentation said at least Groovy 2.4.8 is needed, I installed and used the latest available stable version 2.5.6.
Using 2.5.6 the error happens.

@rnveach
Copy link
Member

rnveach commented Mar 17, 2019

Why do you think it has anything to do with maven-checkstyle or any maven run at all?

You say it starts until it has built the base branch and then it aborts. The only thing that happens after the base branch is created is launch.groovy is run and then maven-checkstyle is invoked after the projects are cloned. Nothing uses jaxb in our groovy process. Only reference to jaxb is in the maven-checkstyle.

at diff.executeCmd(diff.groovy:342)
at diff.executeCmd(diff.groovy:336)
at diff$executeCmd$10.callCurrent(Unknown Source)
at diff.generateCheckstyleReport(diff.groovy:186)

According to the stack trace, it only tells me the exception occurred when diff.groovy is calling launch.groovy.

Did you try to just set your JAVA_HOME to Java 11 and then call the diff.groovy?

Yes and I got no errors/exceptions.
Could this be related to your other issue where you had conflicts between 2 java versions?

Using 2.5.6 the error happens.

I am using the same version.

"Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext"

I saw this and just assumed groovy was trying to do something extra when it saw it had to load the jaxb class.

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

According to the stack trace, it only tells me the exception occurred when diff.groovy is calling launch.groovy.

Yes, and that instantly, no maven output or anything.

Could this be related to your other issue where you had conflicts between 2 java versions?

Nope, still failing when I use Java 11.

"Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext"

I saw this and just assumed groovy was trying to do something extra when it saw it had to load the jaxb class.

I added -d to the launch.groovy call, here the full stracktrace:

Caught: java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext
java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext
        at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:409)
        at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:280)
        at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:400)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.scanExtClasses(MacroMethodsCache.java:88)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.access$000(MacroMethodsCache.java:45)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache$2.onModule(MacroMethodsCache.java:69)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:87)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromMetaInf(ExtensionModuleScanner.java:81)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModulesFrom(ExtensionModuleScanner.java:63)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModules(ExtensionModuleScanner.java:54)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.getMacroMethodsFromClassLoader(MacroMethodsCache.java:76)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache$1.provide(MacroMethodsCache.java:53)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache$1.provide(MacroMethodsCache.java:50)
        at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
        at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:123)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.get(MacroMethodsCache.java:50)
        at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.findMacroMethods(MacroCallTransformingVisitor.java:117)
        at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.visitMethodCallExpression(MacroCallTransformingVisitor.java:88)
        at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:68)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitBinaryExpression(CodeVisitorSupport.java:195)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitDeclarationExpression(CodeVisitorSupport.java:296)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitDeclarationExpression(ClassCodeVisitorSupport.java:116)
        at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:86)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:120)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:197)
        at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:106)
        at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:106)
        at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
        at org.codehaus.groovy.ast.MethodCallTransformation.visit(MethodCallTransformation.java:42)
        at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:318)
        at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:965)
        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:647)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:623)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:600)
        at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:390)
        at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:89)
        at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:330)
        at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:327)
        at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
        at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:325)
        at groovy.lang.GroovyShell.parseClass(GroovyShell.java:540)
        at groovy.lang.GroovyShell.run(GroovyShell.java:369)
        at groovy.lang.GroovyShell.run(GroovyShell.java:359)
        at groovy.ui.GroovyMain.processOnce(GroovyMain.java:588)
        at groovy.ui.GroovyMain.run(GroovyMain.java:332)
        at groovy.ui.GroovyMain.access$1400(GroovyMain.java:69)
        at groovy.ui.GroovyMain$GroovyCommand.process(GroovyMain.java:291)
        at groovy.ui.GroovyMain.processArgs(GroovyMain.java:134)
        at groovy.ui.GroovyMain.main(GroovyMain.java:116)
        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.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:110)
        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
Caught: groovy.lang.GroovyRuntimeException: Error: !
groovy.lang.GroovyRuntimeException: Error: !
        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 diff.executeCmd(diff.groovy:342)
        at diff.executeCmd(diff.groovy:336)
        at diff$executeCmd$7.callCurrent(Unknown Source)
        at diff.generateCheckstyleReport(diff.groovy:186)
        at diff$generateCheckstyleReport$5.callCurrent(Unknown Source)
        at diff.run(diff.groovy:25)
        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)

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

Hm, seems to be a Groovy problem if anything.
executeCmd("""groovy --version """) works fine.
executeCmd("""groovy -e "println 'FOO'" """) fails with the same message as above. :-/

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

Hm, in the Groovy-2.5.6\lib directory, which of the files activation-*.jar, jaxb-api-*.jar, jaxb-core-*.jar, jaxb-impl-*.jar and groovy-jaxb-2.5.6.jar do you have? Directly, not in extras-jaxb subdirectory.

@rnveach
Copy link
Member

rnveach commented Mar 17, 2019

do you have? Directly, not in extras-jaxb subdirectory.

in lib I have groovy-jaxb-2.5.6.jar.
in extras-jaxb, I have jaxb-*-2.3.0*.jar and activation.jar.

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

Hm, strange, because if I do either of first or last of the three points in the bottom of http://groovy-lang.org/releasenotes/groovy-2.5.html#Groovy2.5releasenotes-Addendum251 it works (either removing groovy-jaxb or adding the other four to the lib directory)

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

I really wonder that it works for you.
If you call groovy --version, does it also show the Java 11 being used?
I can now even reproduce it standalone.
If I call groovy -d -e "println 'FOO'" from the commandline, FOO is printed,
if I call groovy -e "println \"\"\"groovy -d -e \"println 'FOO'\" \"\"\".execute().errorStream.text" the exception comes.

@Vampire Vampire closed this as completed Mar 17, 2019
@rnveach
Copy link
Member

rnveach commented Mar 17, 2019

> groovy -version
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/C:/RickyPrograms/groovy-2.5.6/lib/groovy-2.5.6.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Groovy Version: 2.5.6 JVM: 11.0.2 Vendor: Oracle Corporation OS: Windows 10
PS C:\Rickys\Java\checkstyleWorkspaceEclipse\contribution\checkstyle-tester>
> groovy -e "println \"\"\"groovy -d -e \"pri
ntln 'FOO'\" \"\"\".execute().errorStream.text"
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/C:/RickyPrograms/groovy-2.5.6/lib/groovy-2.5.6.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script_from_command_line: 1: unexpected char: '\' @ line 1, column 26.
   println " \\groovy -d -e \println
                            ^

1 error

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

My quotes and escaping is for Bash, not for PS

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

wth, from cmd.exe I even get the exception with groovy -d -e "println 'FOO'"

@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2019

https://issues.apache.org/jira/browse/GROOVY-9039 if anyone is interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants