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

Cannot find serializer. Please set the template engine FieldsMetadata#setTemplateEngineKind(String templateEngineKind) before calling this method. #2

Open
saru17 opened this issue Dec 27, 2016 · 1 comment

Comments

@saru17
Copy link

saru17 commented Dec 27, 2016

Hi,

My code :
InputStream in = new FileInputStream("DocxProjectWithVelocityList.docx");

/* InputStream in = DocxProjectWithVelocityList2PDF.class
.getResourceAsStream("DocxProjectWithVelocityList.docx");*/
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(
in, TemplateEngineKind.Velocity);

		// 2) Create fields metadata to manage lazy loop (#foreach velocity) for table row.
        FieldsMetadata metadata = report.createFieldsMetadata();
		// Old API 
        /*
        metadata.addFieldAsList("developers.Name");
		metadata.addFieldAsList("developers.LastName");
		metadata.addFieldAsList("developers.Mail");
		*/
        // NEW API
		metadata.load( "developers", Developer.class, true );
		
		// 3) Create context Java model
		IContext context = report.createContext();
		// Register project
		Project project = new Project("XDocReport");

I am facing exception below 👍

Exception:

java.lang.NoClassDefFoundError: org/apache/velocity/context/Context
at fr.opensagres.xdocreport.template.velocity.discovery.VelocityTemplateEngineDiscovery.createTemplateEngine(VelocityTemplateEngineDiscovery.java:51)
at fr.opensagres.xdocreport.template.registry.TemplateEngineRegistry.registerInstance(TemplateEngineRegistry.java:78)
at fr.opensagres.xdocreport.template.registry.TemplateEngineRegistry.registerInstance(TemplateEngineRegistry.java:42)
at fr.opensagres.xdocreport.core.registry.AbstractRegistry.initializeIfNeeded(AbstractRegistry.java:76)
at fr.opensagres.xdocreport.template.registry.TemplateEngineRegistry.getTemplateEngineKinds(TemplateEngineRegistry.java:118)
at fr.opensagres.xdocreport.document.registry.TemplateEngineInitializerRegistry.onEndInitialization(TemplateEngineInitializerRegistry.java:166)
at fr.opensagres.xdocreport.core.registry.AbstractRegistry.initializeIfNeeded(AbstractRegistry.java:87)
at fr.opensagres.xdocreport.document.registry.TemplateEngineInitializerRegistry.getTemplateEngine(TemplateEngineInitializerRegistry.java:84)
at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:339)
at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:317)
at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:302)
at fr.opensagres.xdocreport.samples.docxandvelocity.DocxProjectWithVelocityList2PDF.main(DocxProjectWithVelocityList2PDF.java:204)
Caused by: java.lang.ClassNotFoundException: org.apache.velocity.context.Context
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 12 more
Dec 27, 2016 1:22:51 PM fr.opensagres.xdocreport.core.registry.AbstractRegistry initializeIfNeeded
WARNING: Error while registration of Discovery instance fr.opensagres.xdocreport.template.freemarker.discovery.FreemarkerTemplateEngineDiscovery@9d04653
java.lang.NoClassDefFoundError: freemarker/template/ObjectWrapper
at fr.opensagres.xdocreport.template.freemarker.discovery.FreemarkerTemplateEngineDiscovery.createTemplateEngine(FreemarkerTemplateEngineDiscovery.java:42)
at fr.opensagres.xdocreport.template.registry.TemplateEngineRegistry.registerInstance(TemplateEngineRegistry.java:78)
at fr.opensagres.xdocreport.template.registry.TemplateEngineRegistry.registerInstance(TemplateEngineRegistry.java:42)
at fr.opensagres.xdocreport.core.registry.AbstractRegistry.initializeIfNeeded(AbstractRegistry.java:76)
at fr.opensagres.xdocreport.template.registry.TemplateEngineRegistry.getTemplateEngineKinds(TemplateEngineRegistry.java:118)
at fr.opensagres.xdocreport.document.registry.TemplateEngineInitializerRegistry.onEndInitialization(TemplateEngineInitializerRegistry.java:166)
at fr.opensagres.xdocreport.core.registry.AbstractRegistry.initializeIfNeeded(AbstractRegistry.java:87)
at fr.opensagres.xdocreport.document.registry.TemplateEngineInitializerRegistry.getTemplateEngine(TemplateEngineInitializerRegistry.java:84)
at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:339)
at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:317)
at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:302)
at fr.opensagres.xdocreport.samples.docxandvelocity.DocxProjectWithVelocityList2PDF.main(DocxProjectWithVelocityList2PDF.java:204)
Caused by: java.lang.ClassNotFoundException: freemarker.template.ObjectWrapper
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 12 more
fr.opensagres.xdocreport.core.XDocReportException: Cannot find serializer. Please set the template engine FieldsMetadata#setTemplateEngineKind(String templateEngineKind) before calling this method.
at fr.opensagres.xdocreport.template.formatter.FieldsMetadata.load(FieldsMetadata.java:568)
at fr.opensagres.xdocreport.samples.docxandvelocity.DocxProjectWithVelocityList2PDF.main(DocxProjectWithVelocityList2PDF.java:216)

@angelozerr
Copy link
Member

You need Velocity JAR and their dependencies in your classpath.

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

2 participants