com.fasterxml.jackson.databind.JsonMappingException: ApplicationObjectSupport instance [org.springframework.web.servlet.view.json.MappingJackson2JsonView: unnamed] does not run in an ApplicationContext (through reference chain: java.util.HashMap["modelAndView"]->org.springframework.web.servlet.ModelAndView["view"]->org.springframework.web.servlet.view.json.MappingJackson2JsonView["applicationContext"])
jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>RequestAttribute test</title>
</head>
<body>
<%
request.setAttribute("id", 84L); request.getRequestDispatcher("/attribute/requestAttribute.do").forward (request, response);
%>
</body>
</html>
и код контроллера:
@Controller
@RequestMapping("/attribute")
public class Attribute {
@Autowired
private RoleService roleService = null;
@RequestMapping("/requestAttribute")
public ModelAndView reqAttr( @RequestAttribute("id") Long id) {
ModelAndView mav= new ModelAndView();
Role role = roleService.getRole(id);
mav.addObject("role", role);
mav.setView(new MappingJackson2JsonView());
return mav;
}
}
и вывод исключения:
HTTP Status 500 - Внутренняя ошибка сервера
Тип отчета об исключении
Сообщение При обработке возникла исключительная ситуация [/WEB-INF/views/attr.jsp] в строке [12]
Описание Сервер обнаружил непредвиденное состояние, которое не позволило ему выполнить запрос.
Исключение
java.io.IOException: Возникла исключительная ситуация при обработке [/WEB-INF/views/attr.jsp] в строке [12]
9: 10: <%11: request.setAttribute ("id", 84L);12:> request.getRequestDispatcher ("/ attribute / requestAttribute.do"). Forward (запрос, ответ);13:%> 14: 15:
Stacktrace: org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:504) org.apache.jasper.servlet.JspServlet.serviceJspFile (Jspava: сервлет385) org.apache.jasper.servlet.JspServlet.service (JspServlet.java:329) javax.servlet.http.HttpServlet.service (HttpServlet.java:741) org.apache.tomcat.websocket.server.doFWsFilter.java:53) org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel (InternalResourceView.java:168) org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:304rame.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.spring.prme.spring.spring.prme.pr). Orgweb.servlet.DispatcherServlet.render (DispatcherServlet.java:1286) org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1041) org.springframework.web.serverv.Serv.Serv. Dispatcherorg.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:901) org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service (HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java.pr:)web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) корневая причинаЭкземпляр ApplicationObjectSupport [org.springframework.web.servlet.view.json.MappingJackson2JsonView: безымянный] не выполняется в ApplicationContext (через цепочку ссылок: java.util.HashMap ["modelAndView"] -> org.springframework.web.servlet.ModelAndView [ "вид"] -> org.springframework.web.servlet.view.json.MappingJackson2JsonView ["applicationContext"]) com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath (JsonMappingException.java:394) com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath (JsonMappingException.java.xapp com.jpg: 35).ser.std.StdSerializer.wrapAndThrow (StdSerializer.java:316) com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields (BeanSerializerBase.java:727) com.fasterxml.jackson.databind.erial.ize(BeanSerializer.java:155) com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField (BeanPropertyWriter.java:727) com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields:ava com.fasterxml.jackson.databind.ser.BeanSerializer.serialize (BeanSerializer.java:155) com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields (MapSerializer.java:722) com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:643) com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:33)com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize (DefaultSerializerProvider.java:480)
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue (DefaultSerializerProvider.java:319)
com.fasterxml.jackson.databind.ObjectWriter $ Prefetch.serialize (ObjectWriter.java:1396)
com.fasterxml.jackson.databind.ObjectWriter.writeValue (ObjectWriter.java:913)
org.springframework.web.servlet.view.json.AbstractJackson2View.writeContent (AbstractJackson2View.java:211)
org.springframework.web.servlet.view.json.AbstractJackson2View.renderMergedOutputModel (AbstractJackson2View.java:160)
org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:304)
org.springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1286)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1041)
org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:984)
org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:901)
org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service (HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service (HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53)
org.apache.jsp.WEB_002dINF.views.attr_jsp._jspService (attr_jsp.java:126)
org.apache.jasper.runtime.HttpJspBase.service (HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service (HttpServlet.java:741)
org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:329)
javax.servlet.http.HttpServlet.service (HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel (InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:304)
org.springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1286)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1041)
org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:984)
org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:901)
org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service (HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service (HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107)
Основная причина
java.lang.IllegalStateException: экземпляр ApplicationObjectSupport [org.springframework.web.servlet.view.json.MappingJackson2JsonView: неназванный] не выполняется в ApplicationContext
org.springframework.context.support.ApplicationObjectSupport.getApplicationContext (ApplicationObjectSupport.java:141)
sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField (BeanPropertyWriter.java:688)
com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields (BeanSerializerBase.java:719)
com.fasterxml.jackson.databind.ser.BeanSerializer.serialize (BeanSerializer.java:155)
com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField (BeanPropertyWriter.java:727)
com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields (BeanSerializerBase.java:719)
com.fasterxml.jackson.databind.ser.BeanSerializer.serialize (BeanSerializer.java:155)
com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields (MapSerializer.java:722)
com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:643)
com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize (MapSerializer.java:33)
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize (DefaultSerializerProvider.java:480)
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue (DefaultSerializerProvider.java:319)
com.fasterxml.jackson.databind.ObjectWriter $ Prefetch.serialize (ObjectWriter.java:1396)
com.fasterxml.jackson.databind.ObjectWriter.writeValue (ObjectWriter.java:913)
org.springframework.web.servlet.view.json.AbstractJackson2View.writeContent (AbstractJackson2View.java:211)
org.springframework.web.servlet.view.json.AbstractJackson2View.renderMergedOutputModel (AbstractJackson2View.java:160)
org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:304)
org.springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1286)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1041)
org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:984)
org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:901)
org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service (HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service (HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53)
org.apache.jsp.WEB_002dINF.views.attr_jsp._jspService (attr_jsp.java:126)
org.apache.jasper.runtime.HttpJspBase.service (HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service (HttpServlet.java:741)
org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:329)
javax.servlet.http.HttpServlet.service (HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel (InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:304)
org.springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1286)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1041)
org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:984)
org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:901)
org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:970)org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:861) javax.servlet.http.HttpServlet.service (HttpServlet.java:634) org.springframework.web.servlet.846) javax.servlet.http.HttpServlet.service (HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53) org.sringCharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107)