Free Support Forum - groupdocs.com

Error occurred when converting document


#1

Hi,


I am trying to convert docx file using groupdocs 16.10.1 for Java. If I run in single thread, it works fine. But when I run using multithreading, it’s failed.
It seems that ConversionHandler is not thread safe.



#2

Hi There,


Thanks for posting your concerns.
Can you please share problematic file and sample code with us. We’d like to investigate that at our end.

Best wishes

#3

Hi Atir,


Thank you for the reply. Please find the attachment for the snipped code.


#4

Hi Agustino,


Can you please share the problematic file as well? We’ll appreciate your cooperation.

Kind regards

#5

Hi Atir,


Please find the file in the attachment.

#6

Hi Agustino,


Thanks for your cooperation. We’ll update you soon about the investigation’s outcome.

Best wishes


#7

Hi Agustino,


Can you please change,
private static final ConversionHandler CONVERSION_HANDLER = new ConversionHandler(Utilities.getConfiguration());
to this:
private final ConversionHandler CONVERSION_HANDLER = new ConversionHandler(Utilities.getConfiguration());
or any other way to make the ConversionHandler instance member, don’t make it static and see if you still face same issue.

Kind regards

#8

Hi Atir,


I have tried your suggestion. It works fine. For every conversion, if I need to instantiate ConversionHandler, will it be expensive call?

Thanks

#9

Hi Agustino,


I have tried your suggestion. It works fine.
Good to know that.
As far as your second question is concerned, it won’t be very much expensive if you instantiate ConversionHandler and then destroy the object for that specific Conversion call and instantiate again for next call and so on.
After each conversion call you can do:
conversionHandler = null;
It will be automatically deleted by the garbage collector (not immediately, but eventually).
We’d suggest you to observe/compare conversion performance in both cases (Instantiating ConversionHanlder each time without destroying object and with destroying object after each conversion call).

Kind regards

#10

Hi Agustino,


Additionally, please note that the instantiation of ConversionHandler is light weight and very quick operation. It won’t be expensive, no matter if you destroy object or not. Hence, we’d suggest you to instantiate ConversionHandler each time for each conversion call (that is already your basic need).

Many thanks

#11

Hi Atir,


Thank you for the response. I will change to local variable.



#12

Hi Agustino,


You are always welcome.

Best wishes

#13

Hi Atir,


I am getting another error after moving conversion handler to local variable:

Error occurred while getting contents of document: At most 4 elements (for any collection) can be viewed in evaluation mode.
class com.groupdocs.conversion.internal.c.a.pd.internal.ms.System.z87: At most 4 elements (for any collection) can be viewed in evaluation mode

Is it expected result while I am using trial license?

Thanks


#14

Hi Agustino,


At most 4 elements (for any collection) can be viewed in evaluation mode
This error occurs when you are evaluating the API in trial mode.
Is it expected result while I am using trial license?
As you are using trial license to evaluate the API, there can be following possibilities:
  • License is not applied properly
  • Trial license is expired
If trial license is not expired, please share the code with us where you are applying license.

Kind regards

#15

Hi Atir,


Thanks for highlighting this. I have so many classes for testing and this class I miss out to apply the license. Sorry about that

#16

Hi Atir,


I am still getting the same error. This error happened intermittent.
Please find the stacktrace and the source file in the attachment.

Thanks

#17

Hi Agustino,


Thanks for sharing the concerned files.
We’ve logged your issue in our internal issue tracking system with ID - CONVERSIONJAVA-385. As we have any update, we’ll notify you.

Have a nice weekend!
Kind regards

#18

@agustinoalim,

We have an update regarding CONVERSIONJAVA-385. The workaround is to instantiate conversion handler in each thread.
If you change:
private static final ConversionHandler CONVERSION_HANDLER = new ConversionHandler(Utilities.getConfiguration());
to
private final ConversionHandler CONVERSION_HANDLER;
and instantiate the conversion handler in MyThread constructor:
this.CONVERSION_HANDLER = new ConversionHandler(Utilities.getConfiguration());
It will resolve your issue.