How to annotate and watermark a document in Java

Hello ,
I am using groupdocs-Annotation 18.8.jar and groupdocs-watermark 18.8.jar in the same project .
While adding the watermark in the file below line throws exception.

PdfDocument doc = Document.load(PdfDocument.class, inputFilePath);

Please find the exception log below :

java.lang.IllegalAccessError: tried to access class com.aspose.email.as from class com.groupdocs.watermark.bc

Caused by: java.lang.IllegalAccessError: tried to access class com.aspose.email.
as from class com.groupdocs.watermark.bc
at com.groupdocs.watermark.bc.wC(Unknown Source)
at com.groupdocs.watermark.ao.(Unknown Source)
at com.groupdocs.watermark.ao.vJ(Unknown Source)
at com.groupdocs.watermark.DocumentFactory.a(Unknown Source)
at com.groupdocs.watermark.DocumentFactory.load(Unknown Source)
at com.groupdocs.watermark.DocumentFactory.load(Unknown Source)
at com.groupdocs.watermark.Document.load(Unknown Source)
at org.infotech.jdol.client.utility.groupdocs.WatermarkUtility.addWaterm
ark(WatermarkUtility.java:51)

Please guid me for the same.

Thanks

@3iinfo,

Thank you for your inquiry.

We are unable to reproduce this issue at our end. Can you please share a simple application along-with problematic file? We’ll then further investigate the issue.

We integrated GroupDocs.Annotaiton for Java 18.10 and GroupDocs.Watermark for Java 18.8 in a single project.

Hello,

Have you tried with web application or Standalone java application?
I am using it in web application and deployed it on wildfly server.

@3iinfo,

We investigated this issue using a standalone Java application.

However, for further investigation, can you please share a simple web application (without any dependencies) using that we can reproduce the issue.
Secondly, you can also try to reproduce this exception in a standalone application and then share that with us.

@atirtahir3

I have already tried using standalone application, there its working fine . Only problem when I deployed it as web app .

I will try with simple web app and will tell you know.

1 Like

@3iinfo,

Thanks and we’d recommend you to share a simplified (to the point) web application along-with steps to run/compile it.

OK ,Sure

Thanks

1 Like

@3iinfo,

You are welcome.

Hi @atirtahir3,

I have solved that issue .I Just changed the sequence of jar files. Loaded the groupdocs-watermark jar at the first place before the annotation and signature jar. You can see the screen-shot attached.

But started giving new exception while loading the license for annotation jar. I think com.groupdocs.email is creating this ambiguity.Because same path is present in the all three jar file.

Please find the error log below :

Exception in thread “main” java.lang.NoSuchMethodError: com.aspose.email.internal.i.b.Cg()Lcom/aspose/email/internal/i/b;
at com.aspose.email.b.b$e.(Unknown Source)
at com.aspose.email.b.b$e.(Unknown Source)
at com.aspose.email.b.b$c.(Unknown Source)
at com.aspose.email.b.b$h.(Unknown Source)
at com.aspose.email.b.b$h.(Unknown Source)
at com.aspose.email.b.b.b(Unknown Source)
at com.aspose.email.b.b.z(Unknown Source)
at com.aspose.email.internal.g.cD$a.(Unknown Source)
at com.aspose.email.internal.g.cD.(Unknown Source)
at com.aspose.email.acj.a(Unknown Source)
at com.aspose.email.acj.a(Unknown Source)
at com.aspose.email.License.a(Unknown Source)
at com.aspose.email.License.setLicense(Unknown Source)
at com.groupdocs.annotation.internal.c.g.f.l.aspose.a.fH(Unknown Source)
at com.groupdocs.annotation.internal.c.g.f.l.aspose.a.r(Unknown Source)
at com.groupdocs.annotation.internal.c.g.f.l.b.jTb(Unknown Source)
at com.groupdocs.annotation.internal.c.g.f.l.b.b(Unknown Source)
at com.groupdocs.annotation.internal.c.g.f.handler.a.a(Unknown Source)
at com.groupdocs.annotation.internal.c.g.f.handler.a.a(Unknown Source)
at com.groupdocs.annotation.common.license.License.setLicense(Unknown Source)
at MainClass.loadLicense(MainClass.java:153)
at MainClass.main(MainClass.java:23)

jarlistSequence.png (182.9 KB)

@3iinfo,

Good to know that this issue is resolved.

We need sample project in order to investigate this scenario. Are you able to reproduce this (license loading) issue in standalone application?

Yes.In Standalone application also
com.groupdocs.annotation.common.license.License l = new com.groupdocs.annotation.common.license.License();

on this line its throwing exception for me.

If you want to get the same behavior at your end then add the jars in the following sequence
as shown in the attached file jarlistSequence.png (182.9 KB)

1 Like

@3iinfo,

This issue is reproduced at our end as well.
Hence, it has been logged in our internal issue tracking system with ID : ANNOTATIONJAVA-1130. We’re now investigating it. As we have any further updates, we’ll notify you.

@atirtahir3 Ok ,

Thank you .

@3iinfo,

You are welcome.