damianszczepanik / cucumber-reporting

HTML reports for Cucumber
GNU Lesser General Public License v2.1
548 stars 403 forks source link

java.lang.NoSuchMethodError: org.apache.commons.lang3.StringUtils.wrap #483

Closed Hemantp81 closed 8 years ago

Hemantp81 commented 8 years ago

Using

Jenkins : ver. 2.10 Cucumber-jvm reports : ver. 2.5.0

and once my tests executed I see below exception ,I did check the plug-in has the correct set of commons-lang3-3.4.jar . please let me know if you need more details.

[CucumberReportPublisher] 1. Found a json file: cucumber-calculator.json [CucumberReportPublisher] Generating HTML reports ERROR: Step ‘Cucumber-JVM reports’ aborted due to exception: java.lang.NoSuchMethodError: org.apache.commons.lang3.StringUtils.wrap(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; at net.masterthought.cucumber.generators.TagsOverviewPage.generateTagLabels(TagsOverviewPage.java:48) at net.masterthought.cucumber.generators.TagsOverviewPage.prepareReport(TagsOverviewPage.java:39) at net.masterthought.cucumber.generators.AbstractPage.generatePage(AbstractPage.java:52) at net.masterthought.cucumber.ReportBuilder.generateAllPages(ReportBuilder.java:105) at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:54) at net.masterthought.jenkins.CucumberReportPublisher.perform(CucumberReportPublisher.java:134) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720) at hudson.model.Build$BuildExecution.post2(Build.java:185) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665) at hudson.model.Run.execute(Run.java:1745) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410)

damianszczepanik commented 8 years ago

I'm not able to reproduce it so I won't be able to fix it

Hemantp81 commented 8 years ago

added commons-lang3 4. jar to jenkins lib folder and now the issue is gone.Jenkins version 2.10 has Commons Lang 2.6 packaged which does not have <StringUtils.wrap()> thanks for looking into it.

damianszczepanik commented 8 years ago

@daniel-beck Any idea what could be wrong with that code? The problem happens in https://github.com/damianszczepanik/cucumber-reporting/blob/82fb0ea1831ac3d18c68d6bfeba6798c16d340bc/src/main/java/net/masterthought/cucumber/generators/TagsOverviewPage.java#L48 but as we see this code is executed during tests https://codecov.io/gh/damianszczepanik/cucumber-reporting/src/4365ae1de0f0738498b52e1e1bf82066a01db3e5/src/main/java/net/masterthought/cucumber/generators/TagsOverviewPage.java#L48 so wrong reference should cause failure during the tests. So it looks to me that there is something wrong between plugin and Jenkins as @Hemantp81 reported. Also his hot patch fixes the problem. It does not happen to me when using the most recent Jenkins release.

daniel-beck commented 8 years ago

Core leaks its library dependencies to plugins, so if a version of that class without the method exists in core, that gets picked up by the plugin.

I'd try to use the PluginFirstClassLoader in the hopes that this would resolve the problem. https://jenkinsci.github.io/maven-hpi-plugin/hpi-mojo.html#pluginFirstClassLoader

Alternatively -- maskClasses perhaps? https://jenkinsci.github.io/maven-hpi-plugin/hpi-mojo.html#maskClasses