java.lang.NoClassDefFoundError: freemarker/template/TemplateModelException

て烟熏妆下的殇ゞ 提交于 2019-12-25 08:57:16

问题


Tried to create advanced HTML reports using extentReports jar, but it is throwing below error.

java.lang.NoClassDefFoundError: freemarker/template/TemplateModelException

Code:

public class XtentReport { 
   WebDriver driver; 
   ExtentReports report; 
   ExtentTest logger; 

@Test public void verifyXReport() { 
   report = new ExtentReports("D:\\Selenium_Reports\\AdvanceReport.html"); 
   logger=report.startTest("StartingTC"); driver= new FirefoxDriver();
   driver.manage().window().maximize(); logger.log(LogStatus.INFO,"Browser is up and running"); 
   driver.get("google.com"); 
   logger.log(LogStatus.PASS,"Test completed"); report.endTest(logger); 
   report.flush(); 
   } 
 } 

回答1:


Maven: If maven is used as a build tool then just add the below dependency

<dependency>
    <groupId>org.freemarker</groupId>
    <artifactId>freemarker</artifactId>
    <version>2.3.23</version>
</dependency>

No Maven: If maven is not used, add the below jar to the classpath.

Download freemarker-2.3.23.jar from the below link. http://central.maven.org/maven2/org/freemarker/freemarker/2.3.23/freemarker-2.3.23.jar

If a different version is needed then use the below link and choose the version needed. http://central.maven.org/maven2/org/freemarker/freemarker




回答2:


You need to add the freemarker-<version>.jar to yor classpath.




回答3:


If someone came here because have this same error using XDocReport, pay attention that it's just a WARN :).



来源:https://stackoverflow.com/questions/38221933/java-lang-noclassdeffounderror-freemarker-template-templatemodelexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!