Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hudson 3.1.0 + Maven 2.2.1 + sonar 3.7.3 [ERROR] loader constraint violation: when resolving field "VISIBLE"

My project is using the following tools:

  • Hudson 3.1.0
  • Maven 2.2.1
  • sonar 3.7.3

I'm trying to build my project with Hudson, but I'm stuck with whats appear to be a Sonar issue:

When I ask for Hudson to build my project, I receive the following error:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12 seconds
[INFO] Finished at: Wed Nov 13 15:39:46 BRST 2013
[INFO] Final Memory: 30M/347M
[INFO] ------------------------------------------------------------------------
channel stopped
[WARNINGS] Parsing warnings in console log with parser Java Compiler (Eclipse)
[workspace] $ /usr/share/maven2/bin/mvn -f /home/hudson/hudson-opt/jobs/TutorialSpring/workspace/pom.xml -e -B sonar:sonar -Dsonar.jdbc.driver=org.postgresql.Driver -Dsonar.jdbc.url=jdbc:postgresql://localhost/sonar ******** ******** -Dsonar.host.url=http://xxxxxxx:9000 ******** ********
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'sonar'.
[INFO] Ignoring available plugin update: 2.1 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.0 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.0-beta-2 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.0-beta-1 as it requires Maven version 3.0
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - org.springframework.samples.service.service:MYPROJECT:war:0.0.1-SNAPSHOT
[INFO]    task-segment: [sonar:sonar] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [sonar:sonar {execution: default-cli}]
[INFO] Sonar host: http://xxxxxx:9000
[INFO] Sonar version: 3.7.3
[INFO] Execute: org.codehaus.sonar:sonar-maven-plugin:3.7.3:sonar
Downloading: http://repo1.maven.org/maven2/org/codehaus/sonar/sonar-maven-plugin/3.7.3/sonar-maven-plugin-3.7.3.pom
1K downloaded  (sonar-maven-plugin-3.7.3.pom)
Downloading: http://repo1.maven.org/maven2/org/codehaus/sonar/sonar/3.7.3/sonar-3.7.3.pom
47K downloaded  (sonar-3.7.3.pom)
Downloading: http://repo1.maven.org/maven2/org/codehaus/sonar/sonar-maven-plugin/3.7.3/sonar-maven-plugin-3.7.3.jar
7K downloaded  (sonar-maven-plugin-3.7.3.jar)
Downloading: http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.pom
2K downloaded  (junit-4.10.pom)
Downloading: http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.pom
481b downloaded  (hamcrest-core-1.1.pom)
Downloading: http://repo1.maven.org/maven2/org/hamcrest/hamcrest-parent/1.1/hamcrest-parent-1.1.pom
5K downloaded  (hamcrest-parent-1.1.pom)
[INFO] [sonar:sonar {execution: default-sonar}]
INFO: Default locale: "pt_BR", source code encoding: "UTF-8"
INFO: Work directory: /home/hudson/hudson-opt/jobs/TutorialSpring/workspace/target/sonar
INFO: SonarQube Server 3.7.3
[INFO] [15:39:50.891] Load batch settings
[INFO] [15:39:51.007] User cache: /usr/share/tomcat7/.sonar/cache
[INFO] [15:39:51.010] Install plugins
[INFO] [15:39:51.018] Download sonar-findbugs-plugin-1.3.jar
[INFO] [15:39:51.370] Download sonar-jacoco-plugin-1.3.jar
[INFO] [15:39:51.405] Download sonar-l10n-en-plugin-3.7.3.jar
[INFO] [15:39:51.410] Download sonar-maven-batch-plugin-3.7.3.jar
[INFO] [15:39:51.414] Download sonar-surefire-plugin-1.3.jar
[INFO] [15:39:51.419] Download sonar-cpd-plugin-3.7.3.jar
[INFO] [15:39:51.425] Download sonar-checkstyle-plugin-1.3.jar
[INFO] [15:39:51.500] Download sonar-pmd-plugin-1.3.jar
[INFO] [15:39:51.598] Download sonar-java-plugin-1.3.jar
[INFO] [15:39:51.606] Download sonar-core-plugin-3.7.3.jar
[INFO] [15:39:51.621] Download sonar-dbcleaner-plugin-3.7.3.jar
[INFO] [15:39:51.626] Download sonar-squid-java-plugin-1.3.jar
[INFO] [15:39:51.687] Download sonar-email-notifications-plugin-3.7.3.jar
[INFO] [15:39:51.724] Download sonar-design-plugin-3.7.3.jar
[INFO] [15:39:51.848] Install JDBC driver
[INFO] [15:39:51.867] Create JDBC datasource for jdbc:postgresql://localhost/sonar
[INFO] [15:39:52.947] Initializing Hibernate
[INFO] [15:39:55.446] Load project settings
[INFO] [15:39:55.484] Apply project exclusions
[INFO] [15:39:55.671] -------------  Scan Unnamed - org.springframework.samples.service.service:MYPROJECT:war:0.0.1-SNAPSHOT
[INFO] [15:39:55.675] Load module settings
[ERROR] loader constraint violation: when resolving field "VISIBLE" the class loader (instance of org/sonar/runner/impl/IsolatedClassloader) of the referring class, org/apache/commons/io/filefilter/HiddenFileFilter, and the class loader (instance of org/codehaus/classworlds/RealmClassLoader) for the field's resolved type, r, have different Class objects for that type
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: loader constraint violation: when resolving field "VISIBLE" the class loader (instance of org/sonar/runner/impl/IsolatedClassloader) of the referring class, org/apache/commons/io/filefilter/HiddenFileFilter, and the class loader (instance of org/codehaus/classworlds/RealmClassLoader) for the field's resolved type, r, have different Class objects for that type
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:103)
    at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:79)
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:88)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: org.apache.maven.plugin.MojoExecutionException: loader constraint violation: when resolving field "VISIBLE" the class loader (instance of org/sonar/runner/impl/IsolatedClassloader) of the referring class, org/apache/commons/io/filefilter/HiddenFileFilter, and the class loader (instance of org/codehaus/classworlds/RealmClassLoader) for the field's resolved type, r, have different Class objects for that type
    at org.sonar.maven.ExceptionHandling.handle(ExceptionHandling.java:37)
    at org.sonar.maven.SonarMojo.execute(SonarMojo.java:175)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:98)
    ... 21 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving field "VISIBLE" the class loader (instance of org/sonar/runner/impl/IsolatedClassloader) of the referring class, org/apache/commons/io/filefilter/HiddenFileFilter, and the class loader (instance of org/codehaus/classworlds/RealmClassLoader) for the field's resolved type, r, have different Class objects for that type
    at org.sonar.batch.scan.filesystem.DefaultModuleFileSystem.<clinit>(DefaultModuleFileSystem.java:51)
    at org.sonar.batch.scan.filesystem.ModuleFileSystemProvider.provide(ModuleFileSystemProvider.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
    at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
    at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
    at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
    at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
    at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:698)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:646)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:631)
    at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
    at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
    at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1033)
    at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1025)
    at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1002)
    at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:187)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:182)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:175)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:156)
    at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:144)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:90)
    at org.sonar.maven.SonarMojo.execute(SonarMojo.java:173)
    ... 23 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Wed Nov 13 15:39:55 BRST 2013
[INFO] Final Memory: 37M/350M
[INFO] ------------------------------------------------------------------------
Sonar analysis completed: FAILURE

Below you can find my Pom.xml of my project:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework.samples.service.service</groupId>
    <artifactId>MYPROJECT</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>

        <!-- Generic properties -->
        <java.version>1.6</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Web -->
        <jsp.version>2.2</jsp.version>
        <jstl.version>1.2</jstl.version>
        <servlet.version>2.5</servlet.version>


        <!-- Spring -->
        <spring-framework.version>3.2.3.RELEASE</spring-framework.version>

        <!-- Hibernate / JPA -->
        <hibernate.version>4.2.2.Final</hibernate.version>

        <!-- Logging -->
        <logback.version>1.0.13</logback.version>
        <slf4j.version>1.7.5</slf4j.version>

        <!-- Test -->
        <junit.version>4.11</junit.version>

    </properties>

    <dependencies>

        <!-- Spring MVC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <!-- Other Web dependencies -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Spring and Transactions -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <!-- Logging with SLF4J & LogBack -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- Hibernate -->

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.0.1.Final</version>
        </dependency>

        <!-- Test Artifacts -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring-framework.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
        </dependency>

        <!-- Other Artifacts -->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.3</version>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

I saw at the codehaus a similiar a issue from 2011 with the same problem, but it seems the solutions didnt worky (link for the issue):

What I did:

  1. I lookup for the lib commons-io:

    $find . -name commons-io* 2> /dev/null
    ./usr/share/java/commons-io-1.4.jar
    ./usr/share/java/commons-io.jar
    ./usr/share/tomcat7/.sonar/cache/7f97854dc04c119d461fed14f5d8bb96/commons-io-2.4.jar
    ./usr/share/maven-repo/commons-io
    ./usr/share/maven-repo/commons-io/commons-io
    ./usr/share/maven-repo/commons-io/commons-io/1.4/commons-io-1.4.jar
    ./usr/share/maven-repo/commons-io/commons-io/1.4/commons-io-1.4.pom
    ./usr/share/maven-repo/commons-io/commons-io/debian/commons-io-debian.jar
    ./usr/share/maven-repo/commons-io/commons-io/debian/commons-io-debian.pom
    ./home/sonar/lib/commons-io-2.4.jar
    ./home/sonar/war/sonar-server/WEB-INF/lib/commons-io-2.4.jar
    ./home/sonar-3.7.3/sonar-3.7.3/lib/commons-io-2.4.jar
    ./home/sonar-3.7.3/sonar-3.7.3/war/sonar-server/WEB-INF/lib/commons-io-2.4.jar
    ./home/hudson/hudson-opt/plugins/maven-plugin/WEB-INF/lib/commons-io-2.0.1.jar
    ./home/hudson/hudson-opt/plugins/artifactory/WEB-INF/lib/commons-io-2.0.1.jar
    ./home/hudson/hudson-opt/plugins/warnings/WEB-INF/lib/commons-io-2.2.jar
    ./home/hudson/public_html_back/WEB-INF/lib/commons-io-2.0.1.jar
    ./home/hudson/public_html/WEB-INF/lib/commons-io-2.0.1.jar
    
  2. make a backup of:

    $cp ./home/sonar/lib/commons-io-2.4.jar ./home/sonar/lib/commons-io-2.4.jar_back $cp ./home/sonar/war/sonar-server/WEB-INF/lib/commons-io-2.4.jar ./home/sonar/war/sonar-server/WEB-INF/lib/commons-io-2.4.jar

  3. them I put a old version of commons-io lib at the sonar lib folder:

    $cp ./home/hudson/hudson-opt/plugins/artifactory/WEB-INF/lib/commons-io-2.0.1.jar ./home/sonar/lib/

    $sudo /etc/init.d/sonar restart

  4. When I saw that this dindt work I repeat those steps for the librarys: commons-io-2.2.jar and commons-io-1.4.jar

No luck until now :(

like image 593
Mr. CoffeBreak Avatar asked Nov 11 '22 18:11

Mr. CoffeBreak


1 Answers

The following thread should help: http://sonarqube.15.x6.nabble.com/SonarQube-3-7-3-failing-to-process-java-projects-td5018320.html

like image 199
David RACODON - QA Consultant Avatar answered Nov 15 '22 05:11

David RACODON - QA Consultant