utilisation
static {
/** Initialisation du moteur velocity */
Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
"org.apache.velocity.runtime.log.NullLogSystem");
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER,
EjbConstants.VELOCITY_RESOURCE_LOADER_TYPE);
Velocity.setProperty(EjbConstants.VELOCITY_CLASSPATH_RESOURCE_LOADER,
ClasspathResourceLoader.class.getName());
}
public static String createXMLFlux(final RemiseEffetBean bean,
final String maquetteId) {
try {
final VelocityContext context = new VelocityContext();
final StringWriter swOut = new StringWriter();
// Initialisation
Velocity.init();
final Template template = Velocity.getTemplate(
EjbConstants.XML_TEMPLATE_FILE, CharEncoding.UTF_8);
context.put(EjbConstants.VELOCITY_REMISE_EFFET, bean);
// id de la maquette pdf a generer
context.put(EjbConstants.VELOCITY_MAQUETTE_ID, maquetteId);
template.merge(context, swOut);
return swOut.toString();
} catch (final ResourceNotFoundException e) {
LOGGER.error("La template n'a pas été trouvée", e);
} catch (final ParseErrorException e) {
LOGGER.error("Erreur du parsing de la template", e);
} catch (final MethodInvocationException e) {
LOGGER.error("Erreur lors de la substitution des données", e);
} catch (final Exception e) {
LOGGER.error("Erreur lors du traitement du fichier", e);
}
return null;
}
ajoutant properties.setProperty \t \t ("runtime.log.logsystem.class" \t \t « org.apache.velocity. runtime.log.NullLogSystem "); a fait l'affaire –
@Hamza: merci beaucoup! Ajout de ce paramètre à velocity.properties résolu le problème – Vanya