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

Merging of 2 html spark reports #331

Closed
ashanirmala7 opened this issue Nov 2, 2021 · 8 comments
Closed

Merging of 2 html spark reports #331

ashanirmala7 opened this issue Nov 2, 2021 · 8 comments

Comments

@ashanirmala7
Copy link

Dear team, I would like to combine the current run html results with the previous run file. I tried the options given in the docs as

ExtentSparkReporter spark = new ExtentSparkReporter("spark.html");
JsonFormatter json = new JsonFormatter("extent.json");
ExtentReports extent = new ExtentReports();
extent.createDomainFromJsonArchive("extent.json");
extent.attachReporter(json, spark);

But i am getting the below error- Could you please help me on this.

java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.lang.Throwable.detailMessage accessible: module java.base does not "opens java.lang" to unnamed module @13c27452
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.Gson.fromJson(Gson.java:931)
at com.google.gson.Gson.fromJson(Gson.java:897)
at com.google.gson.Gson.fromJson(Gson.java:846)
at com.aventstack.extentreports.append.JsonDeserializer.deserialize(JsonDeserializer.java:30)
at com.aventstack.extentreports.append.RawEntityConverter.convertAndApply(RawEntityConverter.java:27)
at com.aventstack.extentreports.AbstractProcessor.convertRawEntities(AbstractProcessor.java:98)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:372)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:387)
at common.utility.ExtentReportUtil.createReport(ExtentReportUtil.java:64)

@fatcatpl-sub
Copy link

fatcatpl-sub commented Sep 13, 2023

Hi, did anyone come up with a workaround for this one? I happened upon it yesterday after update from jdk 11 to 17, and nothing seems to work. What am I missing? Any suggestion appreciated... Attaching pom (txt version) & stacktrace below

    ExtentSparkReporter spark = new ExtentSparkReporter("Report.html");
    JsonFormatter json = new JsonFormatter("Report.json");
    spark.loadXMLConfig(new File("src\\main\\resources\\extent.xml"));
    ExtentReports extent = new ExtentReports();
    extent.createDomainFromJsonArchive("Report.json");
    extent.attachReporter(json, spark);

error:

java.lang.ExceptionInInitializerError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:250)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:260)
at org.junit.runners.BlockJUnit4ClassRunner$2.runReflectiveCall(BlockJUnit4ClassRunner.java:309)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: com.google.gson.JsonIOException: Failed making field 'java.lang.Throwable#detailMessage' accessible; either change its visibility or write a custom TypeAdapter for its declaring type
at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:22)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:158)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:116)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:165)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:116)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:165)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:116)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:165)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.Gson.fromJson(Gson.java:990)
at com.google.gson.Gson.fromJson(Gson.java:956)
at com.google.gson.Gson.fromJson(Gson.java:905)
at com.aventstack.extentreports.append.JsonDeserializer.deserialize(JsonDeserializer.java:30)
at com.aventstack.extentreports.append.RawEntityConverter.convertAndApply(RawEntityConverter.java:27)
at com.aventstack.extentreports.AbstractProcessor.convertRawEntities(AbstractProcessor.java:108)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:372)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:387)

pom.txt

@anshooarora
Copy link
Member

@fatcatpl-sub Was it working prior to the upgrade?

@fatcatpl-sub
Copy link

@anshooarora yeah, works fine with jdk 11. Unfortunately we're moving to jdk 17, so going back is not an option. Also, reports work fine if you remove the option co combine them into one html, as in:

ExtentSparkReporter spark = new ExtentSparkReporter("spark.html");
ExtentReports extent = new ExtentReports();
extent.attachReporter(spark);

That part is alright. All fails during json deserialization. And without it, with e2e pipelines containing whole sets of classes, we either end up with dozen report files per test run or one, with last method performed only.
I'm still wondering if anyone else can reproduce that, as I only managed to find this issue report here and one on Stack, or if I'm missing something and it's a problem on my side, but I can't think of anything else.

@anshooarora
Copy link
Member

Thanks for the details. Do see a possible fix Gson library fix available (below), will look into it.

Gson: google/gson#1979

@anshooarora
Copy link
Member

Spent some time on this today - and have found out the issue. It's not a trivial fix but I will try to complete this task by sometime next week.

@anshooarora
Copy link
Member

This change is available starting the current SNAPSHOT:

https://oss.sonatype.org/content/repositories/snapshots/com/aventstack/extentreports/5.1.1-SNAPSHOT/

<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.1.1-SNAPSHOT</version>

@fatcatpl-sub Can you please check if this works with your current setup?

@fatcatpl-sub
Copy link

@anshooarora I can confirm the change works correctly with my setup.

I installed .jar in my local maven repo, ran a few test classes - both .html and .json were created successfully with all data intact. HTML file contained all reports generated during tests.
Let me know if you have any additional questions. And thank you very much!

@anshooarora
Copy link
Member

@fatcatpl-sub thank you for checking, much appreciated! I will include this fix as part of the next release.

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

No branches or pull requests

3 participants