XADES4j:不是有效的 Win32 应用程序 (pkcs11)?

XADES4j : is not a valid Win32 application (pkcs11)?

我使用 XADES4j 项目使用 JavaSE-1.8 (jre1.8.0_121) 32 位版本 + Windows32Bits + eclipse (32-bit Luna) + Gemalto token 签署电子发票并且效果很好. 现在我使用的是Windows64位系统,我没有做任何改变:我安装了JavaSE-1.8(jre1.8.0_121) 32位版本,相同版本的eclipse(32- bit) 和令牌 Gemalto (gclib.64bit dll)。 当 运行 来自 eclipse 的签名时,我在 pkcs11 安全提供程序安装级别遇到运行时错误:

0 [main] DEBUG org.apache.xml.security.Init  - Registering default 
algorithms
------------------------------------------------------------
...
profileCore.getInstance
SignerBES.class
profileCore.getInstance
SignerBES.class
Provider 0: SUN
Provider 1: SunRsaSign
Provider 2: SunEC
Provider 3: SunJSSE
Provider 4: SunJCE
Provider 5: SunJGSS
Provider 6: SunSASL
Provider 7: XMLDSig
Provider 8: SunPCSC
Provider 9: SunMSCAPI
INTALL PROVIDER .....

Exception in thread "AWT-EventQueue-0" java.security.ProviderException: 
Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:376)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
at xades4j.providers.impl.PKCS11KeyStoreKeyingDataProvider.createPkcs11Provider(PKCS11KeyStoreKeyingDataProvider.java:327)
at xades4j.providers.impl.PKCS11KeyStoreKeyingDataProvider.access(PKCS11KeyStoreKeyingDataProvider.java:322)
at xades4j.providers.impl.PKCS11KeyStoreKeyingDataProvider.getBuilder(PKCS11KeyStoreKeyingDataProvider.java:180)
at xades4j.providers.impl.KeyStoreKeyingDataProvider.ensureInitialized(KeyStoreKeyingDataProvider.java:277)
at xades4j.providers.impl.KeyStoreKeyingDataProvider.getSigningCertificateChain(KeyStoreKeyingDataProvider.java:423)
at xades4j.production.SignerBES.sign(SignerBES.java:183)
at xades4j.production.SignerBES.sign(SignerBES.java:145)
at FENETRE.PSD_SIGNATURE1(FENETRE.java:706)
at FENETRE.actionPerformed(FENETRE.java:983)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access0(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.IOException: %1 is not a valid Win32 application.
C:\Program Files\Gemalto\Classic Client\BIN\gclib.dl
at sun.security.pkcs11.wrapper.PKCS11.connect(Native Method)
at sun.security.pkcs11.wrapper.PKCS11.<init>(PKCS11.java:138)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:151)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:313)
... 46 more

如何解决这个问题?

在另一个不包含特殊字符的位置安装 Gemalto 驱动程序

如果PKCS11 模块依赖于其他库而加载失败,可能会出现“不是有效的Win32 应用程序”错误。将依赖项的路径添加到 PATH 环境变量应该可以解决这个问题(通常是 PKCS11 库本身的目录)。