11

I use allure-maven plugin configured in my POM. However, when it fails with

ru.yandex.qatools.allure.data.ReportGenerationException: Could not find any allure results

I would like to debug the plugin at runtime to see if it has all variables set properly.

I have tried to use mvnDebug as per answers to Debugging in Maven?. I am able to connect with a debugger to JVM when Maven executes tests with surefire plugin. However, when Maven tries to generate Allure report with allure plugin I am not able to connect with a debugger. Allure plugin is defined in "reporting" section of the POM and used by the "site" Maven goal.

Here's POM (almost complete, I ommited dependenies section) that I call with mvn clean test site command.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://maven.apache.org/POM/4.0.0"
             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>

    ...  

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                    <argLine>-Xmx2048m -XX:-UseSplitVerifier -XX:MaxPermSize=256m
                        -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                    </argLine>
                    <properties>
                        <property>
                            <name>parallel</name>
                            <value>classes</value>
                        </property>
                        <property>
                            <name>threadcount</name>
                            <value>4</value>
                        </property>
                    </properties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>


    <reporting>
        <excludeDefaults>true</excludeDefaults>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.19.1</version>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.8</version>
                <configuration>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

    <pluginRepositories>
        <pluginRepository>
            <id>mvn-nexus-all</id>
            <url>https://lunabuild.akamai.com/nexus/content/groups/public/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

And here's full stacktrace from the failing plugin:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project sso-config-tests: Error during page generation: Error rendering Maven report: Could not generate the report: InvocationTargetException: Could not find any allure results -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project sso-config-tests: Error during page generation
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error during page generation
        at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:143)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 20 more
Caused by: org.apache.maven.doxia.siterenderer.RendererException: Error rendering Maven report: Could not generate the report
        at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:233)
        at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:319)
        at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:135)
        at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:175)
        at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:138)
        ... 22 more
Caused by: org.apache.maven.reporting.MavenReportException: Could not generate the report
        at ru.yandex.qatools.allure.report.AllureGenerateMojo.executeReport(AllureGenerateMojo.java:127)
        at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:255)
        at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:219)
        ... 26 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at ru.yandex.qatools.allure.report.AllureGenerateMojo.executeReport(AllureGenerateMojo.java:123)
        ... 28 more
Caused by: ru.yandex.qatools.allure.data.ReportGenerationException: Could not find any allure results
        at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureReportGenerator.java:58)
        at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureReportGenerator.java:53)
        at ru.yandex.qatools.allure.AllureMain.main(AllureMain.java:48)
        ... 33 more
dzieciou
  • 4,049
  • 8
  • 41
  • 85
  • Where the plugin defined which you like to to debug? – khmarbaise Sep 07 '17 at 16:45
  • @khmarbaise The plugin is defined in POM file. – dzieciou Sep 07 '17 at 16:47
  • In which pom file? I don't see maven-surefire-plugin etc. but I assume I don't see the plugin which you like to run tests against? Furthermore a full pom file or better a complete example project for example on github would help more to see what the issue is? – khmarbaise Sep 07 '17 at 16:49
  • Great...Just fine... – khmarbaise Sep 07 '17 at 17:03
  • @khmarbaise I have provide more complete POM and more explanation. Does it make more sense now? – dzieciou Sep 08 '17 at 08:52
  • Are you sure that it is correct POM/exception? The exception says that error at `ru.yandex.qatools.allure.report.AllureGenerateMojo.executeReport`, but in your pom I can see `io.qameta.allure:allure-maven` plugin. This is a brand new plugin that have other packages (io.qameta.allure instead of ru.yandex.qatools). – Dmitry Baev Sep 11 '17 at 15:07
  • @DmitryBaev I was using two versions of allure-maven plugin 2.6 (in child pom) and 2.8 (in parent pom) which were conflicting. I removed one and it works fine. However, the question was about debuging a reporting plugin which is still not possible so I will keep the question open. – dzieciou Sep 11 '17 at 15:26
  • 1
    Adding information to the accepted answer, when you use ```mvnDebug``` and you want to connect with eclipse, you need to create a Remote Java Application from the Debug configurations and then provide the project along with the same port number where mvnDebug is waiting on. https://doc.nuxeo.com/corg/how-to-debug-a-test-run-with-maven/ – sunder Dec 23 '22 at 09:58

3 Answers3

21

If you start your build with mvnDebug clean install instead of mvn clean install Maven will wait for a remote debugger to connect on port 8000. This should work for all plugin that do not run in their own JVM.

This requires Maven greater than 2.0.8 which I assume you are running.

See Debugging in Maven?

Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
fhossfel
  • 2,041
  • 16
  • 24
  • Unfortunately it did not stop at the break point in the plugin after connecting to it. Yes, I am using Maven 3.3.1 – dzieciou Sep 07 '17 at 15:25
  • Are you sure you have the exact source of the plugin? I suggest you set a break point on class level. – fhossfel Sep 07 '17 at 15:27
  • I set break point on class level. The maven process fails with `JDWP exit error JVMTI_ERROR_WRONG_PHASE(112): on getting class status [util.c:1285] JDWP exit error JVMTI_ERROR_INVALID_ENVIRONMENT(116): Can't allocate jvmti memory [util.c:1799] ERROR: JDWP unable to dispose of JVMTI environment: JVMTI_ERROR_INVALID_ENVIRONMENT(116) FATAL ERROR in native method: JDWP Can't allocate jvmti memory, jvmtiError=JVMTI_ERROR_INVALID_ENVIRONMENT(116) /usr/local/bin/mvnDebug: line 41: 16470 Abort trap: 6 env MAVEN_OPTS="$MAVEN_OPTS $MAVEN_DEBUG_OPTS" $(dirname $0)/mvn "$@" ` – dzieciou Sep 08 '17 at 09:17
  • 1
    That is a big in the JDK[1]. The bug report states an intention to back port that fix to > Java 8.40 but I am not sure this has ever happened. [1] https://bugs.openjdk.java.net/browse/JDK-6988950 – fhossfel Sep 08 '17 at 09:27
  • 1
    What do I connect to port 8000 with? What remote debugger? – Gerry Jan 19 '22 at 18:10
  • If you want to configure it with eclipse, you need to start remote application in eclipse on the same port https://doc.nuxeo.com/corg/how-to-debug-a-test-run-with-maven/ – sunder Dec 23 '22 at 09:56
1

If you want to debug it from Intellij IDEA. I assume that you run bundled mvn, JDK9+

  1. Go to Maven Runner settings in IDEA.
  2. In VM Options specify this line: -agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=y

Maven will not proceed up to the moment you connect with remote debugger.

  1. Create Remote debugger configuration (specify port 5005).
  2. Run remote debugger (do not forget to add breakpoints in code).
-1

Instead of allure-maven plugin debugging, you may want to fix configuration issues first. You've put plugin into wrong pom's section. See official plugin's docs.

Allure 2 doesn't use reporting part anymore. You should put plugin into build section.

Report generation command is updated as well. Instead of a site goal calling, you should use the following:

mvn allure:report
mvn allure:serve

Check this example to get an idea about valid configuration.

Serhii Korol
  • 843
  • 7
  • 15