Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

Access Denied Error in Google App Engine

Started by Pavithra Jeyasingh -   in API Authentication

I'm using Private Application supported by Xero. I have registered my application in Demo Company   and uploaded my public certificate. The sample provided  works fine locally, and i could connect to Xero for submitting invoice. But i'm getting an exception
"access denied (java.lang.RuntimePermission modifyThreadGroup)", when i deploy the same in google app-engine. If this cannot be made possible i have to go with another accounting API available in the market.

Have given you the Stack trace of exception.

Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
………..
………..
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:416)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
    at net.oauth.client.httpclient3.HttpClient3.execute(HttpClient3.java:96)
    at net.oauth.client.OAuthClient.access(OAuthClient.java:325)
    at net.oauth.client.OAuthClient.invoke(OAuthClient.java:306)
    at net.oauth.client.OAuthClient.invoke(OAuthClient.java:262)
    at com.cpt.util.xero.XeroClient.postInvoices(XeroClient.java:139)..
Hi there

That error message doesn't give a lot of detail. As you have mentioned, it works fine on your local machine, so the issue is not with the API itself, but if you were able to get a more detailed error message as to my it is saying access denied, we might be able to figure this out further.
 

Ronan Quirke (Community Manager)  

Have given you the detailed Stack trace of exception.


Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:355)
at java.security.AccessController.checkPermission(AccessController.java:567)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
at java.lang.Thread.init(Thread.java:353)
at java.lang.Thread.<init>(Thread.java:437)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ReferenceQueueThread.<init>(MultiThreadedHttpConnectionManager.java:1080)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.storeReferenceToConnection(MultiThreadedHttpConnectionManager.java:173)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.access$900(MultiThreadedHttpConnectionManager.java:65)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ConnectionPool.createConnection(MultiThreadedHttpConnectionManager.java:771)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:476)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:416)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at net.oauth.client.httpclient3.HttpClient3.execute(HttpClient3.java:96)
at net.oauth.client.OAuthClient.access(OAuthClient.java:325)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:306)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:262)
at com.cpt.util.xero.XeroClient.postInvoices(XeroClient.java:139)


The exception raises at the below line of XeroClient class,
OAuthMessage response = client.invoke(accessor, OAuthMessage.POST, endpointUrl + "Invoices", OAuth.newList("xml", contactsString));

Thanks & Regards,
Pavithra J
 

Pavithra Jeyasingh  

The problem is using invalid classes on appengine.

For other people coming here and having the same issues... see this blog:
http://www.aschroder.com/2013/12/accessing-the-xero-api-for-public-applications-in-java/

Also you may have issues with the exception content not being retrieved by net.oauth.URLConnectionClient. I got around this by using connection.getErrorStream() in the URLConnectionResponse.openBody() method when there response is an error.

Now everything is working successfully on appengine.

Good luck.
 

Joachim Davies