Sorry for the dealy, I didn't get an email to warn me there was a reply. 
Here are the mentioned lines :
out.flush();
inputStream.close();

Indeed, inputStream is null at this point because those lines are in the 
"finally" statement and it is triggered just after the problem with the 
"saveAs" line. Meanwhile, I added a test in order not to attempt to close 
the stream if it is null.

So my bad, the null problem came from another place. The real problem lies 
in this error :
org.jopendocument.dom.template.TemplateException: pb while replacing 
<text:span xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
text:description="Prenom Nom">Prénom NOM</text:span>

It appears the file manipulation isn't ok after all. I'll keep on working 
on it. Thanks (and sorry) for your time.

Regards,

Guillaume


On Friday, April 8, 2016 at 5:56:38 PM UTC+2, jOpenDocument, Guillaume 
wrote:
>
> Le 07/04/2016 16:06, Guillaume Gurdil a écrit :
>
> Hi and thanks for your reply. 
>
> Here is the stack trace I get :
>
> 16:03:56,019 ERROR [io.undertow.request] (default task-38) UT005023: 
> Exception handling request to /tim/edition/soldeCET/extract: 
> org.springframework.web.util.NestedServletException: Request processing 
> failed; nested exception is java.lang.NullPointerException
> at 
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) 
> [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
> at 
> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
> [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> com.match.common.web.springsecurity.InvalidateSessionFilter.doFilter(InvalidateSessionFilter.java:89)
>  
> [matchlib-securite-springsecurity-2.10.1.RELEASE.jar:]
> at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
>  
> [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
> at 
> org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
>  
> [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
>  
> [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56) 
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180)
>  
> [spring-orm-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>  
> [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56) 
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
>  
> [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>  
> [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56) 
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
>  
> [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>  
> [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56) 
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
> at 
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
>  
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52)
>  
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
>  
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
>  
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
>  
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
> at 
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
>  
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
>  
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
>  
> [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
> at io.undertow.server.Connectors.executeRootHandler(Connectors.java:168) 
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:687) 
> [undertow-core-1.0.0.Final.jar:1.0.0.Final]
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>  
> [rt.jar:1.8.0]
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>  
> [rt.jar:1.8.0]
> at java.lang.Thread.run(Thread.java:744) [rt.jar:1.8.0]
> Caused by: java.lang.NullPointerException
> at 
> com.match.tim.web.view.AbstractODTConfigView.renderMergedOutputModel(AbstractODTConfigView.java:88)
>  
> [classes:]
> at 
> org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> at 
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
>  
> [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
> ... 70 more
>
> AbstractODTConfigView is the class which i took the snippet of code in the 
> first post from.
>
> Regards,
>
> Guillaume
>
>
> On Thursday, April 7, 2016 at 11:09:56 AM UTC+2, jOpenDocument, Guillaume 
> wrote: 
>>
>> 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 jopendocumen...@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 
>> Abbevillewww.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 jopendocumen...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
> Hi,
>
> Please provide lines 87 and 88 from :
>
> com.match.tim.web.view.AbstractODTConfigView.renderMergedOutputModel.AbstractODTConfigView.java
>
> Regards,
>
> -- 
> Guillaume Maillard, Directeur technique
> ILM Informatique, 22 place de la libération, 80100 
> Abbevillewww.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