This is the exception that got thrown when the code to fill in a docx using docx4j is called:
- Code: Select all
java.lang.NoClassDefFoundError: javax/xml/bind/ValidationEventHandler
This is the code that uses docx4j:
- Code: Select all
public void generate() {
try {
WordprocessingMLPackage template = WordprocessingMLPackage.load(new ByteArrayInputStream(getTemplate().getContent()));
List<Object> texts = getAllElementFromObject(template.getMainDocumentPart(), Text.class);
Map<String, String> dataMap = createDataMap();
for (Object text : texts) {
Text textElement = (Text) text;
String key = textElement.getValue();
if (dataMap.containsKey(key)) {
textElement.setValue(dataMap.get(key));
}
}
fillInTables(template);
saveDoc(template);
} catch (Exception e) {
throw new ApplicationRuntimeException(e);
}
}
Do you know what could be the problem? We do have javaee-api-5.0-1.jar under WEB-INF/lib that contains this ValidationEventHandler. Many thanks for any help.
Thanks,
Wendy