Hello,
I'm developing an iPhone application that needs to pass information
between the iPhone and a remote database. Using web services seemed to
be a good strategy so I downloaded the latest version of Netbeans,
spent a day or two reading and working through the web services
examples. Doing some web searches I found that most iPhone developers
are using JSON so I downloaded an iPhone JSON library and went to work
at developing a communications channel between the remote device and
the database.
I don't know if it makes any difference but I'm developing on a Mac.
First of all, when I tried to deploy I was getting some errors related
to JSON. They are:
SEVERE: The provider class, class
com.sun.jersey.impl.provider.entity.JSONJAXBElementProvider, could not
be instantiated
SEVERE: The provider class, class
com.sun.jersey.impl.provider.entity.JSONListElementProvider, could not
be instantiated
SEVERE: The provider class, class
com.sun.jersey.impl.provider.entity.JSONRootElementProvider, could not
be instantiated
I thought that I'd go back and look at those problems later as the app
did seem to deploy even with the errors.
It wasn't too tough getting the database to talk to the iPhone.
However I've spent something like a week and a half trying to get the
communications to work going the other way. Initially when I was
getting errors and exceptions I thought that my problem was that I
simply didn't understand the JSON protocol. Consequently I stopped
trying to get the iPhone to talk to the web services and started to
experiment with the netbeans "Test RESTful web services" web
interface. I would do a get to grab some data from my database, tweak
the results and try to POST them back to the database. I could never
get this to work. I had a number of returned error codes depending on
what I would try to POST but I finally focused on the fact that I was
getting messages similar to the following:
javax.ws.rs.WebApplicationException: javax.xml.bind.UnmarshalException
- with linked exception: [org.xml.sax.SAXParseException: Content is
not allowed in prolog.] at
converter.UriResolver.resolve(UriResolver.java:81)
I've been doing some reading and it appears that in Jersey JSON is
layered over XML. Since this exception appears to be coming from the
XML layer it looks like I would have to step through the Jersey source
to figure out what's going on. I suspect that the problem is related
to the exceptions that were happening on deployment that I cited
earlier.
I downloaded the source so that I could build and debug in the Jersey
and Grizzly layers. This took a couple of hours. To my surprise there
was a couple of places where the source wouldn't build as downloaded.
One is in ContainerResponse.java where the compiler complained that at
line 216 it couldn't find getMessageBodyWriterMediaTypes. Another
problem is at line 292 in BasicValidator.java where it couldn't find
ERROR_SUBRES_LOC_HAS_ENTITY_PARAM. I did some quick hacks just to get
the application to build. However it wouldn't deploy and at that point
I decided that I'd just spent too much time on this and decided to
yell for help.
I'd really like to be able to use Glassfish, Netbeans and Jersey but I
really seem to be stuck. If I can't get this to fly I may have to
backtrack and do something entirely different. It doesn't appear that
I can do a remote database connection from the iPhone so web services
looks like the best solution. The problem appears to be at the server
end, not the iPhone end anyway. I'm really kind of surprised that I've
had so much trouble. Regardless, I need to break through this
roadblock and get this app done.
Suggestions or help anyone?