Le 06/04/2016 15:59, Guillaume Gurdil a écrit :
I don't know if that will help but I tried decomposing what was going on using the source of EngineTemplate and I found that this was the line that didn't work :
|
this.template.createDocument(this.engine);
|

Problem is : neither this.template nor this.engine are null so I don't get it.

Again, thanks in advance


On Wednesday, April 6, 2016 at 2:59:17 PM UTC+2, Guillaume Gurdil wrote:

    Hello everyone !

    I've used jOpenDocument for some time now but always with
    spreadsheets. This time, I need to work on text documents.
    Unfortunately, even if all the file manipulation is ok (setFields
    and things like that), I can't save the file because I get a
    NullPointerException. Here's a bit of code :

    |
        try {
          JavaScriptFileTemplate template = null;
          if (getNomFichierModele() != null) {
            // Récupération du template via FTP
            File templateFile = getTemplateSource(request);
            // Création d'un fichier temporaire
            tempFile = File.createTempFile("OdtFile", EXTENSION);
            template = new JavaScriptFileTemplate(templateFile);
          } else {
            logger.debug("Création d'un document vierge");
            tempFile = File.createTempFile("OdtFile", EXTENSION);
            template = new JavaScriptFileTemplate("");
          }
          buildODTDocument(model, template, request, response);
          // Enregistrement dans le fichier
          tempFile = template.saveAs(tempFile);
          // Fin de traitement, envoi dans l'out
          inputStream = new FileInputStream(tempFile);
          byte[] bytes = new byte[4096];
          int lu = 0;
          while ((lu = inputStream.read(bytes)) > 0) {
            out.write(bytes, 0, lu);
          }
        } finally {
          try {
            out.flush();
            inputStream.close();
            tempFile.delete();
          } catch (IOException ie) {
            // Forward to handler
            logger.error("Pb de fermeture de fichier");
          }
        }
    |



    Everything up to buildODTDocument() works fine. The template is
    not null, the file is correctly retrieved and copied, the copy is
    correctly modified. The only line that I can't get to work is
    tempFile = template.saveAs(tempFile);

    Does anyone have an idea why ? It's really frustrating and I've
    spent quite an amount of time to figure out what the problem is.
    In vain...


    Thanks in advance for any help you might give me.

    Guillaume

--

---
You received this message because you are subscribed to the Google Groups "jOpenDocument" group. To unsubscribe from this group and stop receiving emails from it, send an email to jopendocument+unsubscr...@googlegroups.com <mailto:jopendocument+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
Hi,

Can you provide the stack trace?

Thanks.

Regards,

--
Guillaume Maillard, Directeur technique
ILM Informatique, 22 place de la libération, 80100 Abbeville
www.ilm-informatique.fr

Connaissez-vous?
www.openconcerto.org    Le logiciel de gestion Open Source

--

--- You received this message because you are subscribed to the Google Groups "jOpenDocument" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jopendocument+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to