jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

I generate application with Jhipster 8.0.0-beta.2 but sonar analysis appears error #23265

Closed javachavez closed 1 year ago

javachavez commented 1 year ago
Overview of the issue

I generate application with Jhipster 8.0.0-beta.2 but sonar analysis appears error, when execute in jenkins file.

Motivation for or Use Case

I need sonar analysis.

Reproduce the error

Generate jhipster application with generator and jdl generator entities Execute in jenkins with jenkinsfile. Appears this error in stage quality analysis:

[INFO] [INFO] --- properties:1.1.0:read-project-properties (default) @ establishment-catalog --- [INFO] [INFO] --- jacoco:0.8.10:prepare-agent (pre-unit-tests) @ establishment-catalog --- [INFO] argLine set to -javaagent:/var/lib/jenkins/.m2/repository/org/jacoco/org.jacoco.agent/0.8.10/org.jacoco.agent-0.8.10-runtime.jar=destfile=/mnt/data/jenkins/workspace/establishment-catalog_sonar/target/jacoco.exec -Djava.security.egd=file:/dev/./urandom -Xmx1G [INFO] [INFO] -----< com.jumbotours.establishmentcatalog:establishment-catalog >------ [INFO] Building Establishment Catalog 0.0.1-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- sonar:3.9.1.2184:sonar (default-cli) @ establishment-catalog --- [INFO] User cache: /var/lib/jenkins/.sonar/cache [INFO] SonarQube version: 7.9.1 [INFO] Default locale: "es_ES", source code encoding: "UTF-8" [INFO] Load global settings [INFO] Load global settings (done) | time=80ms [INFO] Server id: A7EE8CF2-AXIr741RGzh0g1Z-gz91 [INFO] User cache: /var/lib/jenkins/.sonar/cache [INFO] Load/download plugins [INFO] Load plugins index [INFO] Load plugins index (done) | time=49ms [INFO] Load/download plugins (done) | time=78ms [INFO] Process project properties [INFO] Execute project builders [INFO] Execute project builders (done) | time=3ms [INFO] Project key: establishment-catalog:sonar [INFO] Base dir: /mnt/data/jenkins/workspace/establishment-catalog_sonar [INFO] Working dir: /mnt/data/jenkins/workspace/establishment-catalog_sonar/target/sonar [INFO] Load project settings for component key: 'establishment-catalog:sonar' [INFO] Load project settings for component key: 'establishment-catalog:sonar' (done) | time=19ms [INFO] Load quality profiles [INFO] Load quality profiles (done) | time=43ms [INFO] Detected Jenkins [INFO] Load active rules [INFO] Load active rules (done) | time=406ms [INFO] Indexing files... [INFO] Project configuration: [INFO] Excluded sources: src/main/webapp/content//., src/main/webapp/i18n/.js, target/classes/static//., src/test//. [INFO] Included tests: src/test//. [INFO] 153 files indexed [INFO] 0 files ignored because of inclusion/exclusion patterns [INFO] 0 files ignored because of scm ignore settings [INFO] Quality profile for java: Sonar way jumbo [INFO] Quality profile for web: Sonar way [INFO] Quality profile for xml: Sonar way [INFO] ------------- Run sensors on module establishment-catalog:sonar [INFO] Load metrics repository [INFO] Load metrics repository (done) | time=20ms [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.142 s [INFO] Finished at: 2023-08-10T18:03:11+02:00 [INFO] ------------------------------------------------------------------------ [WARNING] [WARNING] Plugin validation issues were detected in 3 plugin(s) [WARNING] [WARNING] org.jacoco:jacoco-maven-plugin:0.8.10 [WARNING] org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184 [WARNING] org.apache.maven.plugins:maven-resources-plugin:3.3.1 [WARNING] [WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [BRIEF, DEFAULT, VERBOSE] [WARNING] [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project establishment-catalog: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar: java.lang.ExceptionInInitializerError: null [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/var/lib/jenkins/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar [ERROR] urls[1] = file:/var/lib/jenkins/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar [ERROR] urls[2] = file:/var/lib/jenkins/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar [ERROR] urls[3] = file:/var/lib/jenkins/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar [ERROR] urls[4] = file:/var/lib/jenkins/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar [ERROR] urls[5] = file:/var/lib/jenkins/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] ----------------------------------------------------- [ERROR] : java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1c5cd2ea [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException [Pipeline] } WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?

JHipster Version(s)

Jhipster 8.0.0-beta.2

JHipster configuration

jhipster info WARNING! Since JHipster v8, the jhipster command will not use the locally installed generator-jhipster. If you want to execute the locally installed generator-jhipster, run: npx jhipster

    ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
    ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
    ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝

██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ https://www.jhipster.tech Welcome to JHipster v8.0.0-beta.2

Welcome to the JHipster Information Sub-Generator

establishment-catalog@0.0.0 C:\JIP\develop\BKN\establishment-catalog
`-- generator-jhipster@8.0.0-beta.1 invalid: "8.0.0-beta.2" from the root project
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "applicationType": "microservice",
  "authenticationType": "jwt",
  "baseName": "establishment-catalog",
  "buildTool": "maven",
  "cacheProvider": "no",
  "clientFramework": "no",
  "creationTimestamp": 1687288828490,
  "databaseType": "sql",
  "devDatabaseType": "oracle",
  "dtoSuffix": "DTO",
  "enableGradleEnterprise": null,
  "enableHibernateCache": false,
  "enableSwaggerCodegen": false,
  "enableTranslation": false,
  "entities": [
    "MessagePendingToSendKafka",
    "Language",
    "RoomType",
    "RoomTypeTranslation",
    "CRMClient"
  ],
  "entitySuffix": "",
  "gradleEnterpriseHost": null,
  "jhiPrefix": "jhi",
  "jhipsterVersion": "8.0.0-beta.2",
  "lastLiquibaseTimestamp": 1690361568000,
  "messageBroker": false,
  "microfrontend": false,
  "microfrontends": [],
  "nativeLanguage": "es",
  "packageFolder": "com/jumbotours/establishmentcatalog",
  "packageName": "com.jumbotours.establishmentcatalog",
  "pages": [],
  "prodDatabaseType": "oracle",
  "reactive": false,
  "searchEngine": false,
  "serverPort": "8094",
  "serverSideOptions": [],
  "serviceDiscoveryType": "eureka",
  "skipCheckLengthOfIdentifier": false,
  "skipClient": true,
  "skipFakeData": false,
  "skipUserManagement": true,
  "testFrameworks": [],
  "websocket": "no",
  "withAdminUi": false
}
Environment and Tools

openjdk version "11.0.4" 2019-07-16 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11) Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.15.1, JRE 11 Windows 10 amd64-64-Bit Compressed References 20190717_282 (JIT enabled, AOT enabled) OpenJ9 - 0f66c6431 OMR - ec782f26 JCL - fa49279450 based on jdk-11.0.4+11)

git version 2.30.1.windows.1

node: v18.16.0 npm: 9.7.1

'docker' command could not be found

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity MessagePendingToSendKafka {
  id Long required
  topic String required maxlength(50)
  entityId Long required
  key Long required
  message String required
  numAttempts Long required
  modifiedDateTime Instant required
  error String maxlength(255)
}
entity Language {
  id Long required
}
entity RoomType {
  id Long required
  code String
  maxPax Integer
  minPax Integer
  minAdults Integer
  minChildren Integer
  maxInfants Integer
  maxAdults Integer
  maxChildren Integer
  type String
  activo Boolean
  externalCode String maxlength(255)
  hotel String maxlength(255)
  idJet String minlength(1) maxlength(10)
}
entity RoomTypeTranslation {
  id Long required
  text String minlength(1) maxlength(10000)
  activo Boolean
}
entity CRMClient {
  id Long required
}
relationship OneToMany {
  Language{id} to RoomTypeTranslation{language}
  RoomType{nameTranslations} to RoomTypeTranslation{roomType}
}
relationship ManyToOne {
  RoomType{crmClient} to CRMClient
  RoomTypeTranslation{language} to Language{id}
  RoomTypeTranslation{roomType} to RoomType{nameTranslations}
}

service MessagePendingToSendKafka, Language, RoomType, RoomTypeTranslation, CRMClient with serviceClass
microservice MessagePendingToSendKafka, Language, RoomType, RoomTypeTranslation, CRMClient with establishment-catalog
clientRootFolder MessagePendingToSendKafka, Language, RoomType, RoomTypeTranslation, CRMClient with establishment-catalog

√ applying multi-step templates info Multiple customCommitTask tasks found (C:\JIP\develop\BKN\establishment-catalog#jhipster:info, jhipster:bootstrap). Using the first.

Congratulations, JHipster execution is complete! If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/

Sponsored with ❤️ by @oktadev.

Browsers and Operating System

All Operating System, all browsers

Jenkins File

def gateId = 47 def pom def app def gitRepo = "establishment-catalog"

def cancelPreviousBuilds() { def jobName = env.JOB_NAME def buildNumber = env.BUILD_NUMBER.toInteger() / Get job name / def currentJob = Jenkins.instance.getItemByFullName(jobName)

/* Iterating over the builds for specific job */
for (def build : currentJob.builds) {
    def exec = build.getExecutor()
    /* If there is a build that is currently running and it's not current build */
    if (build.isBuilding() && build.number.toInteger() != buildNumber && exec != null) {
        /* Then stop it */
        exec.interrupt(
                Result.ABORTED,
                new CauseOfInterruption.UserInterruption("Aborted by #'${env.BUILD_NUMBER}'")
        )
        println("Aborted previously running build #'${env.BUILD_NUMBER}'")
        echo "Aborted previously running build #'${env.BUILD_NUMBER}'"
        slackSend(channel: "#jenkins", color: '#FFBB2F', message: "ABORTED: Job by previously running build '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
    }
}

}

pipeline {

agent any

options {
    timeout(time: 1, unit: 'HOURS')
    preserveStashes(buildCount: 5)
    disableResume()
}

stages {
    stage('clean') {
        steps {
            script{
                cancelPreviousBuilds()
                pom= readMavenPom file: 'pom.xml'
                app= "${pom.artifactId}"
                echo "App: ${app}"
                sh "JAVA_HOME=/usr/lib/jvm/jdk-19.0.2 /mnt/data/maven-3.9.2/bin/mvn clean -P-webpack"
                sh "JAVA_HOME=/usr/lib/jvm/jdk-19.0.2 /mnt/data/maven-3.9.2/bin/mvn --version"
            }
        }
    }
    // stage('checkstyle') {
    //    steps {
    //        sh "mvn checkstyle:check"
    //    }
    //}

    stage('backend tests') {
        steps {
            script {
                try {
                 sh "JAVA_HOME=/usr/lib/jvm/jdk-19.0.2 /mnt/data/maven-3.9.2/bin/mvn -U verify -P-webpack"
                } catch(err) {
                    throw err
                } finally {
                    junit '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml'
                }
            }
        }
    }

    stage('packaging') {
        steps {
            sh "JAVA_HOME=/usr/lib/jvm/jdk-19.0.2 /mnt/data/maven-3.9.2/bin/mvn -ntp verify -P-webapp -Pprod -DskipTests"
            archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
        }
    }

      stage('quality analysis') {
        when {  
            anyOf {
                expression { "${env.BRANCH_NAME}".startsWith('sonar') }
            }
        }
        steps {
            script {
                withSonarQubeEnv('SonarQube') {
                    def url = "${env.SONAR_URL_CREATE}"
                    def token = "${env.SONAR_TOKEN}"
                    def urlQualitygate = "${env.SONAR_URL_QUALITY}"
                    echo "${url}"
                    echo "${token}"
                    echo "${urlQualitygate}"
                    sh "curl -u ${token}: ${url} -d 'name=${app}&project=${app}&branch=${env.BRANCH_NAME}'"
                    echo "API SONAR: ${urlQualitygate}/gateId=${gateId}&projectKey=${app}:${env.BRANCH_NAME}"
                    sh "curl -u ${token}: ${urlQualitygate} -d 'gateId=${gateId}&projectKey=${app}:${env.BRANCH_NAME}'"
                    sh "JAVA_HOME=/usr/lib/jvm/jdk-19.0.2 /mnt/data/maven-3.9.2/bin/mvn initialize sonar:sonar -Dsonar.projectKey=${app}:${env.BRANCH_NAME} -Dsonar.projectName=${app}:${env.BRANCH_NAME}"
                }
            }
        }
    }

    stage('quality gates') {
        when {  
            anyOf {
                expression { "${env.BRANCH_NAME}".startsWith('pruebas') }
            }
        }
        steps {
            script {
                    timeout(time: 2, unit: 'MINUTES') {
                        def qualitygate = waitForQualityGate()
                        if (qualitygate.status == 'ERROR') {
                            eror "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
                        }
                        if (qualitygate.status == 'WARN') {
                            echo "El estatus de calidad es:  ${qualitygate.status}, por ello el código se puede mejorar"
                        }
                    }
            }
        }
    }

    stage('publish docker') {
        steps {
            script {
                def branch = "${env.BRANCH_NAME}";
                def version = branch.replace("release-", "");
                def imageTag = "${version}.${env.BUILD_NUMBER}"

                if ("${env.BRANCH_NAME}".startsWith('release')
                    ||"${env.BRANCH_NAME}".startsWith('develop')
                    ||"${env.BRANCH_NAME}".startsWith('RC')) 
                {
                    if ("${env.BRANCH_NAME}".startsWith('release')){
                        tag = "${imageTag}"
                    } else {
                        tag = "${env.BRANCH_NAME}"
                    }

                    sh "JAVA_HOME=/usr/lib/jvm/jdk-19.0.2 /mnt/data/maven-3.9.2/bin/mvn -U -X jib:build -Denv.BRANCH_NAME=${tag}"
                }

                cleanWs()
            }
        }
    }
    stage('merges release') {
        when {
            anyOf {
                expression { "${env.BRANCH_NAME}".startsWith('release') }
            }
        }
        steps {
            script {
                    withCredentials([usernamePassword(credentialsId: 'jenkinsApp', passwordVariable: 'password', usernameVariable: 'username')]) {
                        sh("git checkout RC")
                        sh("git checkout ${env.BRANCH_NAME}")
                        sh("git checkout RC")
                        sh("git fetch https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                        sh("git pull https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                        try {
                            sh("git merge ${env.BRANCH_NAME}")
                            sh("git push https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                        } catch (all) {
                            //ignored
                        }
                    }

            }
        }
    }

    stage('merges RC') {
        when {
            anyOf {
                expression { "${env.BRANCH_NAME}".startsWith('RC') }
            }
        }
        steps {
            script {
                    withCredentials([usernamePassword(credentialsId: 'jenkinsApp', passwordVariable: 'password', usernameVariable: 'username')]) {
                        try {
                            sh("git checkout develop")
                            sh("git checkout RC ")
                            sh("git checkout develop")
                            sh("git fetch https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                            sh("git pull https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                            sh("git merge RC")
                            sh("git push https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                        } catch (all) {
                            //ignored
                        }
                    }
            }
        }
    }

    stage('merges epic') {
        when {
            anyOf {
                expression {
                    "${env.BRANCH_NAME}".startsWith('epic-') || "${env.BRANCH_NAME}".startsWith('EPIC-')
                }
            }
        }
        steps {
            script {
                    withCredentials([usernamePassword(credentialsId: 'jenkinsApp', passwordVariable: 'password', usernameVariable: 'username')]) {
                        try {
                            sh("git checkout ${env.BRANCH_NAME}")
                            sh("git checkout develop")
                            sh("git checkout ${env.BRANCH_NAME}")
                            sh("git fetch https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                            sh("git pull https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                            sh("git merge develop")
                            sh("git push https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                        } catch (all) {
                            //ignored
                        }

                        try {
                            sh("git checkout develop-temp")
                            sh("git checkout ${env.BRANCH_NAME}")
                            sh("git checkout develop-temp")
                            sh("git fetch https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                            sh("git pull https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                            sh("git merge ${env.BRANCH_NAME}")
                            sh("git push https://$username:$password@'bitbucket.org/jumbotours/${app}.git'")
                        } catch (all) {
                            //ignored
                        }
                    }
            }
        }
    }
}

triggers {
    bitbucketPush()
}

post {
    always {
        cleanWs()
    }
    success {
        slackSend(color: '#00FF00', message: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
        bitbucketStatusNotify(buildState: 'SUCCESSFUL')
    }

    failure {
        slackSend(color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
        bitbucketStatusNotify(buildState: 'FAILED')
    }
}

}

mshima commented 1 year ago

Looks an environment error at Jenkins, not a jhipster issue. Please post at stackoverflow. If you manage to reproduce locally, let us know. Don’t forget to update to Java 17.

javachavez commented 1 year ago

where can i post it? url please? thanks

mraible commented 1 year ago

https://stackoverflow.com. Use the "jhipster" tag if you want attention from committers.

javachavez commented 1 year ago

done: https://stackoverflow.com/questions/77021845/i-generate-application-with-jhipster-8-0-0-beta-2-but-sonar-analysis-appears-errx#new-answer