Java Object from XML Using Only AppEngine

Posted on 2010-11-23
Last Modified: 2012-05-10
Greetings AppEngine experts,
   I am working on a standalone Java program that will interact with a Google AppEngine app that I am also working on. It does so using the XMPP chat protocol. On the client-side, I need to be able to "pack" a POJO (Plain Old Java Object) into an XML chat packet (the easy part), and pull it back out on the server-side (the hard part). I will try to explain in as much detail as possible.

  On the client end, this is very easy with the Smack library:
To Set the Value:
msg.setProperty("TheIntVector", myIntVector);
To Get it Back:
Vector<Integer> v = (Vector<Integer>) packet.getProperty("TheIntVector");

  The reason the server-side is not as straightforward is that the JRE for AppEngine is limited to only classes on an approved WhiteList:
- Google's own XMPP package is much more limited than Smack. I can get the XML chat packet, but the package does not include a way to pull out an Object.
- Also, Easy-To-Use (i.e. one-line-only) XML utilities that I would normally use are not usable in this case because of AppEngine restrictions. I am limited to what's in that list.

The one-size-fits all approach of Smack suits us very well because we need to send a wide variety of types, many of which are custom types in an inheritance hierarchy. This very small part of the project has turned into a hangup because of AppEngine's restrictions. We want to avoid doing a SAX/DOM parsing "mini project" for something that should have only taken 1-2 lines of code. This is where I hope to tap your plentiful brains, Experts.

So my question is this:
   Using Only classes in the Whitelist, what is the simplest (i.e. fewest lines) way to get a Java Object from inside an XML packet?

Here is the XML from the code above.
<message id="84HBN-5" to="" from="" type="error">
  <body>Vector of Ints Test</body>
<properties xmlns="">

Open in new window

Question by:tau161
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
LVL 16

Accepted Solution

Valeri earned 500 total points
ID: 34249063
According to me XStream is all you need

Author Comment

ID: 34260861
Hello Valeri. Thank you for responding.
   I initially ruled out XStream because of incompatibility issues. Just looked it up again after seeing your post. Again I found mention of requests (~2009) for a patch to make XStream AppEngine compatible, but I can't find any mention online of the XStream developers actually releasing an out-of-the-box  AppEngine-friendly version.
LVL 16

Assisted Solution

Valeri earned 500 total points
ID: 34261490
I was thinking that XStream uses very simple /reflection / classes and it will work everywhere without any problems, but as I can see it's not true :-(
Here is a workaround for G App Engine, hope it will help you:
sorry that I recommended you this library! I didn't know about the problems with GAE.
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.


Author Comment

ID: 34298232
That link looks like exactly what I need. Thank you.
One question, though. It references a patch for XStream. I have a copy of the patch file now, but I can find no instructions on the XStream site (or elsewhere) for how to actually apply the patch. There are plenty of links to posts about such-and-such a patch for such-and-such a problem, but they all skip over the act of integrating the patch. Have you had to do this before? If so, how?
LVL 16

Assisted Solution

Valeri earned 500 total points
ID: 34301817
such as patches are applied by cvs/svn as I know. But I've never applied any patches. It describes in which classes which lines to be removed and which lines to be inserted. But I read that this patch has helped of some people to start their apps with GAE, but was completely useless for some other people...:-( It's not sure that it will help you.
But I found this article for you:
it refers to this project:
You can try to apply the patch and to test your app, OR to try this "Simple" library.

Author Comment

ID: 34443551
Apologies for the long delay. I got caught up in an unrelated project.
   I applied the patch to the version listed on the patch download page. Unfortunately it gave me several merge conflicts. I tried resolving them line by line, but had no success. I found some posts where other users met with the same conflicts even though they were also using the correct patch on the correct version, but no solutions to that problem were ever posted. Thank you for taking the time to answer.
   I am still convinced that you are right, and that XStream+Patch is exactly what I am looking for. I just need to find a solution to the 'apply' conflicts.
LVL 16

Assisted Solution

Valeri earned 500 total points
ID: 34446996
May be it's better to use Simple!
LVL 16

Assisted Solution

Valeri earned 500 total points
ID: 34449385
May be you have missed my previous message. I mean this one #34301817.
In this article one developer explains more about Simple and that it works perfectly with GAE.
Hope it will help you to fix your problem. He says that Simple is faster than XStream as well.
XStream is also good, but obviously it has problems with GAE.

Author Comment

ID: 34487576
I'm going to go ahead and award the points.  Valeri, thank you for all help.  Eventually I will get back to this project and, it does indeed look like Simple should work fine for that.

Author Closing Comment

ID: 34487589
Answers accepted.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question