Reputation: 33
I'm getting error at "User.findById(user_id)" not frequently but some times, I don't know why. What causes this error?
Note : I'm using Play version 1.2.3
Thanks.
Function where throws exception;
public static void getMemberProfile(Long user _id){
User sessionUser = getUser();
User user = User.findById(user_id);
Error message ;
2012-02-12T13:06:42+00:00 app[web.1]:
2012-02-12T13:06:42+00:00 app[web.1]: Execution exception (In /app/controllers/UserApi.java around line 470)
2012-02-12T13:06:42+00:00 app[web.1]: IllegalArgumentException occured : id to load is required for loading
2012-02-12T13:06:42+00:00 app[web.1]:
2012-02-12T13:06:42+00:00 app[web.1]: play.exceptions.JavaExecutionException: id to load is required for loading
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
2012-02-12T13:06:42+00:00 app[web.1]: at Invocation.HTTP Request(Play!)
2012-02-12T13:06:42+00:00 app[web.1]: Caused by: java.lang.IllegalArgumentException: id to load is required for loading
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:89)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:61)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1002)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:614)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:589)
2012-02-12T13:06:42+00:00 app[web.1]: at play.db.jpa.JPQL.findById(JPQL.java:34)
2012-02-12T13:06:42+00:00 app[web.1]: at models.User.findById(User.java)
2012-02-12T13:06:42+00:00 app[web.1]: at controllers.UserApi.getMemberProfile(UserApi.java:470)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159)
Upvotes: 3
Views: 28467
Reputation: 53
Why don't you check the routes file
I am also a beginner but I learned that from my senior
---------------
# Import CRUD routes
* /admin module:crud
---------------
must be above
# Catch all
* /{controller}/{action} {controller}.{action}
If you put that under this it's not gonna work
shortly
# Catch all
* /{controller}/{action} {controller}.{action}
MUST be the last line.
Upvotes: 3
Reputation: 692131
You get this exception because you pass a null user_id
to the method.
It's easily findable by
org.hibernate.event.LoadEvent
Upvotes: 8