解决:java.lang.IllegalArgumentException: id to load is required for loading

解决:java.lang.IllegalArgumentException: id to load is required for loading

6541发表于2016-07-18

今天调试Spring mvc时输入地址:http://localhost:8081/LanhuSpringDemo1/json/user2

出现了下面错误:


HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: id to load is required for loading


type Exception report

message Request processing failed; nested exception is java.lang.IllegalArgumentException: id to load is required for loading

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: id to load is required for loading
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

java.lang.IllegalArgumentException: id to load is required for loading
org.hibernate.event.LoadEvent.<init>(LoadEvent.java:89)
org.hibernate.event.LoadEvent.<init>(LoadEvent.java:61)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:1002)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
com.lanhusoft.dao.hibernate.UserInfoImpl.GetModelByID(UserInfoImpl.java:32)
com.lanhusoft.controllers.UserController.get(UserController.java:26)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
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:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.67 logs.

Apache Tomcat/7.0.67

Controller代码:

可以看到上面有一个参数oid为没提供值,所以报错。

把地址改为:http://localhost:8081/LanhuSpringDemo1/json/user2?oid=7F3AA54A-D9FF-4ACD-B04F-06CBD8719E77

就不会报错了。


小编蓝狐