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)
>