Skip to content

The latest version (codeanalyzer-1.0.8.jar) of the code analyzer is failing when executing the datasets #87

Closed

Description

@rejoykulangara

Describe the bug

The latest version (codeanalyzer-1.0.8.jar) of the code analyzer execution is failing when executing the dataset .
Currently, we have found this issue in the cash-account and portfolio-spring projects.
code analyser version = codeanalyzer-1.0.8.jar
datasets = https://github.com/IBMStockTrader/cash-account,
https://github.com/IBMStockTrader/portfolio-spring

Steps To Reproduce

Steps to reproduce the behavior:
execute below command with latest code analyser (1.0.8)
java -jar codeanalyzer-1.0.8.jar -i ~/{root project folder} -o ~/{outputFolder} -a 2

Observed behavior

Command execution is failing with the following error:

java.lang.RuntimeException: java.lang.IllegalStateException: Could not find a valid maven command. I did not find
/cash-account/mvnw in the project directory or in the system PATH.
at com.ibm.cldk.CodeAnalyzer.run(CodeAnalyzer.java:103)
at picocli.CommandLine.executeUserObject(CommandLine.java:1767)
at picocli.CommandLine.access$900(CommandLine.java:145)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2139)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2106)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1973)
at picocli.CommandLine.execute(CommandLine.java:1902)
at com.ibm.cldk.CodeAnalyzer.main(CodeAnalyzer.java:92)
Caused by: java.lang.IllegalStateException: Could not find a valid maven command. I did not find /cash-account/mvnw in the project directory or in the system PATH.
at com.ibm.cldk.utils.BuildProject.downloadLibraryDependencies(BuildProject.java:231)
at com.ibm.cldk.CodeAnalyzer.analyze(CodeAnalyzer.java:121)
at com.ibm.cldk.CodeAnalyzer.run(CodeAnalyzer.java:101)

Expected behavior

It should execute and build analysis.json without any error

Screenshots

If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS = macOS 15.1, linux
  • Version of Java = Eclipse OpenJ9 VM 17.0.10.0
  • Version of Maven = Apache Maven 3.9.9

Additional context

Add any other context about the problem here.

Activity

  1. changed the title [-]The latest version (codeanalyzer-1.0.8.jar) of the code analyzer is failing when executing the cash account dataset[/-] [+]The latest version (codeanalyzer-1.0.8.jar) of the code analyzer is failing when executing the dataset[/+] on Jan 8, 2025
  2. changed the title [-]The latest version (codeanalyzer-1.0.8.jar) of the code analyzer is failing when executing the dataset[/-] [+]The latest version (codeanalyzer-1.0.8.jar) of the code analyzer is failing when executing the datasets[/+] on Jan 8, 2025
  3. rofrano commented on Jan 9, 2025

    @rofrano
    Collaborator

    CodeAnalyzer requires a working Maven or Gradle build environment. I followed your instructions and reproduced the error.

    Caused by: java.lang.IllegalStateException: Could not find a valid maven command. I did not find /cash-account/mvnw in the project directory or in the system PATH.
    

    Then I noticed that the cash-account repo has a mvnw command so I tried to execute it but the execute bit was not set. So I set it and executed it to see if it works and got back this error:

    $ ./mvnw 
    ./mvnw: 223: cannot open /workspaces/java-test-env/code/cash-account/.mvn/wrapper/maven-wrapper.properties: No such file
    /workspaces/java-test-env/code/cash-account/.mvn/wrapper/maven-wrapper.jar: No such file or directory
    Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
    Caused by: java.lang.ClassNotFoundException: org.apache.maven.wrapper.MavenWrapperMain

    Clearly not working. Then I renamed it to get it out of the way:

    $ mv ./cash-account/mvnw ./cash-account/_mvnw

    Then I executed CodeAnalyzer again:

    $ java -jar codeanalyzer-1.0.8.jar -i ./cash-account -o ./output/cash-account -a 2

    and it worked this time producing an ./output/cash-account/analysis.json file as expected.

    We will still accept this as a bug because if mvnw fails we should fall back to using the raw mvn command, but at least you have a work-around while we fix this. (i.e., name mvnw, run codeanalyzer, rename it back) Renaming mvnw in theportfolio-spring project works as well. We will investigate further.

  4. self-assigned this
    on Jan 15, 2025
  5. rejoykulangara commented on Jan 17, 2025

    @rejoykulangara
    Author

    Thanks for the workaround. We have adopted this as temporary code as a fallback mechanism in our pipeline, and it is working perfectly. We will be monitoring the latest code analyzer releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions