7 Replies Latest reply: Jul 11, 2011 5:30 AM by jemawa RSS

    test failures during mvn package

    jemawa Community Member

      I am trying to add rules to the FlexPMD ruleset. I have checked out the code and initially it packaged and compiled correctly, however after adding a new rule and compiling it, the mvn package command fails.

       

      I have never used maven before, so I am at a loss as to how to fix it. It has to do with the testing I do know. If I run the command “mvn –Dmaven.test.skip=true package” then I am able to get passed the fail and run FlexPMD with my new rule just fine. When I run just mvn package, here is part of the build including my error:

       

      [INFO] ------------------------------------------------------------------------
      [INFO] Building Adobe Flex PMD RuleSet API 1.2
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- maven-dependency-plugin:2.0:unpack-dependencies (unpack-test-resource
      s) @ flex-pmd-ruleset-api ---
      [INFO] Unpacking C:\AndrewPMDSource\flex-pmd-test-resources\target\flex-pmd-test
      -resources-1.2-resources.zipto
      C:\AndrewPMDSource\flex-pmd-ruleset-api\target\test\generated-resources
      with Includes **/*.as,**/*.mxml and excludes:null
      [INFO] as3-parser-1.2.jar already exists in destination.
      [INFO] as3-plugin-utils-1.2.jar already exists in destination.
      [INFO] flex-pmd-files-1.2.jar already exists in destination.
      [INFO]
      [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ flex-pmd
      -ruleset-api ---
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] Copying 1 resource
      [INFO]
      [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ flex-pmd-rule
      set-api ---
      [INFO] Nothing to compile - all classes are up to date
      [INFO]
      [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @
      flex-pmd-ruleset-api ---
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] Copying 96 resources
      [INFO] Copying 0 resource
      [INFO]
      [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ flex-
      pmd-ruleset-api ---
      [INFO] Nothing to compile - all classes are up to date
      [INFO]
      [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ flex-pmd-ruleset-ap
      i ---
      [INFO] Surefire report directory: C:\AndrewPMDSource\flex-pmd-ruleset-api\target
      \surefire-reports
      java.lang.reflect.UndeclaredThrowableException
              at $Proxy0.invoke(Unknown Source)
              at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(Suref
      ireStarter.java:150)
              at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(S
      urefireStarter.java:91)
              at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:
      69)
      Caused by: java.lang.reflect.InvocationTargetException
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.inv
      oke(ProviderFactory.java:103)
              ... 4 more
      Caused by: java.lang.NoClassDefFoundError: JSAPException
              at java.lang.Class.getDeclaredMethods0(Native Method)
              at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
              at java.lang.Class.getMethod0(Class.java:2670)
              at java.lang.Class.getMethod(Class.java:1603)
              at org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod(Reflectio
      nUtils.java:57)
              at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isSuiteOnly
      (JUnit3TestChecker.java:65)
              at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isValidJUni
      t3Test(JUnit3TestChecker.java:60)
              at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.accept(JUni
      t3TestChecker.java:55)
              at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUni
      t4TestChecker.java:52)
              at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClas
      ses(DefaultDirectoryScanner.java:80)
              at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4P
      rovider.java:164)
              at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider
      .java:86)
              ... 9 more
      Caused by: java.lang.ClassNotFoundException: JSAPException
              at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
              ... 21 more
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary:
      [INFO]
      [INFO] Adobe Flex PMD Java Parent ........................ SUCCESS [1.108s]
      [INFO] As3 Parser API .................................... SUCCESS [3.603s]
      [INFO] As3 Maven plugin Utils ............................ SUCCESS [2.215s]
      [INFO] Adobe Flex PMD RuleSet test resources ............. SUCCESS [3.619s]
      [INFO] Adobe Flex PMD Files .............................. SUCCESS [5.008s]
      [INFO] As3 Parser ........................................ SUCCESS [3.104s]
      [INFO] Adobe Flex PMD RuleSet API ........................ FAILURE [3.650s]
      [INFO] Adobe Flex PMD RuleSet ............................ SKIPPED
      [INFO] Adobe Flex CPD (Copy and Past Detector) ........... SKIPPED
      [INFO] Adobe Flex CPD Ant task ........................... SKIPPED
      [INFO] Adobe Flex PMD Core ............................... SKIPPED
      [INFO] Adobe Flex CPD Maven plugin ....................... SKIPPED
      [INFO] Adobe Flex PMD Command line API ................... SKIPPED
      [INFO] Adobe Flex CPD Command line ....................... SKIPPED
      [INFO] Adobe Flex PMD Ant task ........................... SKIPPED
      [INFO] Adobe Flex PMD Maven plugin ....................... SKIPPED
      [INFO] Adobe Flex PMD Command line ....................... SKIPPED
      [INFO] Adobe Flex Metrics ................................ SKIPPED
      [INFO] Adobe Flex Metrics command line ................... SKIPPED
      [INFO] Adobe Flex Metrics Ant task ....................... SKIPPED
      [INFO] Adobe Flex Metrics Maven plugin ................... SKIPPED
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 23.259s
      [INFO] Finished at: Mon Jun 20 14:20:34 EDT 2011
      [INFO] Final Memory: 8M/19M
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
      7.2:test (default-test) on project flex-pmd-ruleset-api: There are test failures
      .
      [ERROR]
      [ERROR] Please refer to C:\AndrewPMDSource\flex-pmd-ruleset-api\target\surefire-
      reports for the individual test results.
      [ERROR] -> [Help 1]
      [ERROR]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
      ch.
      [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 rea
      d the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
      eption
      [ERROR]
      [ERROR] After correcting the problems, you can resume the build with the command

      [ERROR]   mvn <goals> -rf :flex-pmd-ruleset-api

       

      Any help or guidance would be greatly appreciated 

       

      Thanks,

      Jennifer

       

       

        • 1. Re: test failures during mvn package
          Adrian Parker Community Member

          Hi Jennifer

           

          the error is saying Maven does not have JSAPException.class available.

          This means that in all likelihood your Maven repository is missing jsap-2.1.jar

           

           

           

          adrian$ ls -alR ~/.m2/repository/ | grep jsap

          drwxr-xr-x   3 adrian  staff  102 28 Jun 14:24 jsap

          /Users/adrian/.m2/repository//com/martiansoftware/jsap:

          /Users/adrian/.m2/repository//com/martiansoftware/jsap/2.1:

          -rw-r--r--  1 adrian  staff  69344 28 Jun 14:24 jsap-2.1.jar

          -rw-r--r--  1 adrian  staff    287 28 Jun 14:24 jsap-2.1.jar.lastUpdated

          -rw-r--r--  1 adrian  staff    133 28 Jun 14:24 jsap-2.1.jar.sha1

          -rw-r--r--  1 adrian  staff    815 28 Jun 14:24 jsap-2.1.pom

          -rw-r--r--  1 adrian  staff    287 28 Jun 14:24 jsap-2.1.pom.lastUpdated

          -rw-r--r--  1 adrian  staff    133 28 Jun 14:24 jsap-2.1.pom.sha1

           

           

          I think you are on Windows, so just in case its not clear, what I am doing above is searching my local Maven (.m2) repository for any entry with jsap in the filename, you can see it has a directory com / martiansoft / jsap / 2.1 in which is the JAR we need.

           

           

          Then install it locally via

           

          mvn install:install-file -Dfile=/<path_to>/jsap-2.1.jar -DgroupId=com.martiansoftware.jsap -DartifactId=jsap -Dversion=2.1

           

           

          which should clear this error.  Hope that helps.

           

          Adrian

          • 2. Re: test failures during mvn package
            jemawa Community Member

            Hey Adrian,

             

            Thank you for your reply. I checked my maven repository and it does indeed have the jsap-2.1.jar, so I do not think that this is the issue?

             

            Jennifer

            • 3. Re: test failures during mvn package
              Adrian Parker Community Member

              Hi Jennifer

               

              drat. OK so I still think the problem is with that JAR file - I guess this due to the error you post, specifically

               

              Caused by: java.lang.ClassNotFoundException: JSAPException
                      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
                      at java.security.AccessController.doPrivileged(Native Method)
                      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
                      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
                      ... 21 more

               

              JSAPException is definitely in jsap-2.1.jar (you can check by opening the JAR with a utility like WinZip).

               

              So I think the root cause of your problem is that for whatever reason, Maven cannot see or use that JAR you verified you have in your repository.  Sometimes they get corrupted, so next I'd suggest you try deleting that part of the repository, then try a mvn -U clean package  (this should force Maven to download a fresh copy of that JAR).

               

              So delete /repository/com/martiansoftware   and then mvn -U clean package from flex-pmd-parent  (and cross your fingers)

               

              If that fails, then I'm out of ideas I am afraid.

               

              Good luck!


              Adrian

              • 4. Re: test failures during mvn package
                jemawa Community Member

                Thank you so much, that definitely got me further down past that error. However, are you supposed to run mvn -U clean compile everytime? Because when I go back to try simply mvn package, it gets stuck at the Ruleset API with the same error again. But also, when I run the mvn -U clean compile after I have already run it, it gets stuck at the As3 Parser API, saying that if failed to clean the project because it failed to delete the as3-parser-api-1.2.jar file.

                 

                Sorry for all the questions, like I said I am not very familiar with maven and such, but thank you so much again!

                 

                Jennifer

                • 5. Re: test failures during mvn package
                  jemawa Community Member

                  And I definitely meant mvn -U clean package, not mvn -U clean compile. whooops

                  • 6. Re: test failures during mvn package
                    Adrian Parker Community Member

                    Hi Jennifer

                     

                    the instructions for FlexPMD say we can use command

                     

                    mvn package

                     

                    I suggested mvn -U clean package in order to get Maven to reset itself with your JAR issue earlier. I don't know off hand why you would see an error when running mvn package but not see it when running mvn -U clean package...  can you post the error message?  Also can you post the error you see from the mvn -U clean package...

                     

                    also please can you include in those posts waht you see when you type each of these commands?

                     

                    mvn --version

                    svn --version

                    java -version

                     

                    I'm most of the way through a blog post detailing some helpful tips I have found with FlexPMD developer builds, when it is done I will drop a link here for you. It might help, I am not sure.

                    • 7. Re: test failures during mvn package
                      jemawa Community Member

                      Hey Adrian,

                       

                      Well of course I just ran mvn package this morning and it works without any errors. I am not sure why I works sometimes and others it does not. But here is what I get when I type the commands you asked me to type:

                       

                      C:\AndrewPMDSource\flex-pmd-java-parent>mvn --version
                      Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
                      Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.0.3-bin\a
                      pache-maven-3.0.3
                      Java version: 1.6.0_20, vendor: Sun Microsystems Inc.
                      Java home: C:\opt\isv\devtools\jdk1.6.0_20\jre
                      Default locale: en_US, platform encoding: Cp1252
                      OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

                       

                      C:\AndrewPMDSource\flex-pmd-java-parent>svn --version
                      svn, version 1.4.5 (r25188)
                         compiled Aug 22 2007, 20:49:04

                      Copyright (C) 2000-2006 CollabNet.
                      Subversion is open source software, see http://subversion.tigris.org/
                      This product includes software developed by CollabNet (http://www.Collab.Net/). following repository access (RA) modules are available:

                      The

                      * ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
                        - handles 'http' scheme
                        - handles 'https' scheme
                      * ra_svn : Module for accessing a repository using the svn network protocol.
                        - handles 'svn' scheme
                      * ra_local : Module for accessing a repository on local disk.
                        - handles 'file' scheme


                      C:\AndrewPMDSource\flex-pmd-java-parent>java --version
                      Unrecognized option: --version
                      Could not create the Java virtual machine.

                       

                      Thank you for all your help!