javax.el.ELException: Cannot convert abcCache of type class java.lang.String to class java.lang.Class

Ankur Choudhary

I have randomly started to get

"javax.el.ELException:"

error in jsp pages where we load the Java code. The same was working earlier but started to give this error randomly. Have tried building with different versions of JDK, tomcat and maven but the problem still persist. Any leads will be appreciated. Find the logs below:

Mar 05, 2014 3:22:31 PM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception javax.el.ELException: Cannot convert abcCache of type class java.lang.String to class java.lang.Class at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:420) at org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:47) at javax.el.BeanELResolver.invoke(BeanELResolver.java:469) at org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:139) at org.apache.el.parser.AstValue.getValue(AstValue.java:173) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:963) at

Ankur Choudhary

The issue is with calling overloaded Java methods from JSP where the intended method won't be picked.

e.g. Illustration.java

getData(String input){
  // Code removed for simplicity 
}
getData(Class input){
  //Code removed for simplicity
}

Here, the jsp code getData("validInput") can pickup the second method with class parameter. Hence, the exception Cannot convert abcCache of type class java.lang.String to class java.lang.Class

Changing the second method to below solves the issue.

 getDataFromClass(Class input){
  //Code removed for simplicity
 }

The problem might occur randomly with different versions of JDK/Maven/Tomcat.

As a practice, one can think of having methods with different names, if to be used in such cases.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

javax.el.ELException: Cannot convert [2020-01-28T12:53:00.000+0000] of type [class java.lang.String] to [class java.util.Date]

javax.el.ELException: The class [java.lang.Number] must be public, non-abstract and not an interface

IllegalArgumentException: Cannot convert PROPERTY of type class org.omnifaces.el.ExpressionInspector$ValueExpressionType to class java.lang.Boolean

<p:selectManyMenu var> throws ELException: The class 'java.lang.String' does not have the property 'foo'

Cannot convert instance of class org.jruby.RubyObject to class java.lang.String

javax.el.ELException: java.lang.NullPointerException

Cannot cast class java.lang.Integer to class java.lang.String

how to fix Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class javax.swing.JLabel cannot be cast to class java.lang.String

JPype1=0.7.0: TypeError: Unable to convert str ro java type class java.lang.String

Convert java.lang.reflect.Type to Class<T> clazz

how to convert system type (C sharp) to java lang class

Provided id of the wrong type for class classname Expected: class java.lang.Integer, got class java.lang.String

java.lang.ClassCastException: class java.sql.Date cannot be cast to java.lang.String

Class required a bean of type 'java.lang.String' that could not be found

Class cannot be cast to java.lang.Comparable

class java.lang.Long cannot be cast to class java.lang.String error when having a hashmap of mixed types (Long and string)

java.lang.IllegalArgumentException: Not a managed type: class

org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'user'

Cannot cast object 'url' with class 'java.lang.String' to class 'int' Gradle Java

No such property: split for class: java.lang.String

java.lang.String class' value variable

No such property: id for class: java.lang.String

java.lang.ClassCastException (Cannot cast class to same class)

Java.lang.ClassCastException: model class cannot cast to model class

Why get class cannot be cast to class java.lang.Comparable

Class cannot be cast to class java.lang.reflect.ParameterizedType (java.lang.Class and java.lang.reflect.ParameterizedType )

java.lang.ClassCastException: [Z cannot be cast to [Ljava.lang.String in reflective toString on model class

java.lang.Class cannot be cast to clojure.lang.IFn when date capturing and string formatting

InvalidTypeException: Invalid type for value 1 of CQL type text, expecting class java.lang.String but class [Ljava.lang.Object; provided