npm-groovy-lint icon indicating copy to clipboard operation
npm-groovy-lint copied to clipboard

CodeNarcServer unexpected error

Open UksusoFF opened this issue 4 months ago • 9 comments

Node: v21.6.2 Ubuntu: 22.04.1

Always get error:

GroovyLint: Started CodeNarc Server
CodeNarcServer unexpected error:
{
  "message": "Request failed with status code 500",
  "name": "Error",
  "stack": "Error: Request failed with status code 500\n    at createError (/home/uksusoff/ci-tools/jenkins/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/home/uksusoff/ci-tools/jenkins/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/home/uksusoff/ci-tools/jenkins/node_modules/axios/lib/adapters/http.js:236:11)\n    at IncomingMessage.emit (node:events:531:35)\n    at endReadableNT (node:internal/streams/readable:1696:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)",
  "config": {
    "url": "http://localhost:7484/request",
    "method": "post",
    "data": "{\"codeNarcArgs\":\"-basedir=/home/uksusoff/ci-tools/jenkins -rulesetfiles=file:/tmp/npm-groovy-lint/codeNarcTmpRs_0.8913330368337362.groovy -includes=**/*.groovy,**/Jenkinsfile,**/*.gradle -report=json:stdout\",\"codeNarcBaseDir\":\"/home/uksusoff/ci-tools/jenkins\",\"codeNarcIncludes\":\"**/*.groovy,**/Jenkinsfile,**/*.gradle\",\"parse\":true,\"file\":null,\"requestKey\":null}",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/json;charset=utf-8",
      "User-Agent": "axios/0.19.2",
      "Content-Length": 363
    },
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 600000,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1
  }
}
GroovyLint: Error running CodeNarc: 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.ReflectionUtils (file:/home/uksusoff/ci-tools/jenkins/node_modules/npm-groovy-lint/lib/java/groovy/lib/groovy-3.0.5.jar) to field java.lang.ThreadGroup.name
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.ReflectionUtils
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
java.lang.NullPointerException: Cannot invoke method trim() on null object
	at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:44)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)

How can troubleshoot this?

UksusoFF avatar Feb 15 '24 17:02 UksusoFF

This seems to be a CodeNarc internal error... What is your version of java ?

nvuillam avatar Feb 15 '24 18:02 nvuillam

java --version
openjdk 11.0.21 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)

UksusoFF avatar Feb 15 '24 18:02 UksusoFF

https://github.com/nvuillam/npm-groovy-lint?tab=readme-ov-file#installation

npm-groovy-lint is supposed to install java 17 if a previous version is found...

Was your first run strangely long ?

What if you try to add --noserver to your npm-groovy-lint call ?

nvuillam avatar Feb 15 '24 18:02 nvuillam

After apt install openjdk-17-jdk openjdk-17-jre and reboot.

First run npm-groovy-lint stuck on CodeNarcServer run without any errors.

Second run produce: GroovyLint: Request cancelled by duplicate call on requestKey undefined

UksusoFF avatar Feb 16 '24 07:02 UksusoFF

--noserver produce:

GroovyLint: Error running CodeNarc: 
BUG! exception in phase 'semantic analysis' in source unit 'None' Unsupported class file major version 61
	at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:905)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627)
	at org.codehaus.groovy.control.CompilationUnit$compile$0.call(Unknown Source)
	at org.codenarc.source.AbstractSourceCode.init(AbstractSourceCode.groovy:98)
	at org.codenarc.source.AbstractSourceCode.getAst(AbstractSourceCode.groovy:85)

UksusoFF avatar Feb 16 '24 07:02 UksusoFF

ouuuch... seems to require super @stevenh 's knowledge ^^

nvuillam avatar Feb 16 '24 08:02 nvuillam

Looks like your trying to use a java version, possibly a library, that's compiled with a version of java later that what the code is compiled with, so it can't analyse it.

Can you run the server with debug enabled and post the log file so we can see if it's server or codenarc which is throwing the error.

stevenh avatar Feb 16 '24 13:02 stevenh

@nvuillam how I can pass debug enabled to CodeNarc with npm-groovy-lint?

UksusoFF avatar Feb 26 '24 15:02 UksusoFF

You can't but if you can run it manually from the command line in another shell npm-groovy-lint will use it instead of starting one.

stevenh avatar Feb 26 '24 20:02 stevenh

I am getting similar error, possibly due to my proxy settings, but it makes me paranoid that my non-open-source Jenkinsfile is going to get sent to some off-site server, which is not allowed by my company. Why didn't npm install all pre-reqs? Here's my java output:

$ java --version
Command 'java' not found, but can be installed with:
sudo apt install default-jre              # version 2:1.11-72build2, or
sudo apt install openjdk-11-jre-headless  # version 11.0.20.1+1-0ubuntu1~22.04
sudo apt install openjdk-17-jre-headless  # version 17.0.8.1+1~us1-0ubuntu1~22.04
sudo apt install openjdk-18-jre-headless  # version 18.0.2+9-2~22.04
sudo apt install openjdk-19-jre-headless  # version 19.0.2+7-0ubuntu3~22.04
sudo apt install openjdk-8-jre-headless   # version 8u382-ga-1~22.04.1

using --noserver I still get something about codenarc trying to download and it doesn't seem like it makes any progress:

[████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] Running CodeNarc for 0sJava jre or jdk 17 is required
Installing Java jre 17 in /home/user/.java-caller...
[████████████████████████░░░░░░░░░░░░░░░░] Running CodeNarc for 2m3s^C

then I installed java 17 manually with apt: apt install openjdk-17-jre-headless

then I re-run the linter (with --noserver), and I get linting results.

nmz787-intel avatar Mar 21 '24 18:03 nmz787-intel

Can't fix this issue on localhost, but run successful in Docker container. So seems this is environment dependent.

UksusoFF avatar Mar 29 '24 06:03 UksusoFF