Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ELException Error Reading ... on type

Tags:

java

jsp

el

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

like image 849
Benjamin Ihrig Avatar asked Sep 17 '12 17:09

Benjamin Ihrig


1 Answers

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.

like image 194
BalusC Avatar answered Oct 17 '22 04:10

BalusC