Sorry, I should have said that this was occurring with the 0.5-ea
release of Jersey. It's very likely that this was changed because there
is a comment there about what to do when a no-arg constructor doesn't
exist. I probably should have checked trunk before asking about it.
Thanks for the looking into this for me though. I really appreciate
that you guys have been good about responding positively to my feedback.
Rich
Jakub Podlesak wrote:
> Hi Rich,
>
> Constructor for a resource class is taken from
>
> resourceClass.getConstructors()[0]
>
> (in [com.sun.ws.rest.api.model.AbstractResource:49])
>
> If no such constructor exists (i.e. getConstructors() returns an empty array),
> then the resource instance is being constructed via:
>
> resource = abstractResource.getResourceClass().newInstance();
>
> (in [com.sun.ws.rest.impl.resource.PerRequestProvider]
> or [com.sun.ws.rest.impl.resource.SingletonProvider])
>
> However, as Paul already mentioned, the original exception
> being caught by [com.sun.ws.rest.api.model.AbstractResource]
> was just printed out without any other impact (besides that
> the abstract resource model did not have any constructor set).
>
> Could you please confirm whether you are still blocked?
>
> Thanks,
>
> ~Jakub
>
>
>
>
> On Mon, Nov 26, 2007 at 12:10:08PM +0100, Jakub Podlesak wrote:
>
>> Hi Rich,
>>
>> please see in line...
>>
>> On Sat, Nov 24, 2007 at 11:00:55PM -0800, Richard Wallace wrote:
>>
>>> Hello,
>>>
>>> I'm trying to get Guice working with Jersey and am running into one
>>> roadblock. The thing is that I really like to use constructor injection
>>> whenever possible. I want to do this with my resources. To that effect
>>> I've changed the GuiceProvider.getInstance() method from Christians blog
>>> post to
>>>
>>> public Object getInstance(ResourceProviderContext context)
>>> throws ContainerException {
>>> Object resource = getInjector(context).getInstance(resourceClass);
>>> context.injectDependencies(resource);
>>> return resource;
>>> }
>>>
>>> That way Guice is completely responsible for creating and injecting
>>> dependencies into the resource object without the need for a no-arg
>>> constructor.
>>>
>>> This should work. But I'm running into a problem because Jersey is
>>> building an AbstractResource internally to track information about the
>>> resource class. This wouldn't be a problem except that one of the
>>> things that it is trying to find is a no-arg constructor. Why does it
>>> do that? I've search for references to the getConstructor() method and
>>> usages of the AbstractResourceConstructor class, but they are only used
>>> within AbstractResource and it doesn't actually do anything with the
>>> information, it seems to get it just to have it.
>>>
>>> Would it be possible to eliminate this completely and get rid of the
>>> no-arg constructor requirement?
>>>
>> I have reworked the code getting a resource constructor
>> on [jersey-resourcemodel] branch. The information is then used
>> by the runtime model, which is being built upon the abstract model.
>> The no-arg ctor requirement no longer exist there.
>>
>> Let me check, if it is ok to merge the changes from the branch
>> into the main trunk. Then I will get back to you.
>>
>> Thanks,
>>
>> ~Jakub
>>
>>
>>
>>
>>> Thanks,
>>> Rich
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>