Jeff Schmidt wrote:
> Hi Jakub:
>
> I too am having the problem with the InstantiationException and
> JSONListElementProvider when I try to use the Jersey 1.0.1 jars in
> Netbeans 6.5. I really need to start working with Craig's multipart
> API and I see it is included in 1.0.1. Jersey 1.0 is what is available
> in Netbeans 6.5. I tried to update Jersey by creating a new library in
> Netbeans and included the following jar files, which I basically got
> from the Jersey 1.0.1 dependencies page.
>
> ./asm-3.1.jar
> ./grizzly-servlet-webserver-1.8.6.3.jar
> ./http-20070405.jar
> ./jaxb-api-2.1.jar
> ./jaxb-impl-2.1.jar
> ./jaxb-xjc.jar
> ./jdom-1.0.jar
> ./jersey-atom-1.0.1.jar
> ./jersey-core-1.0.1.jar
> ./jersey-fastinfoset-1.0.1.jar
> ./jersey-json-1.0.1.jar
> ./jersey-server-1.0.1-javadoc.jar
> ./jersey-server-1.0.1.jar
> ./jettison-1.0.1.jar
> ./jsr173-api-1.0.jar
> ./jsr311-api-1.0.jar
> ./rome-0.9.jar
> ./stax-api-1.0-2.jar
>
> When starting up the app server (Tomcat or Glassfish) I get several:
>
> The provider class, class
> com.sun.jersey.impl.provider.entity.JSONListElementProvider, could not
> be instantiated
> java.lang.InstantiationException:
> com.sun.jersey.impl.provider.entity.JSONListElementProvider
>
> Browsing jersey-json-1.0.1.jar within Netbeans, I can see that class
> is abstract.
>
> When I tried the sample customer DB app as you suggested below, it
> worked just fine using the stock Jersey 1.0 library.
>
> What is the proper combination of jar files one uses to create a
> library in Netbeans 6.5 that will allow me to use the IDE to develop
> using Jersey 1.0.1?
>
One silly question ... do you actually have jersey-json-1.0.1 declared
as a dependency in your NB project? That won't happen by default, but
will be required if you want to use JSON representations.
In general, I have found it easier to just treat the relevant jar files
as file/jar dependencies, rather than use the built in NB version of
Jersey, because I'm always tending to do stuff that requires a newer
version. Of course, if you use Maven based projects (which NB also
supports, with the Maven plugin), then it's even easier :-).
Craig
> Thanks!
>
> Jeff
>
>
> On Jan 19, 2009, at 8:38 AM, Jakub Podlesak wrote:
>
>>
>> Hello Eric,
>>
>> On Sun, Jan 18, 2009 at 10:12:55AM -0600, Marsh Eric wrote:
>>> 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.
>>
>> I would recommend you to try resolve the above errors in the first place
>> as it seems something is wrong with your configuration.
>> Are you using the latest NetBeans 6.5? If so,
>> could you try to create a new project with:
>> [New Project]->[Samples]->[WebServices]->[Customer Database (RESTful)]
>> then try to deploy. Same errors?
>> Then please try to submit a new bug report against NetBeans RESTful
>> WS plugin at [1]
>> Another thing you may try is to run your NetBeans with a fresh userdir.
>> Then you need to use --userdir rest-app-nbdir command line option.
>>
>>
>>>
>>> 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
>>
>> The simplest test scenario to try out here is to
>>
>> - GET some data from a particular containee resource
>> - POST the very same *unchanged* data to the corresponding container
>> resource
>>
>> Then, you should get something like
>> Entity already exists exception (coming from db layer)
>> Which in fact means, you entity gets unmarshalled all right.
>> Could you please try out something similar (without touching the
>> data) at your application?
>>
>>
>>> 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 suspect that is the case. If the customer db application works for you,
>> you might want to check, you web app uses the same jersey related
>> libraries.
>> (Please make sure you do not mix jersey jar versions)
>>
>> If none of the above helps, would you be able to send out your project
>> files so that i could have a closer look?
>>
>> ~Jakub
>>
>> [1]http://www.netbeans.org/community/issues.html
>>
>>> 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?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> <mailto:users-unsubscribe_at_jersey.dev.java.net>
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>> <mailto:users-help_at_jersey.dev.java.net>
>>
>
> --
>
> Jeff Schmidt
>
> 535 Consulting
>
> jas_at_535consulting.com <mailto:jas_at_535consulting.com>
>
> (408) 205-7697
>
>
>
>
>