How to avoid that window message about some conversion error

87 views
Skip to first unread message

Carlos Spohr

unread,
Jul 4, 2018, 12:19:07 PM7/4/18
to documents4j
Hi there,

I have a Windows server with MS Office (full installed) and a Java application providing rest calling to convert .docx files to PDF. 

When this server has a lot of requests, sometimes I got a error window from msoffice word, so, when I click to close, the original request resume (returning a conversion error to caller) and all next requests (that got stuck) resume.

Is there some configuration to avoid it ?

Rafael Winterhalter

unread,
Jul 5, 2018, 11:03:08 AM7/5/18
to Carlos Spohr, documents4j
I would assume that you can configure this in the MS Word installation. Within the script, checkboxes are normally suppressed. It should also be possible to avoid this by running documents4j as a service where Word runs headless.

--
You received this message because you are subscribed to the Google Groups "documents4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to documents4j+unsubscribe@googlegroups.com.
To post to this group, send email to docum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/documents4j/a694ea16-ecfe-4e84-95ed-ff8f23caeff7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Spohr

unread,
Jul 5, 2018, 1:07:33 PM7/5/18
to documents4j
Hi Rafael,

Uhmm, in this case to run as headless service, what I have to do is disable all settings may throw popup window ?

Just for you understand, some days ago, my rest application received a bunch of requests to convert docs from our users (+- 5k users), and at some moment all requests were stuck because some previous request was waiting conversion...and looking on Windows by remote desktop, there was a MS office window reporting some error on MS Word. 

I did some refactoring on code, reviewing some methods to avoid 'locks', so I did some update with this:

// Register one converter per request.
IConverter converter = LocalConverter.builder()
 
.baseFolder(baseFolder)
 
.processTimeout(30, TimeUnit.SECONDS)
 
.build();


// Call conversion with some priority and get byte array.
byte[] response = null;
 
 
try {
 
 converter
 
.convert(file.getFile(), true)
 
.as(typeFrom)
 
.to(out)
 
.as(typeTo)
 
.prioritizeWith(1000)
 
.execute();
 
 
InputStream io = new FileInputStream(out);
 
 response
= IOUtils.toByteArray(io);
 
 io
.close();
 
 
} catch (Exception e) {
 
//e.printStackTrace();
 
throw new ConverterException(e.getMessage());
 
} finally {
 
 converter
.shutDown();
 
// remove temp files.
 
}
 
 
return response;

I'll continue monitoring my service here, but I think that is OK now. 

What do you think about a simple post in official site explaining how to configure office installation as headless service?


On Thursday, July 5, 2018 at 12:03:08 PM UTC-3, Rafael Winterhalter wrote:
I would assume that you can configure this in the MS Word installation. Within the script, checkboxes are normally suppressed. It should also be possible to avoid this by running documents4j as a service where Word runs headless.
2018-07-04 18:19 GMT+02:00 Carlos Spohr <carlos...@gmail.com>:
Hi there,

I have a Windows server with MS Office (full installed) and a Java application providing rest calling to convert .docx files to PDF. 

When this server has a lot of requests, sometimes I got a error window from msoffice word, so, when I click to close, the original request resume (returning a conversion error to caller) and all next requests (that got stuck) resume.

Is there some configuration to avoid it ?

--
You received this message because you are subscribed to the Google Groups "documents4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to documents4j...@googlegroups.com.

Carlos Spohr

unread,
Jul 5, 2018, 1:09:53 PM7/5/18
to documents4j
That exception:

Carlos Spohr

unread,
Jul 5, 2018, 1:14:39 PM7/5/18
to documents4j

Looking up on catalina.out file, I found this exception:

04-Jul-2018 19:06:42.683 INFO [Thread-5] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]
04-Jul-2018 19:06:42.714 INFO [Shutdown hook: com.documents4j.job.LocalConverter] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [excel_shutdown.vbs]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
 java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [excel_shutdown.vbs]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1305)
at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:986)
at java.lang.Class.getResource(Class.java:2267)
at com.google.common.io.Resources.getResource(Resources.java:208)
at com.documents4j.conversion.msoffice.MicrosoftExcelScript.materializeIn(MicrosoftExcelScript.java:54)
at com.documents4j.conversion.msoffice.AbstractMicrosoftOfficeBridge.runNoArgumentScript(AbstractMicrosoftOfficeBridge.java:49)
at com.documents4j.conversion.msoffice.AbstractMicrosoftOfficeBridge.tryStop(AbstractMicrosoftOfficeBridge.java:41)
at com.documents4j.conversion.msoffice.MicrosoftExcelBridge.shutDown(MicrosoftExcelBridge.java:56)
at com.documents4j.conversion.ConverterRegistry.shutDown(ConverterRegistry.java:83)
at com.documents4j.conversion.DefaultConversionManager.shutDown(DefaultConversionManager.java:45)
at com.documents4j.job.LocalConverter.shutDown(LocalConverter.java:106)
at com.documents4j.job.ConverterAdapter$ConverterShutdownHook.run(ConverterAdapter.java:134)

Is there any way to avoid problems with VB scripts or macros? 

Rafael Winterhalter

unread,
Jul 21, 2018, 5:10:56 PM7/21/18
to Carlos Spohr, documents4j
Sorry for the delay, I have been on vacation.

It seems like you are running the server from a Tomcat instance. The instance has determined that the Java application is to shut down. This will not work. documents4j is a hibrid service that runs Java and .NET, you cannot put this into a container properly.
I would recommend you to run the standalone server.

--
You received this message because you are subscribed to the Google Groups "documents4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to documents4j+unsubscribe@googlegroups.com.

To post to this group, send email to docum...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages