Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassNotFoundException thrown for each custom error class by serenity:aggregate #3102

Open
Rangiferus opened this issue Mar 28, 2023 · 10 comments

Comments

@Rangiferus
Copy link

While generating the report serenity:aggregate throws this exception for every error class defined within the project.
It doesn't happen for earlier Serenity versions ().
This exception is thrown multiple times for each custom class extending RuntimeException found in the project, also when none of them was executed during the test run.

[WARNING] Could not find error class: my.project.exceptions.ErrorConnectivity(my.project.exceptions.ErrorConnectivity)
java.lang.ClassNotFoundException: my.project.exceptions.ErrorConnectivity
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:315)
    at net.thucydides.core.model.failures.FailureAnalysisConfiguration.typesDefinedIn (FailureAnalysisConfiguration.java:146)
    at net.thucydides.core.model.failures.FailureAnalysisConfiguration.compromisedTypesDefinedIn (FailureAnalysisConfiguration.java:129)
    at net.thucydides.core.model.failures.FailureAnalysisConfiguration.pendingTypes (FailureAnalysisConfiguration.java:85)
    at net.thucydides.core.model.failures.FailureAnalysis.reportAsPending (FailureAnalysis.java:111)
    at net.thucydides.core.model.failures.FailureAnalysis.resultFor (FailureAnalysis.java:44)
    at net.thucydides.core.model.TestOutcome.testResultFromFailureClassname (TestOutcome.java:1473)
    at net.thucydides.core.model.TestOutcome.getResult (TestOutcome.java:1461)
    at net.serenitybdd.reports.model.ScenarioSummary$Companion.ofFailingScenariosIn (ScenarioSummary.kt:30)
    at net.serenitybdd.reports.model.FrequentFailuresBuilder.withMaxOf (FrequentFailures.kt:21)
    at net.thucydides.core.reports.html.HtmlAggregateStoryReporter.generateReportsForTestResultsIn (HtmlAggregateStoryReporter.java:208)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
@wakaleo
Copy link
Member

wakaleo commented Mar 28, 2023

This is the way Maven works. Plugins do not have access to application code unless you explicitly add a dependency to your project in the plugin dependencies. This is why the aggregate plugin cannot find the custom exception class.

@Rangiferus
Copy link
Author

This doesn't explain why it doesn't throw this exception in all previous versions before 3.4.3.

@wakaleo
Copy link
Member

wakaleo commented Mar 28, 2023

I don't know, maybe due to the Maven API version updates used in the plugin.

@Rangiferus
Copy link
Author

Which plugin is suspected here?

@wakaleo
Copy link
Member

wakaleo commented Mar 28, 2023

You need to add your project dependencies to the maven-serenity-plugin, e.g.

            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>${serenity.version}</version>
                <configuration>
                    <tags>${tags}</tags>
                    <reports>single-page-html</reports>
                </configuration>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>net.serenity-bdd</groupId>
                        <artifactId>serenity-single-page-report</artifactId>
                        <version>${serenity.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

@Rangiferus
Copy link
Author

Doesn't it require a jar file created out of the project code?

[ERROR] Failed to execute goal net.serenity-bdd.maven.plugins:serenity-maven-plugin:3.6.21:aggregate (default-cli) on project project: Execution default-cli of goal net.serenity-bdd.maven.plugins:serenity-maven-plugin:3.6.21:aggregate failed: Plugin net.serenity-bdd.maven.plugins:serenity-maven-plugin:3.6.21 or one of its dependencies could not be resolved: Could not find artifact my:project:jar:0.0.1-SNAPSHOT -> [Help 1]                                                                              

@wakaleo
Copy link
Member

wakaleo commented Mar 28, 2023

No

@Rangiferus
Copy link
Author

but this is what it outputs when executed - it complains about missing jar

Plugin net.serenity-bdd.maven.plugins:serenity-maven-plugin:3.6.21 or one of its dependencies could not be resolved: Could not find artifact x.y.z:project_name:jar:0.0.1-SNAPSHOT

@wakaleo
Copy link
Member

wakaleo commented Mar 28, 2023

Have a look at https://stackoverflow.com/questions/21270009/when-does-a-maven-plugin-have-access-to-the-projects-classes

@Rangiferus
Copy link
Author

Unfortunately this link doesn't help me.
serenity:aggregate worked properly and didn't complain about missing exception classes when Serenity ver. 3.4.2 came in with changed behavior. Now, adding the suggested dependency to serenity-maven-plugin only makes it fail and does not help.
I still have no idea what to do to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants