ELException Error Reading ... on type
Asked Answered
T

1

9

I'm getting an exception when displaying my jsp page that tries to invoke a function defined getCurrentlocation() in type Person. The function is invoked by ${person.currentlocation} in the jsp file.

type Exception report

message javax.el.ELException: Error reading 'currentlocation' on type **.person.Person

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

exception 

org.apache.jasper.JasperException: javax.el.ELException: Error reading 'currentlocation' on type **.person.Person

I am pretty new to jsp technology. Maybe someone could help me out!

Thanks, Benjamin

Therrien answered 17/9, 2012 at 17:29 Comment(3)
Could be a typo, perhaps getCurrentLocation()? Also check that the getter is public.Mueller
I also checked for typos... this function is not a getter but its public. it calculates the return value from some fields of the object.Therrien
sorry guys, found the problem... i ran out of an array's bounds... thanks anyway!Therrien
H
23

This particular ELException is a wrapper exception. This is usually only thrown when invoking the getter method itself has thrown an exception. Something like the following is happening under the covers when this ELException is been thrown:

Object bean;
String property;
Method getter;
// ...

try {
    getter.invoke(bean);
} catch (Exception e) {
    String message = String.format("Error reading '%s' on type %s", property, bean.getClass().getName());
    throw new ELException(message, e);
}

You should look further down in the stacktrace for the real root cause. The complete stacktrace is usually just available in server logs. The real root cause is the bottommost exception of the stacktrace. E.g. the below one is caused by a NullPointerException being thrown in the getter method.

javax.el.ELException: Error reading 'currentlocation' on type **.person.Person
    at ...
    at ...
    at ...
Caused by: java.lang.NullPointerException
    at **.person.Person.getCurrentlocation(Person.java:42)
    at ...
    at ...

The information about the real root cause (the exception type and the line number) should give you enough clues to nail down the problem.

Again, this is not a problem with EL in general. It's just your own code which caused the problem.

Heteroecious answered 17/9, 2012 at 18:54 Comment(1)
Thank you for that information. I already found my mistake! (IndexOutOfBounds...). BenjaminTherrien

© 2022 - 2024 — McMap. All rights reserved.