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

Unparseable date error thrown intermittently #691

Closed
realfaisalk opened this Issue Nov 16, 2016 · 8 comments

Comments

Projects
None yet
5 participants
@realfaisalk

realfaisalk commented Nov 16, 2016

Hi,

I am using Extent Reports v3.0.1 in Eclipse Neon.

It seems that after adding "htmlReporter.setAppendExisting(true);" programmatically (Is there a way to add the "appendexisitng" to the xml config file?) I am getting an intermittent error when running a TestNG suite where the following error appears:

"_

Nov 16, 2016 11:43:10 AM com.aventstack.extentreports.utils.DateUtil parse
SEVERE:
java.text.ParseException: Unparseable date: "16-Nov-2016 11:38:28"
at java.text.DateFormat.parse(Unknown Source)
at com.aventstack.extentreports.utils.DateUtil.parse(DateUtil.java:16)
at com.aventstack.extentreports.reporter.converters.ExtentHtmlTestConverter$TestParserUtils.getStartTime(ExtentHtmlTestConverter.java:138)
at com.aventstack.extentreports.reporter.converters.ExtentHtmlTestConverter.parseAndGetTest(ExtentHtmlTestConverter.java:68)
at com.aventstack.extentreports.reporter.converters.ExtentHtmlTestConverter.parseAndGetTests(ExtentHtmlTestConverter.java:50)
at com.aventstack.extentreports.reporter.converters.ExtentHtmlReporterConverter.parseAndGetModelCollection(ExtentHtmlReporterConverter.java:17)
at com.aventstack.extentreports.reporter.ExtentHtmlReporter.parseReportBuildTestCollection(ExtentHtmlReporter.java:111)
at com.aventstack.extentreports.reporter.ExtentHtmlReporter.start(ExtentHtmlReporter.java:102)
at com.aventstack.extentreports.Report.attach(Report.java:51)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at com.aventstack.extentreports.ExtentReports.attachReporter(ExtentReports.java:66)
at utilityFunctions.ExtentReporter.setExtent(ExtentReporter.java:21)
at automationFramework.Driver.BeforeSuite_Driver(Driver.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:307)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

_"
The generated html file after a "flush" is empty (0kb).

Nov 16, 2016 11:43:39 AM freemarker.log._JULLoggerFactory$JULLogger error
SEVERE: Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> test.startTime [in template "test-view/test-view.ftl" at line 105, column 76]


Tip: It's the step after the last dot that caused this error, not those before it.

Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??


FTL stack trace ("~" means nesting-related):

  • Failed at: ${test.startTime?datetime?string} [in template "test-view/test-view.ftl" at line 105, column 73]
  • Reached through: #include "test-view/test-view.ftl" [in template "index.ftl" at line 43, column 25]

Java stack trace (for programmers):

freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:131)
at freemarker.core.EvalUtil.coerceModelToString(EvalUtil.java:355)
at freemarker.core.Expression.evalAndCoerceToString(Expression.java:82)
at freemarker.core.BuiltInsForMultipleTypes$dateBI._eval(BuiltInsForMultipleTypes.java:226)
at freemarker.core.Expression.eval(Expression.java:78)
at freemarker.core.BuiltInsForMultipleTypes$stringBI._eval(BuiltInsForMultipleTypes.java:597)
at freemarker.core.Expression.eval(Expression.java:78)
at freemarker.core.Expression.evalAndCoerceToString(Expression.java:82)
at freemarker.core.DollarVariable.accept(DollarVariable.java:41)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
at freemarker.core.IteratorBlock$IterationContext.executeNestedBlockInner(IteratorBlock.java:268)
at freemarker.core.IteratorBlock$IterationContext.executeNestedBlock(IteratorBlock.java:220)
at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:194)
at freemarker.core.Environment.visitIteratorBlock(Environment.java:572)
at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:78)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:64)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.Environment.include(Environment.java:2072)
at freemarker.core.Include.accept(Include.java:167)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.Environment.process(Environment.java:302)
at freemarker.template.Template.process(Template.java:325)
at com.aventstack.extentreports.reporter.ExtentHtmlReporter.flush(ExtentHtmlReporter.java:141)
at java.util.ArrayList.forEach(Unknown Source)
at com.aventstack.extentreports.Report.notifyReporters(Report.java:210)
at com.aventstack.extentreports.Report.flush(Report.java:132)
at com.aventstack.extentreports.ExtentReports.flush(ExtentReports.java:261)
at automationFramework.Driver.AfterSuite(Driver.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:338)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

Nov 16, 2016 11:43:39 AM com.aventstack.extentreports.reporter.ExtentHtmlReporter flush
SEVERE: Template not found
FreeMarker template error:
The following has evaluated to null or missing:
==> test.startTime [in template "test-view/test-view.ftl" at line 105, column 76]


Tip: It's the step after the last dot that caused this error, not those before it.

Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??


FTL stack trace ("~" means nesting-related):

  • Failed at: ${test.startTime?datetime?string} [in template "test-view/test-view.ftl" at line 105, column 73]
  • Reached through: #include "test-view/test-view.ftl" [in template "index.ftl" at line 43, column 25]

Java stack trace (for programmers):

freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:131)
at freemarker.core.EvalUtil.coerceModelToString(EvalUtil.java:355)
at freemarker.core.Expression.evalAndCoerceToString(Expression.java:82)
at freemarker.core.BuiltInsForMultipleTypes$dateBI._eval(BuiltInsForMultipleTypes.java:226)
at freemarker.core.Expression.eval(Expression.java:78)
at freemarker.core.BuiltInsForMultipleTypes$stringBI._eval(BuiltInsForMultipleTypes.java:597)
at freemarker.core.Expression.eval(Expression.java:78)
at freemarker.core.Expression.evalAndCoerceToString(Expression.java:82)
at freemarker.core.DollarVariable.accept(DollarVariable.java:41)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
at freemarker.core.IteratorBlock$IterationContext.executeNestedBlockInner(IteratorBlock.java:268)
at freemarker.core.IteratorBlock$IterationContext.executeNestedBlock(IteratorBlock.java:220)
at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:194)
at freemarker.core.Environment.visitIteratorBlock(Environment.java:572)
at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:78)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:64)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.Environment.include(Environment.java:2072)
at freemarker.core.Include.accept(Include.java:167)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.Environment.process(Environment.java:302)
at freemarker.template.Template.process(Template.java:325)
at com.aventstack.extentreports.reporter.ExtentHtmlReporter.flush(ExtentHtmlReporter.java:141)
at java.util.ArrayList.forEach(Unknown Source)
at com.aventstack.extentreports.Report.notifyReporters(Report.java:210)
at com.aventstack.extentreports.Report.flush(Report.java:132)
at com.aventstack.extentreports.ExtentReports.flush(ExtentReports.java:261)
at automationFramework.Driver.AfterSuite(Driver.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:338)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

Nov 16, 2016 11:43:39 AM com.aventstack.extentreports.utils.Writer write
SEVERE: .\extentreport.html
java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at com.aventstack.extentreports.utils.Writer.write(Writer.java:23)
at com.aventstack.extentreports.reporter.ExtentHtmlReporter.flush(ExtentHtmlReporter.java:150)
at java.util.ArrayList.forEach(Unknown Source)
at com.aventstack.extentreports.Report.notifyReporters(Report.java:210)
at com.aventstack.extentreports.Report.flush(Report.java:132)
at com.aventstack.extentreports.ExtentReports.flush(ExtentReports.java:261)
at automationFramework.Driver.AfterSuite(Driver.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:338)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

@anshooarora

This comment has been minimized.

Show comment
Hide comment
@anshooarora

anshooarora Nov 17, 2016

Owner

Can you share a small sample to repro this?

Enhancement: I will add a way to append via config.xml. Can you open a new issue for this so its easily trackable?

Owner

anshooarora commented Nov 17, 2016

Can you share a small sample to repro this?

Enhancement: I will add a way to append via config.xml. Can you open a new issue for this so its easily trackable?

@realfaisalk

This comment has been minimized.

Show comment
Hide comment
@realfaisalk

realfaisalk Nov 23, 2016

Hi,

sorry for the late reply.

This is the method in a class:

private static ExtentHtmlReporter getHtmlReporter(String ConfigFile) {
		try{
			//Set the filepath of the Extent html report
	        htmlReporter = new ExtentHtmlReporter(filePath);
			
	        //htmlReporter.loadXMLConfig("./Extent_Regression_Config.xml");
	        htmlReporter.loadXMLConfig("./" + ConfigFile);
	        //Append to existing report 
	        htmlReporter.setAppendExisting(true);

	        return htmlReporter;
		}
		catch (Exception e) {
			return null;
		}
	}

This is the config file:

<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
    <configuration>
        <!-- report theme -->
        <!-- standard, dark -->
        <theme>standard</theme>
    
        <!-- document encoding -->
        <!-- defaults to UTF-8 -->
        <encoding>UTF-8</encoding>
        
        <!-- protocol for script and stylesheets -->
        <!-- defaults to https -->
        <protocol>https</protocol>
        
        <!-- title of the document -->
        <documentTitle>HRE Virdict Automation Report</documentTitle>
        
        <!-- report name - displayed at top-nav -->
        <reportName>Smoke Test Pack</reportName>
        
        <!-- location of charts in the test view -->
        <!-- top, bottom -->
        <testViewChartLocation>bottom</testViewChartLocation>
        
        <!-- custom javascript -->
        <scripts>
            <![CDATA[
                $(document).ready(function() {
                    
                });
            ]]>
        </scripts>
        
        <!-- custom styles -->
        <styles>
            <![CDATA[
                
            ]]>
        </styles>
    </configuration>
</extentreports>

realfaisalk commented Nov 23, 2016

Hi,

sorry for the late reply.

This is the method in a class:

private static ExtentHtmlReporter getHtmlReporter(String ConfigFile) {
		try{
			//Set the filepath of the Extent html report
	        htmlReporter = new ExtentHtmlReporter(filePath);
			
	        //htmlReporter.loadXMLConfig("./Extent_Regression_Config.xml");
	        htmlReporter.loadXMLConfig("./" + ConfigFile);
	        //Append to existing report 
	        htmlReporter.setAppendExisting(true);

	        return htmlReporter;
		}
		catch (Exception e) {
			return null;
		}
	}

This is the config file:

<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
    <configuration>
        <!-- report theme -->
        <!-- standard, dark -->
        <theme>standard</theme>
    
        <!-- document encoding -->
        <!-- defaults to UTF-8 -->
        <encoding>UTF-8</encoding>
        
        <!-- protocol for script and stylesheets -->
        <!-- defaults to https -->
        <protocol>https</protocol>
        
        <!-- title of the document -->
        <documentTitle>HRE Virdict Automation Report</documentTitle>
        
        <!-- report name - displayed at top-nav -->
        <reportName>Smoke Test Pack</reportName>
        
        <!-- location of charts in the test view -->
        <!-- top, bottom -->
        <testViewChartLocation>bottom</testViewChartLocation>
        
        <!-- custom javascript -->
        <scripts>
            <![CDATA[
                $(document).ready(function() {
                    
                });
            ]]>
        </scripts>
        
        <!-- custom styles -->
        <styles>
            <![CDATA[
                
            ]]>
        </styles>
    </configuration>
</extentreports>
@realfaisalk

This comment has been minimized.

Show comment
Hide comment
@realfaisalk

realfaisalk Nov 23, 2016

If I comment out the line "htmlReporter.setAppendExisting(true);" then I do not get the issue

realfaisalk commented Nov 23, 2016

If I comment out the line "htmlReporter.setAppendExisting(true);" then I do not get the issue

@sukhjinderkahlon

This comment has been minimized.

Show comment
Hide comment
@sukhjinderkahlon

sukhjinderkahlon Dec 17, 2016

I am also facing the same issue. Is there any solution or trick to bypass this error. As I need two report one needs to preserve history.

sukhjinderkahlon commented Dec 17, 2016

I am also facing the same issue. Is there any solution or trick to bypass this error. As I need two report one needs to preserve history.

@anshooarora

This comment has been minimized.

Show comment
Hide comment
@anshooarora

anshooarora Dec 28, 2016

Owner

How did you manage to get the data in the format 16-Nov-2016 11:38:28? The default format should be Oct 14, 2016 10:47:05 AM.

Owner

anshooarora commented Dec 28, 2016

How did you manage to get the data in the format 16-Nov-2016 11:38:28? The default format should be Oct 14, 2016 10:47:05 AM.

@jtolotta

This comment has been minimized.

Show comment
Hide comment
@jtolotta

jtolotta Feb 14, 2017

@sukhjinderkahlon, @anshooarora

I resolved this issue by setting theLocalebefore attaching theExtentHtmlReporterinstance to theExtentReportsobject.

Code below:

extentReport = new ExtentReports();
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(new File("path/to/results.html"));

htmlReporter.setAppendExisting(true);

// Required to parse the start and end times in the HTML report.
Locale.setDefault(Locale.ENGLISH);

extentReport.attachReporter(htmlReporter);

jtolotta commented Feb 14, 2017

@sukhjinderkahlon, @anshooarora

I resolved this issue by setting theLocalebefore attaching theExtentHtmlReporterinstance to theExtentReportsobject.

Code below:

extentReport = new ExtentReports();
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(new File("path/to/results.html"));

htmlReporter.setAppendExisting(true);

// Required to parse the start and end times in the HTML report.
Locale.setDefault(Locale.ENGLISH);

extentReport.attachReporter(htmlReporter);
@anshooarora

This comment has been minimized.

Show comment
Hide comment
@anshooarora

anshooarora Feb 27, 2017

Owner

@jtolotta - Thanks for sharing this fix, I will make it a default setting for the HTML report.

Owner

anshooarora commented Feb 27, 2017

@jtolotta - Thanks for sharing this fix, I will make it a default setting for the HTML report.

@sukhjindersukh

This comment has been minimized.

Show comment
Hide comment
@sukhjindersukh

sukhjindersukh Mar 1, 2017

@jtolotta Thanks for your help. You are a life saver.

sukhjindersukh commented Mar 1, 2017

@jtolotta Thanks for your help. You are a life saver.

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