1

我需要用 Trusted-Library=true 属性标记 JAR 文件……不知何故。当我在清单中添加 Trusted-Library=true 时,我得到 class not found 异常。我在 Netbeans 中看到的清单是,

 Manifest-Version: 1.0
 X-COMMENT: Main-Class will be added automatically by build

当我使用项目属性中的 webstart 选项并从签名部分中选择 Trusted-Library 时,我找不到相同的类。

我能做些什么?

编辑:罐子里的清单:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
X-COMMENT: Main-Class will be added automatically by build
Created-By: 1.6.0_45-b06 (Sun Microsystems Inc.)

Name: JTwainLicense.class
SHA1-Digest: L4BTAOFRNEyeRA9Tw1Z3EQ0Ud5c=

Name: com/asprise/util/jtwain/web/TestApplet.class
SHA1-Digest: 8EetVUQhuvNH4urJB3oDG66vYas=

Name: com/asprise/util/jtwain/web/TestConstants.class
SHA1-Digest: ycjvP24IF/ggDBtj4v/r5Bz5nBY=

Name: com/asprise/util/jtwain/web/TestApplet_buttonScan_actionAdapter.class
SHA1-Digest: EWMDyf2p4ka8jOD8Fr2Fbrj/Tf0=

Name: META-INF/INDEX.LIST
SHA1-Digest: ymizlIYUM8SXgYNjYA30r1G0X7A=

Name: com/asprise/util/jtwain/web/ImageDisplayPanel.class
SHA1-Digest: Ae0oc23YVy8W9oTJoiRT2M1o4cY=

未找到类的清单错误。

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
X-COMMENT: Main-Class will be added automatically by build
Trusted-library: true
Created-By: 1.6.0_45-b06 (Sun Microsystems Inc.)

Name: JTwainLicense.class
SHA1-Digest: L4BTAOFRNEyeRA9Tw1Z3EQ0Ud5c=

Name: com/asprise/util/jtwain/web/TestApplet.class
SHA1-Digest: 8EetVUQhuvNH4urJB3oDG66vYas=

Name: com/asprise/util/jtwain/web/TestConstants.class
SHA1-Digest: ycjvP24IF/ggDBtj4v/r5Bz5nBY=

Name: com/asprise/util/jtwain/web/TestApplet_buttonScan_actionAdapter.class
SHA1-Digest: EWMDyf2p4ka8jOD8Fr2Fbrj/Tf0=

Name: META-INF/INDEX.LIST
SHA1-Digest: ymizlIYUM8SXgYNjYA30r1G0X7A=

Name: com/asprise/util/jtwain/web/ImageDisplayPanel.class
SHA1-Digest: Ae0oc23YVy8W9oTJoiRT2M1o4cY=

堆栈跟踪:

ERROR: com/asprise/util/jtwain/SourceManager
Exception in thread "AWT-EventQueue-3" java.lang.NoClassDefFoundError:            com/asprise/util/jtwain/SourceManager
at com.asprise.util.jtwain.web.TestApplet.buttonScan_actionPerformed(UploadApplet.java:388)
at com.asprise.util.jtwain.web.TestApplet_buttonScan_actionAdapter.actionPerformed(UploadApplet.java:548)
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)
....
4

1 回答 1

2

使用 Trusted-Library: true 使 jar 文件加载到单独的类加载器中,该类加载器是加载 Applets/WebStart 应用程序的类加载器的父级。

请参阅:https ://forums.oracle.com/forums/thread.jspa?threadID=2278127 ,另请参阅: http ://docs.oracle.com/javase/7/docs/technotes/guides/jweb/mixed_code.html

这意味着您的受信任代码无法访问不受信任的代码,除非通过 Thread.currentThread().getContextClassLoader()。

您还可以将 Trusted-Library: true 添加到您依赖的所有 jar 中。

于 2013-05-27T09:32:51.167 回答