users@jersey.java.net

Re: [Jersey] ExceptionMapper and constructor injection of _at_Context UriInfo ?

From: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Thu, 23 Jul 2009 10:43:05 -0700

Morten wrote:
> --- Den tors 23/7/09 skrev Paul Sandoz <Paul.Sandoz_at_Sun.COM>:
>
>>> Unfortunately, jersey gives an error that the class
>>>
>> can't be instantiated (assumingly because it does not
>> support injection of the provider).
>>
>> Any more information on the error? stack trace?
>>
>
> Sorry for leaving this out. Here is the stack trace:
>
> SEVERE: The provider class, class com.test.ws.controller.CustomExceptionMapper, could not be instantiated. Processing will continue but the class will not be utilized
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:160)
> at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:140)
> at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:159)
> at com.sun.jersey.core.spi.component.ProviderFactory._getComponentProvider(ProviderFactory.java:152)
> at com.sun.jersey.core.spi.component.ioc.IoCProviderFactory.wrap(IoCProviderFactory.java:106)
> at com.sun.jersey.core.spi.component.ioc.IoCProviderFactory._getComponentProvider(IoCProviderFactory.java:87)
> at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:146)
> at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:185)
> at com.sun.jersey.core.spi.component.ProviderServices.getProviders(ProviderServices.java:95)
> at com.sun.jersey.server.impl.application.ExceptionMapperFactory.<init>(ExceptionMapperFactory.java:67)
> at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:570)
> at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:168)
>
>
>
FWIW, I've seen this type of thing when the constructor of my class
itself threw an exception (like an NPE or something). It might be worth
looking for something like that.

Craig
>> Many of the internal providers supplied by Jersey use
>> constructor injection. I did a quick test and it works for
>> me e.g. i modified the helloworld sample [1] resource class
>> to be:
>>
>
> Hmm. Stange. Are you using another sw cfg then I am (I am using newest releases 1.1.1-ea with Sun's HTTPServer on JDK1.6_0_13 on Mac OS 10.5 )
>
> P.S. Thanks for your prompt replies to my mails on this mailing list. Great support!
>
> Cheers,
> Morten
>
>
> Trænger du til at se det store billede? Kelkoo giver dig gode tilbud på LCD TV! Se her http://dk.yahoo.com/r/pat/lcd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>