As a temporary step, instead of reading in your HubSubscriberResource
via a Spring application context file, can you try directly
hardcoding/instantiating it and see what happens? That will let us know
whether the problem is with the Spring config or getSingletons().
There are actually not two entries for hubSubscriberResource, just one
(the other is "H"ubSubscriber...) Perhaps it's your Spring config file
causing those classes to be registered.
Finally, if nothing else works, you might be able to register your
@Provider (providing it has that annotation) by adding it to
getClasses(). CXF at least allows that, and it still treats it as a
singleton (AFAIK):
https://github.com/gmazza/jersey-samples-on-cxf/blob/master/simple-servlet/src/main/java/com/sun/jersey/samples/servlet/resources/MyApplication.java
HTH,
Glen
On 02/28/2012 12:00 PM, Farrukh Najmi wrote:
>
> With help from Alexey Stashok on the Grizzly list I have overcome
> earlier problems with an issue in Grizzly with webstart.
> Now I am close and would really appreciate if someone from jersey team
> / community can get me over the hump on the following simple issue...
>
> Recall that when running a jersey endpoint within javawebstart could
> not use automatic package scanning:
>
> http://jersey.576304.n2.nabble.com/jersey-and-java-web-start-td4506576.html
>
> So I modified my code to use explcit declaration of root resource and
> provider classes. This seems to work for my root resource singleton
> but is not working for my provider class.
>
> Here is what my Provider class looks like:
>
> @Produces("application/atom+xml")
> @Provider
> public class SyndFeedReader implements MessageBodyReader<SyndFeed> {
> ...
> }
>
> Here is how I explicitly declare the root resource singleton and my
> provider class...
>
> public class HubSubscriber extends javax.ws.rs.core.Application {
>
> ....
>
> @Override
> public Set<Class<?>> getClasses() {
> Set<Class<?>> s = new HashSet<Class<?>>();
> s.add(SyndFeedReader.class); //My Provider
> class that does not seem to be detected
> return s;
> }
>
> @Override
> public Set<java.lang.Object> getSingletons() {
> Set<Object> s = new HashSet<Object>();
>
> HubSubscriberResource hsr = (HubSubscriberResource)
> subApplicationContext.getBean("HubSubscriberResource");
> s.add(hsr);
> return s;
> }
>
>
> ....
>
> }
>
> Here is what the LoggingFilter and other logs are logging on my app
> that implements the jersey server endpoint above.
>
> Some odd things I notice are:
>
> * Why are there two entries for INFO: Registering Spring bean,
> hubSubscriberResource?
> * Why is my SyndFeedReader provider class not being registered as a
> provider class?
>
>
> Feb 28, 2012 11:42:13 AM
> com.sun.jersey.spi.spring.container.servlet.SpringServlet getContext
> INFO: Using default applicationContext
> Feb 28, 2012 11:42:13 AM
> com.sun.jersey.spi.spring.container.SpringComponentProviderFactory
> registerSpringBeans
> INFO: Registering Spring bean, hubSubscriberResource, of type
> org.freebxml.omar.pubsub.subscriber.HubSubscriberResource as a root
> resource class
> Feb 28, 2012 11:42:13 AM
> com.sun.jersey.spi.spring.container.SpringComponentProviderFactory
> registerSpringBeans
> INFO: Registering Spring bean, HubSubscriberResource, of type
> org.freebxml.omar.pubsub.subscriber.HubSubscriberResource as a root
> resource class
> Feb 28, 2012 11:42:13 AM
> com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
> INFO: Initiating Jersey application, version 'Jersey: 1.10 11/02/2011
> 03:53 PM'
> Feb 28, 2012 11:42:15 AM
> com.sun.jersey.api.container.filter.LoggingFilter filter
> INFO: 1 * Server in-bound request
> 1 > GET
> http://localhost:9075/wellgeo/adminui/rest/pubsub/subscriber/15e347cf-9f0b-4afb-9427-e6c1982c9f7e?hub.mode=subscribe&hub.topic=http%3A%2F%2Flocalhost%3A8080%2Fomar-server%2Frest%2Fevents%2Fall&hub.challenge=60fdc38c-b224-449c-b4aa-f3a0b760c4b5&hub.lease_seconds=3610&hub.verify_token=79fc36ef-ea52-46bf-98b4-ac14b122234c
> 1 > user-agent: ROME-Certiorem
> 1 > host: localhost:9075
> 1 > accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> 1 > connection: keep-alive
> 1 >
>
> Feb 28, 2012 11:42:15 AM org.rometools.certiorem.sub.Subscriptions
> validate
> FINE: Handling validation request for id
> 15e347cf-9f0b-4afb-9427-e6c1982c9f7e
> Feb 28, 2012 11:42:15 AM org.rometools.certiorem.sub.Subscriptions
> validate
> FINE: Validated. Returning 60fdc38c-b224-449c-b4aa-f3a0b760c4b5
> Feb 28, 2012 11:42:15 AM
> com.sun.jersey.api.container.filter.LoggingFilter$Adapter finish
> INFO: 1 * Server out-bound response
> 1 < 200
> 1 < Content-Type: text/html
> 1 <
> 60fdc38c-b224-449c-b4aa-f3a0b760c4b5
>
> .... Above request is processed fine indicating that my singleton root
> resource HubSubscriberResource is working fine
>
> Feb 28, 2012 11:42:48 AM
> com.sun.jersey.api.container.filter.LoggingFilter filter
> INFO: 2 * Server in-bound request
> 2 > POST
> http://localhost:9075/wellgeo/adminui/rest/pubsub/subscriber/65e6c143-5f8e-4488-ac96-4cb97e52ad24
> 2 > content-type: application/atom+xml
> 2 > user-agent: Java/1.6.0_20
> 2 > host: localhost:9075
> 2 > accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> 2 > connection: keep-alive
> 2 > content-length: 2211
> 2 >
> <?xml version="1.0" encoding="UTF-8"?>
> <feed xmlns="http://www.w3.org/2005/Atom"
> xmlns:dc="http://purl.org/dc/elements/1.1/">
> <title>ebXML RegRep All Events Feed</title>
> <link rel="alternate"
> href="http://localhost:8080/omar-server/rest/events/all" />
> <subtitle>A feed of all AuditableEvents generated by ebXML RegRep
> server</subtitle>
> <id>http://localhost:8080/omar-server/rest/events/all</id>
> <dc:creator>ebXML RegRep Server</dc:creator>
> <entry>
> <link rel="alternate"
> href="http://localhost:8080/omar-server/rest/registryObjects/urn:uuid:9ee59029-a855-45ca-9290-af1f45309d5a"
> />
> <author>
> <name>rod</name>
> </author>
> <id>urn:uuid:9ee59029-a855-45ca-9290-af1f45309d5a</id>
> <updated>2012-02-28T16:42:33Z</updated>
> <published>2012-02-28T16:42:33Z</published>
> <content type="text/xml">
> ...
> </content>
> <dc:creator>rod</dc:creator>
> <dc:date>2012-02-28T16:42:33Z</dc:date>
> </entry>
> </feed>
>
>
>
> Feb 28, 2012 11:42:48 AM com.sun.jersey.spi.container.ContainerRequest
> getEntity
> *SEVERE: A message body reader for Java class
> com.sun.syndication.feed.synd.SyndFeed, and Java type interface
> com.sun.syndication.feed.synd.SyndFeed, and MIME media type
> application/atom+xml was not found.*
> The registered message body readers compatible with the MIME media
> type are:
> */* ->
> com.sun.jersey.core.impl.provider.entity.FormProvider
> com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider
> com.sun.jersey.core.impl.provider.entity.StringProvider
> com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
> com.sun.jersey.core.impl.provider.entity.FileProvider
> com.sun.jersey.core.impl.provider.entity.InputStreamProvider
> com.sun.jersey.core.impl.provider.entity.DataSourceProvider
> com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
> com.sun.jersey.core.impl.provider.entity.ReaderProvider
> com.sun.jersey.core.impl.provider.entity.DocumentProvider
>
> com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
> com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
> com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
> com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
> com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
> com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
> com.sun.jersey.core.impl.provider.entity.EntityHolderReader
>
> Feb 28, 2012 11:42:48 AM
> com.sun.jersey.api.container.filter.LoggingFilter$Adapter finish
> INFO: 2 * Server out-bound response
> 2 < 415
> 2 <
>
>
> ............. Above POST request fails because it seems that my
> SyndFeedReader provider class is not getting used.
> --
> Regards,
> Farrukh Najmi
>
> Web:http://www.wellfleetsoftware.com
>
--
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza