Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
134 views
in Technique[技术] by (71.8m points)

java - ELException Error Reading ... on type

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...