[seam-issues] [JBoss JIRA] (SEAMREST-58) NullPointerException when templating enabled

anil halil (JIRA) jira-events at lists.jboss.org
Mon Sep 10 10:07:34 EDT 2012


anil halil created SEAMREST-58:
----------------------------------

             Summary: NullPointerException when templating enabled
                 Key: SEAMREST-58
                 URL: https://issues.jboss.org/browse/SEAMREST-58
             Project: Seam REST
          Issue Type: Bug
          Components: Templating
    Affects Versions: 3.1.0.Final
            Reporter: anil halil


I enabled solder catch with this annotations
@ExceptionMapping.List({
    @ExceptionMapping(exceptionType = NotFoundException.class, status = 404, message = "Requested resource does not exist."),
    @ExceptionMapping(exceptionType = IllegalArgumentException.class, status = 400, message = "Illegal argument value.")
})

which should produce 404 for unknown/not mapped urls.  But when i enter an unknown url it produces

java.lang.NullPointerException
	at org.jboss.seam.rest.templating.TemplatingMessageBodyWriter.findAnnotation(TemplatingMessageBodyWriter.java:112)
	at org.jboss.seam.rest.templating.TemplatingMessageBodyWriter.isWriteable(TemplatingMessageBodyWriter.java:97)
	at org.jboss.seam.rest.templating.TemplatingMessageBodyWriter$Proxy$_$$_WeldClientProxy.isWriteable(TemplatingMessageBodyWriter$Proxy$_$$_WeldClientProxy.java)
	at org.jboss.resteasy.spi.ResteasyProviderFactory.getMessageBodyWriter(ResteasyProviderFactory.java:1033)
	at org.jboss.resteasy.core.SynchronousDispatcher.resolveContentTypeByAccept(SynchronousDispatcher.java:615)
	at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:591)
	at org.jboss.resteasy.core.SynchronousDispatcher.writeFailure(SynchronousDispatcher.java:433)
	at org.jboss.resteasy.core.SynchronousDispatcher.executeExceptionMapper(SynchronousDispatcher.java:335)
	at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:235)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:129)
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:594)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1365)
	at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
	at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:483)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:351)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
	at java.lang.Thread.run(Thread.java:722)

The problem arise from 

protected MediaType resolveContentTypeByAccept(List<MediaType> accepts, Object entity)
   {
      if (accepts == null || accepts.size() == 0 || entity == null)
      {
         return MediaType.WILDCARD_TYPE;
      }
      Class clazz = entity.getClass();
      Type type = null;
      if (entity instanceof GenericEntity)
      {
         GenericEntity gen = (GenericEntity) entity;
         clazz = gen.getRawType();
         type = gen.getType();
      }
      for (MediaType accept : accepts)
      {
         if (providerFactory.getMessageBodyWriter(clazz, type, null, accept) != null)
         {
            return accept;
         }
      }
      return MediaType.WILDCARD_TYPE;
   }

as you see getMessageBodyWriter has null as annotations parameter and TemplatingMessageBodyWriter findAnnotation function has this line

for (Annotation a : annotations) 

which rises NullPointerException

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list