users@jersey.java.net

[Jersey] Re: jersey-spring depends on javax.ws.rs.core.Context, but no OSGi import

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 30 May 2011 17:02:32 +0200

Some OSGi tests are already in place. Look at the following modules:

samples/helloworld-osgi-webapp
samples/osgi-http-service
osgi
contribs/jersey-oauth/oauth-tests

All of them use the pax-exam maven plugin.
You can either add a new test into the contribs/spring module
or to the samples/spring-annotations example.
Yet another option would be to add a new sub-module
to the osgi umbrella module.

~Jakub

On 05/30/2011 02:28 PM, Ryan Stewart wrote:
> I can take a look at doing that. I've barely looked at the
> jersey-spring project source so far. Any advice on how you'd test for
> this in that project?
>
> On Mon, May 30, 2011 at 7:01 AM, Jakub Podlesak
> <jakub.podlesak_at_oracle.com <mailto:jakub.podlesak_at_oracle.com>> wrote:
>
>
> Hi Ryan,
>
> Good catch. Thanks.
>
> You are right, we are auto-generating the headers, and we do not test
> the jersey-spring module in OSGi.
>
> By any chance, just a question: would you be willing to provide a
> patch
> to fix that in the jersey-spring module ideally including some tests?
> The best way to do that would be to submit a bug report against Jersey
> and add the patch as a attachment.
>
> Thanks,
>
> ~Jakub
>
>
> On 05/28/2011 07:26 AM, Ryan Stewart wrote:
>
> When I try to start a
> com.sun.jersey.spi.spring.container.servlet.SpringServlet in
> an OSGi container, it fails with:
> java.lang.TypeNotPresentException: Type
> javax.ws.rs.core.Context not present
>
> The Context annotation isn't referenced directly, but by
> reflection. I'm guessing that the OSGi bundle headers are
> auto-generated, and the Context reference is missed because it
> isn't imported anywhere. Adding "javax.ws.rs.core" to the
> Import-Package header fixes the problem
>
> Relevant stacktrace follows:
>
> unavailable java.lang.TypeNotPresentException: Type
> javax.ws.rs.core.Context not present
> at
> sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:98)
> at
> sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:107)
> at
> sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
> at
> sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:50)
> at
> sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:120)
> at
> sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
> at
> sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:66)
> at java.lang.Class.getGenericSuperclass(Class.java:677)
> at
> com.sun.jersey.core.reflection.ReflectionHelper.resolveTypeVariable(ReflectionHelper.java:620)
> at
> com.sun.jersey.core.reflection.ReflectionHelper.resolveTypeVariable(ReflectionHelper.java:604)
> at
> com.sun.jersey.core.spi.factory.InjectableProviderFactory.getResolvedType(InjectableProviderFactory.java:160)
> at
> com.sun.jersey.core.spi.factory.InjectableProviderFactory.getMetaArguments(InjectableProviderFactory.java:142)
> at
> com.sun.jersey.core.spi.factory.InjectableProviderFactory.add(InjectableProviderFactory.java:93)
> at
> com.sun.jersey.core.spi.factory.InjectableProviderFactory$1.onAdd(InjectableProviderFactory.java:109)
> at
> com.sun.jersey.core.spi.factory.InjectableProviderFactory$1.onAdd(InjectableProviderFactory.java:107)
> at
> com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndServices(ProviderServices.java:201)
> at
> com.sun.jersey.core.spi.factory.InjectableProviderFactory.configure(InjectableProviderFactory.java:106)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1127)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:167)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:773)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:769)
> at
> com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:769)
> at
> com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
> at
> com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:609)
> at
> com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
>
>
>