users@jersey.java.net

[Jersey] Re: JsonMessageWriter not working under Netbeans 6.9.1

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Wed, 9 Feb 2011 06:43:33 -0800 (PST)

Gili wrote:
>
> SEVERE: A message body writer for Java class
> com.amayagaming.moneywheel.server.data.User, and Java type class
> com.amayagaming.moneywheel.server.data.User, and MIME media type
> application/json was not found
>

I figured it out. Classic case of user error. My servlet context was defined
as:

public class GuiceConfig extends GuiceServletContextListener
{
  @Override
  protected Injector getInjector()
  {
    return Guice.createInjector(new JerseyServletModule()
    {
      @Override
      protected void configureServlets()
      {
        Map<String, String> params = Maps.newHashMap();
        params.put(ServletContainer.RESOURCE_CONFIG_CLASS,
          ClasspathResourceConfig.class.getName());
        params.put(PackagesResourceConfig.PROPERTY_PACKAGES,
          GuiceConfig.class.getPackage().getName());
        serve("/*").with(GuiceContainer.class);
      }
    });
  }
}

Notice the last line ignores the parameters declared above it. The line
should read:

        serve("/*").with(GuiceContainer.class, params);

PS: Is it possible to update
http://jersey.java.net/nonav/apidocs/latest/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html
to contain an example of using RESOURCE_CONFIG_CLASS and PROPERTY_PACKAGES
parameters? It took me a while to figure this out.

Thanks,
Gili
-- 
View this message in context: http://jersey.576304.n2.nabble.com/JsonMessageWriter-not-working-under-Netbeans-6-9-1-tp6005749p6007871.html
Sent from the Jersey mailing list archive at Nabble.com.