Dear Support,
I get following exception in LINQ Template: "Error! Can not resolve
method ‘getResourceAsStream’ on type ‘class c.v.s.b.g.DocumentGenerator’ running Spring Boot application
on Java 16 or 17.
On Java 15 it works like expected.
It seems like a bug, but could you please check?
Template:
<< doc [DocumentGenerator.getResourceAsStream("sub-document.docx")] -build -sourceStyles >>
DocumentGenerator class:
public class DocumentGenerator {
public static InputStream getResourceAsStream(String path) throws IOException {
final ClassPathResource classPathResource = new ClassPathResource(path);
return classPathResource.getInputStream();
}
}
Engine execution code:
Document doc = new Document(documentResourceStream);
ReportingEngine engine = new ReportingEngine();
engine.getKnownTypes().add(DocumentGenerator.class);
engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS + ReportBuildOptions.INLINE_ERROR_MESSAGES + ReportBuildOptions.REMOVE_EMPTY_PARAGRAPHS);
XmlDataSource dbConstants = new XmlDataSource(getResourceAsStream("doc.xml"));
if (engine.buildReport(doc, dbConstants)) {
LOGGER.info("Document generated successfully!");
} else {
LOGGER.error("Document generation failed! Please check the generated document for inlined error message!");
};
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
doc.save(byteArrayOutputStream, SaveFormat.DOCX);
return byteArrayOutputStream.toByteArray();
Lib maven info:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>21.9</version>
<classifier>jdk17</classifier>
</dependency>