We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Getting NoSuchAlgorithmException when applying watermark to XLSX

When I am applying watermark to a password protected xlsx file getting NoSuchAlgorithmException. The similar issue found and fixed in Viewer SDK and it posted in Getting NoSuchAlgorithmException when converting XLSX to pdf

Component Details:
Watermark SDK : 20.5
OS : Windows 10
JDK : 8

java.lang.RuntimeException: java.security.NoSuchAlgorithmException: no such algorithm: SHA-512 for provider BC
	at com.groupdocs.watermark.internal.b.a(Unknown Source)
	at com.groupdocs.watermark.contents.SpreadsheetContent.a(Unknown Source)
	at com.groupdocs.watermark.contents.SpreadsheetContent.<init>(Unknown Source)
	at com.groupdocs.watermark.internal.bH.j(Unknown Source)
	at com.groupdocs.watermark.internal.bH.b(Unknown Source)
	at com.groupdocs.watermark.internal.az.a(Unknown Source)
	at com.groupdocs.watermark.internal.E.a(Unknown Source)
	at com.groupdocs.watermark.internal.E.a(Unknown Source)
	at com.groupdocs.watermark.Watermarker.<init>(Unknown Source)
	at com.groupdocs.watermark.Watermarker.<init>(Unknown Source)
	at com.securelyshare.groupdocs.test.ConvertDocTest.addWatermark(ConvertDocTest.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:532)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:171)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:167)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:114)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:59)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:108)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.security.NoSuchAlgorithmException: no such algorithm: SHA-512 for provider BC
	at sun.security.jca.GetInstance.getService(GetInstance.java:87)
	at sun.security.jca.GetInstance.getInstance(GetInstance.java:206)
	at java.security.Security.getImpl(Security.java:698)
	at java.security.MessageDigest.getInstance(MessageDigest.java:230)
	at com.groupdocs.watermark.internalx.c.a.c.a.c.x.sS(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.a.c.x.<init>(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.Zp.dj(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.Zp.<init>(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.YX.c(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.SY.b(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.SY.a(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.SY.a(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.fN.a(Unknown Source)
	at com.groupdocs.watermark.internalx.c.a.c.fN.<init>(Unknown Source)
	... 50 more

Code snippet to reproduce the issue

    @Test
    void addWatermark() {
        com.groupdocs.watermark.options.LoadOptions l = new com.groupdocs.watermark.options.LoadOptions();
        l.setPassword("xxxx");
        Watermarker watermarker = new Watermarker(getClass().getResourceAsStream("/test_protect.xlsx"), l);
        TextWatermark watermark = new TextWatermark("Test watermark", new Font("Arial", 36, FontStyle.Bold | FontStyle.Italic));
        watermarker.add(watermark);
        watermarker.save("test_protect.xlsx");
        watermarker.close();
    }
Password

Secure@123

test_protect.docx (15 KB)
Please rename .docx to .xlsx

1 Like

@shiva.k

This issue is reproduced at our end. Therefore, we’ve logged it in our internal issue tracking system with ID WATERMARKJAVA-107. It’ll be now further investigated. You’ll be notified about the progress update.