Skip navigation
jemawa
Currently Being Moderated

test failures during mvn package

Jun 20, 2011 11:37 AM

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-resourc es
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

 

 
Replies
  • Currently Being Moderated
    Jul 5, 2011 8:53 AM   in reply to jemawa

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2011 1:14 AM   in reply to jemawa

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2011 3:54 AM   in reply to jemawa

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points