Compare and convert documents in Java

Hi,
I am trying to compare docx files through comparer.compare(byteoutputStream,compareoptions) and then trying to convert the byteoutputstream to html using conversion api . The convert api is throwing this exception . Is it something you can help me with ?

java.lang.NoClassDefFoundError: Could not initialize class com.groupdocs.conversion.internal.c.a.w.internal.oZ

@bselvam

Please share following details and we’ll investigate this issue:

  • API versions that you are using (e.g. 19.10, 20.4)
  • Sample code or application

For comparison we are using 20.4
For convert we are using 20.2.1
Compare :
try (final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
final Comparer comparer = new Comparer(sourceStream);
comparer.add(targetStream);
CompareOptions compareOptions= new CompareOptions();
compareOptions.setDetectStyleChanges(true);
comparer.compare(byteArrayOutputStream,compareOptions);
return byteArrayOutputStream;

    } catch (IOException ioe) {
        throw new IOException(ioe);
    }

Convert :
final Converter converter = new Converter(new ByteArrayInputStream(inputByteArray));
final MarkupConvertOptions markupConvertOptions = new MarkupConvertOptions();
markupConvertOptions.setFormat_ConvertOptions_New(MarkupFileType.Html);
markupConvertOptions.setFixedLayout(true);
markupConvertOptions.setUsePdf(false); // Convert Docx -> Pdf -> Html, “true” causes exception: ERROR … [Request processing failed; nested exception is class com.groupdocs.conversion.internal.c.a.pd.internal.ms.System.l6n: Cannot find any fonts installed on the system.
converter.convert(byteArrayOutputStream, markupConvertOptions);
break;

@bselvam

We tried to reproduce this issue using following API versions and the application executed successfully:

  • GroupDocs.Comparison for Java 20.4
  • GroupDocs.Conversion for Java 20.6

Can you please try with these versions and share your experience.

Sure .I will try.Thank you for the response.

@bselvam

You’re welcome.

@atirtahir3 : Looks like the exception is not because of comparison i resolved it . When i tested it locally everything works fine. When we try to deploy in dev environment we are getting the below issue. Is this because we are using evaluation version not the license version ? Please throw some light on this issue

Exception Details:

7/17/2020 9:36:25 PM Location:

7/17/2020 9:36:25 PM com/groupdocs/comparison/license/License.setLicense(Ljava/io/InputStream;)V @81: invokevirtual

7/17/2020 9:36:25 PM Reason:

7/17/2020 9:36:25 PM Type ‘com/groupdocs/comparison/a’ (current frame, stack[2]) is not assignable to ‘com/groupdocs/comparison/internal/c/g/f/l/a’

7/17/2020 9:36:25 PM Current Frame:

7/17/2020 9:36:25 PM bci: @81

7/17/2020 9:36:25 PM flags: { }

7/17/2020 9:36:25 PM locals: { top, ‘java/io/InputStream’, ‘com/groupdocs/comparison/utils/b/b/a’ }

7/17/2020 9:36:25 PM stack: { ‘com/groupdocs/comparison/internal/c/g/f/c/a’, ‘com/groupdocs/comparison/utils/b/b/a’, ‘com/groupdocs/comparison/a’ }

7/17/2020 9:36:25 PM Bytecode:

7/17/2020 9:36:25 PM 0x0000000: 2bc7 003c bb00 0f59 b800 20b6 001f b800

7/17/2020 9:36:25 PM 0x0000010: 1eb7 002b 4d2c b800 279a 000d bb00 0f59

7/17/2020 9:36:25 PM 0x0000020: 1204 b700 2a4d bb00 0e59 b700 284e bb00

7/17/2020 9:36:25 PM 0x0000030: 0759 2d12 012c b600 29b7 001d bfbb 0011

7/17/2020 9:36:25 PM 0x0000040: 592b b700 2e4d b200 1a2c bb00 0559 b700

7/17/2020 9:36:25 PM 0x0000050: 1bb6 0022 04bd 0017 5903 2c53 b800 2fa7

7/17/2020 9:36:25 PM 0x0000060: 0013 3a04 04bd 0017 5903 2c53 b800 2f19

7/17/2020 9:36:25 PM 0x0000070: 04bf b1

7/17/2020 9:36:25 PM Exception Handler Table:

7/17/2020 9:36:25 PM bci [70, 84] => handler: 98

7/17/2020 9:36:25 PM bci [98, 100] => handler: 98

7/17/2020 9:36:25 PM Stackmap Table:

7/17/2020 9:36:25 PM full_frame(@38,{Top,Top,Object[#15]},{})

7/17/2020 9:36:25 PM full_frame(@61,{Top,Object[#21]},{})

7/17/2020 9:36:25 PM full_frame(@98,{Top,Top,Object[#17]},{Object[#25]})

7/17/2020 9:36:25 PM chop_frame(@114,3)

7/17/2020 9:36:25 PM ] with root cause

7/17/2020 9:36:25 PM java.lang.VerifyError: Bad type on operand stack

7/17/2020 9:36:25 PM Exception Details:

7/17/2020 9:36:25 PM Location:

7/17/2020 9:36:25 PM com/groupdocs/comparison/license/License.setLicense(Ljava/io/InputStream;)V @81: invokevirtual

7/17/2020 9:36:25 PM Reason:

7/17/2020 9:36:25 PM Type ‘com/groupdocs/comparison/a’ (current frame, stack[2]) is not assignable to ‘com/groupdocs/comparison/internal/c/g/f/l/a’

7/17/2020 9:36:25 PM Current Frame:

7/17/2020 9:36:25 PM bci: @81

7/17/2020 9:36:25 PM flags: { }

7/17/2020 9:36:25 PM locals: { top, ‘java/io/InputStream’, ‘com/groupdocs/comparison/utils/b/b/a’ }

7/17/2020 9:36:25 PM stack: { ‘com/groupdocs/comparison/internal/c/g/f/c/a’, ‘com/groupdocs/comparison/utils/b/b/a’, ‘com/groupdocs/comparison/a’ }

7/17/2020 9:36:25 PM Bytecode:

7/17/2020 9:36:25 PM 0x0000000: 2bc7 003c bb00 0f59 b800 20b6 001f b800

7/17/2020 9:36:25 PM 0x0000010: 1eb7 002b 4d2c b800 279a 000d bb00 0f59

7/17/2020 9:36:25 PM 0x0000020: 1204 b700 2a4d bb00 0e59 b700 284e bb00

7/17/2020 9:36:25 PM 0x0000030: 0759 2d12 012c b600 29b7 001d bfbb 0011

7/17/2020 9:36:25 PM 0x0000040: 592b b700 2e4d b200 1a2c bb00 0559 b700

7/17/2020 9:36:25 PM 0x0000050: 1bb6 0022 04bd 0017 5903 2c53 b800 2fa7

7/17/2020 9:36:25 PM 0x0000060: 0013 3a04 04bd 0017 5903 2c53 b800 2f19

7/17/2020 9:36:25 PM 0x0000070: 04bf b1

7/17/2020 9:36:25 PM Exception Handler Table:

7/17/2020 9:36:25 PM bci [70, 84] => handler: 98

7/17/2020 9:36:25 PM bci [98, 100] => handler: 98

7/17/2020 9:36:25 PM Stackmap Table:

7/17/2020 9:36:25 PM full_frame(@38,{Top,Top,Object[#15]},{})

7/17/2020 9:36:25 PM full_frame(@61,{Top,Object[#21]},{})

7/17/2020 9:36:25 PM full_frame(@98,{Top,Top,Object[#17]},{Object[#25]})

7/17/2020 9:36:25 PM chop_frame(@114,3)

@bselvam

You can request a temporary license here in purchase wizard. Please try to apply GroupDocs.Comparison for Java temporary license and share your experience.

Hi @atirtahir3 : We got temp lic for total . I am trying to apply the license. its throwing me the above exception at apply license . Below is the way i am applying the license.

License lic = new License();
lic.setLicense(inputStream);

Exception in my local machine : Caused by: java.lang.IllegalAccessError: tried to access class com.groupdocs.comparison.a from class com.groupdocs.comparison.license.License
at com.groupdocs.comparison.license.License.setLicense(Unknown Source)
Exception in development env:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘convertServiceImpl’ defined in URL [jar:file:/usr/share/myservice/myservice.jar!/BOOT-INF/classes!/com/xxxx/kms/convert/service/serivce/ConvertServiceImpl.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.xxxx.kms.convert.service.serivce.ConvertServiceImpl]: Constructor threw exception; nested exception is java.lang.VerifyError: Bad type on operand stack

7/24/2020 11:03:51 PM Exception Details:

7/24/2020 11:03:51 PM Location:

7/24/2020 11:03:51 PM com/groupdocs/comparison/license/License.setLicense(Ljava/io/InputStream;)V @81: invokevirtual

7/24/2020 11:03:51 PM Reason:

7/24/2020 11:03:51 PM Type ‘com/groupdocs/comparison/a’ (current frame, stack[2]) is not assignable to ‘com/groupdocs/comparison/internal/c/g/f/l/a’

7/24/2020 11:03:51 PM Current Frame:

7/24/2020 11:03:51 PM bci: @81

7/24/2020 11:03:51 PM flags: { }

7/24/2020 11:03:51 PM locals: { top, ‘java/io/InputStream’, ‘com/groupdocs/comparison/utils/b/b/a’ }

7/24/2020 11:03:51 PM stack: { ‘com/groupdocs/comparison/internal/c/g/f/c/a’, ‘com/groupdocs/comparison/utils/b/b/a’, ‘com/groupdocs/comparison/a’ }

7/24/2020 11:03:51 PM Bytecode:

7/24/2020 11:03:51 PM 0x0000000: 2bc7 003c bb00 0f59 b800 20b6 001f b800

7/24/2020 11:03:51 PM 0x0000010: 1eb7 002b 4d2c b800 279a 000d bb00 0f59

7/24/2020 11:03:51 PM 0x0000020: 1204 b700 2a4d bb00 0e59 b700 284e bb00

7/24/2020 11:03:51 PM 0x0000030: 0759 2d12 012c b600 29b7 001d bfbb 0011

7/24/2020 11:03:51 PM 0x0000040: 592b b700 2e4d b200 1a2c bb00 0559 b700

7/24/2020 11:03:51 PM 0x0000050: 1bb6 0022 04bd 0017 5903 2c53 b800 2fa7

7/24/2020 11:03:51 PM 0x0000060: 0013 3a04 04bd 0017 5903 2c53 b800 2f19

7/24/2020 11:03:51 PM 0x0000070: 04bf b1

7/24/2020 11:03:51 PM Exception Handler Table:

7/24/2020 11:03:51 PM bci [70, 84] => handler: 98

7/24/2020 11:03:51 PM bci [98, 100] => handler: 98

7/24/2020 11:03:51 PM Stackmap Table:

7/24/2020 11:03:51 PM full_frame(@38,{Top,Top,Object[#15]},{})

7/24/2020 11:03:51 PM full_frame(@61,{Top,Object[#21]},{})

7/24/2020 11:03:51 PM full_frame(@98,{Top,Top,Object[#17]},{Object[#25]})

7/24/2020 11:03:51 PM chop_frame(@114,3)

7/24/2020 11:03:51 PM

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:312)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:293)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)

7/24/2020 11:03:51 PM at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)

7/24/2020 11:03:51 PM at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)

7/24/2020 11:03:51 PM at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)

7/24/2020 11:03:51 PM at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)

7/24/2020 11:03:51 PM at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)

7/24/2020 11:03:51 PM at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)

7/24/2020 11:03:51 PM at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)

7/24/2020 11:03:51 PM at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)

7/24/2020 11:03:51 PM at com.xxxx.kms.convert.service.ConvertServiceApplication.main(ConvertServiceApplication.java:12)

7/24/2020 11:03:51 PM at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

7/24/2020 11:03:51 PM at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

7/24/2020 11:03:51 PM at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

7/24/2020 11:03:51 PM at java.lang.reflect.Method.invoke(Method.java:498)

7/24/2020 11:03:51 PM at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)

7/24/2020 11:03:51 PM at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)

7/24/2020 11:03:51 PM at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)

7/24/2020 11:03:51 PM at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)

7/24/2020 11:03:51 PM Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.xxxx.kms.convert.service.serivce.ConvertServiceImpl]: Constructor threw exception; nested exception is java.lang.VerifyError: Bad type on operand stack

7/24/2020 11:03:51 PM Exception Details:

7/24/2020 11:03:51 PM Location:

7/24/2020 11:03:51 PM com/groupdocs/comparison/license/License.setLicense(Ljava/io/InputStream;)V @81: invokevirtual

7/24/2020 11:03:51 PM Reason:

7/24/2020 11:03:51 PM Type ‘com/groupdocs/comparison/a’ (current frame, stack[2]) is not assignable to ‘com/groupdocs/comparison/internal/c/g/f/l/a’

7/24/2020 11:03:51 PM Current Frame:

7/24/2020 11:03:51 PM bci: @81

7/24/2020 11:03:51 PM flags: { }

7/24/2020 11:03:51 PM locals: { top, ‘java/io/InputStream’, ‘com/groupdocs/comparison/utils/b/b/a’ }

7/24/2020 11:03:51 PM stack: { ‘com/groupdocs/comparison/internal/c/g/f/c/a’, ‘com/groupdocs/comparison/utils/b/b/a’, ‘com/groupdocs/comparison/a’ }

7/24/2020 11:03:51 PM Bytecode:

7/24/2020 11:03:51 PM 0x0000000: 2bc7 003c bb00 0f59 b800 20b6 001f b800

7/24/2020 11:03:51 PM 0x0000010: 1eb7 002b 4d2c b800 279a 000d bb00 0f59

7/24/2020 11:03:51 PM 0x0000020: 1204 b700 2a4d bb00 0e59 b700 284e bb00

7/24/2020 11:03:51 PM 0x0000030: 0759 2d12 012c b600 29b7 001d bfbb 0011

7/24/2020 11:03:51 PM 0x0000040: 592b b700 2e4d b200 1a2c bb00 0559 b700

7/24/2020 11:03:51 PM 0x0000050: 1bb6 0022 04bd 0017 5903 2c53 b800 2fa7

7/24/2020 11:03:51 PM 0x0000060: 0013 3a04 04bd 0017 5903 2c53 b800 2f19

7/24/2020 11:03:51 PM 0x0000070: 04bf b1

7/24/2020 11:03:51 PM Exception Handler Table:

7/24/2020 11:03:51 PM bci [70, 84] => handler: 98

7/24/2020 11:03:51 PM bci [98, 100] => handler: 98

7/24/2020 11:03:51 PM Stackmap Table:

7/24/2020 11:03:51 PM full_frame(@38,{Top,Top,Object[#15]},{})

7/24/2020 11:03:51 PM full_frame(@61,{Top,Object[#21]},{})

7/24/2020 11:03:51 PM full_frame(@98,{Top,Top,Object[#17]},{Object[#25]})

7/24/2020 11:03:51 PM chop_frame(@114,3)

7/24/2020 11:03:51 PM

7/24/2020 11:03:51 PM at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:213)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)

7/24/2020 11:03:51 PM at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:308)

7/24/2020 11:03:51 PM … 27 common frames omitted

7/24/2020 11:03:51 PM Caused by: java.lang.VerifyError: Bad type on operand stack

7/24/2020 11:03:51 PM Exception Details:

7/24/2020 11:03:51 PM Location:

7/24/2020 11:03:51 PM com/groupdocs/comparison/license/License.setLicense(Ljava/io/InputStream;)V @81: invokevirtual

7/24/2020 11:03:51 PM Reason:

7/24/2020 11:03:51 PM Type ‘com/groupdocs/comparison/a’ (current frame, stack[2]) is not assignable to ‘com/groupdocs/comparison/internal/c/g/f/l/a’

7/24/2020 11:03:51 PM Current Frame:

7/24/2020 11:03:51 PM bci: @81

7/24/2020 11:03:51 PM flags: { }

7/24/2020 11:03:51 PM locals: { top, ‘java/io/InputStream’, ‘com/groupdocs/comparison/utils/b/b/a’ }

7/24/2020 11:03:51 PM stack: { ‘com/groupdocs/comparison/internal/c/g/f/c/a’, ‘com/groupdocs/comparison/utils/b/b/a’, ‘com/groupdocs/comparison/a’ }

7/24/2020 11:03:51 PM Bytecode:

7/24/2020 11:03:51 PM 0x0000000: 2bc7 003c bb00 0f59 b800 20b6 001f b800

7/24/2020 11:03:51 PM 0x0000010: 1eb7 002b 4d2c b800 279a 000d bb00 0f59

7/24/2020 11:03:51 PM 0x0000020: 1204 b700 2a4d bb00 0e59 b700 284e bb00

7/24/2020 11:03:51 PM 0x0000030: 0759 2d12 012c b600 29b7 001d bfbb 0011

7/24/2020 11:03:51 PM 0x0000040: 592b b700 2e4d b200 1a2c bb00 0559 b700

7/24/2020 11:03:51 PM 0x0000050: 1bb6 0022 04bd 0017 5903 2c53 b800 2fa7

7/24/2020 11:03:51 PM 0x0000060: 0013 3a04 04bd 0017 5903 2c53 b800 2f19

7/24/2020 11:03:51 PM 0x0000070: 04bf b1

7/24/2020 11:03:51 PM Exception Handler Table:

7/24/2020 11:03:51 PM bci [70, 84] => handler: 98

7/24/2020 11:03:51 PM bci [98, 100] => handler: 98

7/24/2020 11:03:51 PM Stackmap Table:

7/24/2020 11:03:51 PM full_frame(@38,{Top,Top,Object[#15]},{})

7/24/2020 11:03:51 PM full_frame(@61,{Top,Object[#21]},{})

7/24/2020 11:03:51 PM full_frame(@98,{Top,Top,Object[#17]},{Object[#25]})

7/24/2020 11:03:51 PM chop_frame(@114,3)

7/24/2020 11:03:51 PM

7/24/2020 11:03:51 PM

@bselvam

Please download and run this application at your machine (you have to add Comparison and Conversion latest versions/JARs in the application) and let us know if issue persists.
We can successfully run this application at our end. Have a look at this screenshot.png (104.0 KB).

@atirtahir3 : I have attached pom.xml . The total license which we got works for conversion but not for comparison . I am getting the same exception as above. I did run the example with my license and my local file. The same exception occurs in run example too. Is there any suggestion which i can try ?

pom.zip (1.2 KB)

@bselvam

Can you please share a simple console application using that issue could be reproduced?

@atirtahir3 : I used your sample application and ran it in my local even that threw error . I guess it was working fine at your end . The temp license we got from groupdocs is working fine with older version (19.10) of comparison license method . Do you suggest to go ahead and use the older version ?

// apply comparison license (pass license string)
        com.groupdocs.comparison.common.license.License compLic = new com.groupdocs.comparison.common.license.License();
        compLic.setLicense(tempResource.getInputStream());
1 Like

@bselvam

We’ve logged this issue in our internal issue tracking system with ID COMPARISONJAVA-894. It’ll be now further investigated. As there’s any update, you’ll be notified.