You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by Raja Subramanian <rs...@pcomm.hfi.unimelb.edu.au> on 2004/09/01 17:37:21 UTC

workaround for xmlrpc-client exception in applet context

Hi,

I have started using xmlrpc-1.2-b1 as a client and am extremely pleased
with it.  My thanks to all the developers for their efforts.

When I run my application as a standalone app, all goes well.  But when
I run the same as an (unsigned) applet, the following exception is
raised.  Yes, yes, I'm aware of applet restrictions and such.

===== my code
import org.apache.xmlrpc.secure.SecureXmlRpcClient;
...
    try {
        fetchMethod = new SecureXmlRpcClient(fetch);
        fetchMethod.setBasicAuthentication(user, passwd);
    } catch (MalformedURLException e) {
        System.err.println("ERROR: Bad URL " + e);
    }
...
    // This bombs when called from applet context!
    result = (Hashtable) fetchMethod.execute("fetchJob", new Vector());
=====


===== Exception raised
java.security.AccessControlException: access denied (java.util.PropertyPermission org.apache.xmlrpc.TypeFactory read)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
        at java.security.AccessController.checkPermission(AccessController.java:401)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
        at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1276)
        at java.lang.System.getProperty(System.java:573)
        at org.apache.xmlrpc.XmlRpc.<init>(XmlRpc.java:201)
        at org.apache.xmlrpc.XmlRpcClient$Worker.<init>(XmlRpcClient.java:325)
        at org.apache.xmlrpc.XmlRpcClient.getWorker(XmlRpcClient.java:234)
        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:160)
        ...
=====

The offending line is in ./org/apache/xmlrpc/XmlRpc.java line 201.  The
following change to XmlRpc() seems to fix the problem for me.  For the
record, I'm using java 1.4.2_04 on linux.  I have not tested on other
platforms.

===== XmlRpc.java
protected XmlRpc()
{
//  System.get...() always returns null on my box anyway!
//  this(System.getProperty(TypeFactory.class.getName()));

    this((String) null);
}
=====

I admit that my workaround is too crude, but can someone offer a better
solution that is more acceptable for all?  Can someone help?

- Raja


Re: workaround for xmlrpc-client exception in applet context

Posted by "Life is hard, and then you die" <ro...@innovation.ch>.
On Thu, Sep 02, 2004 at 01:37:21AM +1000, Raja Subramanian wrote:
> When I run my application as a standalone app, all goes well.  But when
> I run the same as an (unsigned) applet, the following exception is
> raised.  Yes, yes, I'm aware of applet restrictions and such.
[snip]
> The offending line is in ./org/apache/xmlrpc/XmlRpc.java line 201.  The
> following change to XmlRpc() seems to fix the problem for me.  For the
> record, I'm using java 1.4.2_04 on linux.  I have not tested on other
> platforms.
> 
> ===== XmlRpc.java
> protected XmlRpc()
> {
> //  System.get...() always returns null on my box anyway!
> //  this(System.getProperty(TypeFactory.class.getName()));
> 
>     this((String) null);
> }
> =====
> 
> I admit that my workaround is too crude, but can someone offer a better
> solution that is more acceptable for all?  Can someone help?

Just catch the exception:

      try
      {
          this(System.getProperty(TypeFactory.class.getName()));
      }
      catch (SecurityException e)
      {
          this((String) null);
      }


  Cheers,

  Ronald