Java Applet SOAPMessage 导致“SAAJ0540:保存多部分消息时出错" [英] Java Applet SOAPMessage causes "SAAJ0540: Error during saving a multipart message"

查看:17
本文介绍了Java Applet SOAPMessage 导致“SAAJ0540:保存多部分消息时出错"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,可以归结为这个简单的例子.

I have a problem which I have boiled down to this simple example.

import java.applet.Applet;

import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;

public class SOAPTest2 extends Applet {
    private static final long serialVersionUID = -1;

    public void init(){
        try{
            MessageFactory mf = MessageFactory.newInstance();
            SOAPMessage sm = mf.createMessage();

            System.out.println("About to fail");
            sm.writeTo(System.out);
            System.out.println();

            System.out.println("If you see this, it didn't fail.");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

当我在 eclipse (JDK 1.6.0_27) 中运行它时,它按预期工作,并得到以下输出:

When I run this in eclipse (JDK 1.6.0_27) It works as I would expect, and I get the following output:

About to fail
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body/></SOAP-ENV:Envelope>
If you see this, it didn't fail.

当我在浏览器中将它作为小程序运行时,我在 java 控制台中收到以下错误.

When I run this in a browser as an applet I get the following error in the java console.

About to fail
14-Sep-2011 1:20:51 PM com.sun.xml.internal.messaging.saaj.soap.MessageImpl saveChanges
SEVERE: SAAJ0540: Error during saving a multipart message
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(Unknown Source)
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(Unknown Source)
    at SOAPTest2.init(SOAPTest2.java:16)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.xml.internal.messaging.saaj.util.FastInfosetReflection.<clinit>(Unknown Source)
    at com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer.transform(Unknown Source)
    at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(Unknown Source)
    at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(Unknown Source)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(Unknown Source)
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getHeaderBytes(Unknown Source)
    ... 5 more
Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission com.sun.xml.internal.fastinfoset.parser.string-interning read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at com.sun.xml.internal.fastinfoset.Decoder.<clinit>(Unknown Source)
    ... 13 more

我不知道为什么会发生这种情况.我只是创建空的 SOAPMessage 并尝试将其写入 System.out.我没有访问任何本地资源.我在 MessageImpl.saveChanges 和 FastInfosetReflection 上做了很多搜索,但无济于事.请试试这个例子,如果你有任何想法,请告诉我.

I am at a loss as to why this is occurring. I am simply creating en empty SOAPMessage and trying to write it to System.out. I am not accessing any local resources. I have done much searching on MessageImpl.saveChanges and FastInfosetReflection to no avail. Please give the example a try, and let me know if you have any ideas.

恕我直言,鉴于上面不访问本地资源的最小示例,我要求任何告诉我签署 Jar 的答案都附有合理的解释.

Respectfully, I ask that any answers that tell me to sign my Jar be accompanied by a reasonable explanation given the minimal example above that does not access local resources.

推荐答案

绝对是签名问题.http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html

您可以使用该链接中的确切值进行尝试(在此示例中,唯一不同的是 jar 称为 sample.jar):

You can try it out with the exact values from that link (in this sample the only thing that is different is that the jar is called sample.jar):

  1. 构建一个名为 sample.jar 的 jar
  2. 运行:keytool -genkey -alias signFiles -keystore compstore -keypass kpi135 -dname "cn=jones" -storepass ab987c
  3. 运行:jarsigner -keystore compstore -storepass ab987c -keypass kpi135 -signedjar Ssample.jar sample.jar signFiles

我应该补充一点,我知道这是解决方案,因为我与 FuryComputers 合作......但我不知道为什么它是解决方案 - 其他人有任何想法吗?

I should add that I know this is the solution since I work with FuryComputers ... I have no idea why it is the solution though - anyone else have any ideas?

这篇关于Java Applet SOAPMessage 导致“SAAJ0540:保存多部分消息时出错"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆