Manish Kumar
Manish Kumar

Reputation: 10492

java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext

I am returning data from spring controller as below:

    HashMap hm = new HashMap();
    hm.put("totalPage", pageQuery.count());
    ArrayList al = new ArrayList();
    while(iterator.hasNext()){
        Vertex v = iterator.next();
        MyPageList myPageList = new MyPageList();
        myPageList.setPageName(....);
        al.add(myPageList);
    }
    hm.put("pages", al);
    ...
    ...
    HashMap hm2=new HashMap();
    hm2.put("mydata",hm);
    return hm2;

On jsp side If i use ${mydata['totalPage']} it prints the value bu when when i try to iterate pages as below:

<c:forEach items="${mydata['pages']}" var="v">  
</c:forEach>

It show following exception:

javax.servlet.ServletException: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;

How can i display pages values??

Here is my POM file

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.xyz</groupId>
<artifactId>abcde</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>hello world</name>

<properties>
    <spring.version>3.2.4.RELEASE</spring.version>        
</properties>
<dependencies>
    <!-- spring -->
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
    </dependency>
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
    </dependency>
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
    </dependency>
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
    </dependency>
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
    </dependency>
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
    </dependency>

    <!-- spring security -->
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.4.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.1.4.RELEASE</version>
    </dependency>            
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.4.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>3.1.4.RELEASE</version>
    </dependency>

<!-- javax mail -->
<dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.5.0</version>
</dependency>
<dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
</dependency>
<dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mailapi</artifactId>
        <version>1.4.3</version>
</dependency>
<dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.5.0</version>
</dependency>

<!-- Cassandra dependency -->
<dependency>
  <groupId>org.apache.cassandra</groupId>
  <artifactId>cassandra-thrift</artifactId>
  <version>2.0.0</version>
</dependency>
<dependency>
  <groupId>org.apache.cassandra</groupId>
  <artifactId>cassandra-clientutil</artifactId>
  <version>2.0.0</version>
</dependency>            
<dependency>
  <groupId>com.datastax.cassandra</groupId>
  <artifactId>cassandra-driver-core</artifactId>
  <version>2.0.0-rc2</version>
</dependency>       
<dependency>
  <groupId>com.yammer.metrics</groupId>
  <artifactId>metrics-core</artifactId>
  <version>2.2.0</version>
</dependency>
<dependency>
  <groupId>org.apache.thrift</groupId>
  <artifactId>libthrift</artifactId>
  <version>0.9.1</version>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
</dependency>
<dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.3</version>
</dependency>

<!-- Titan dependency -->
<dependency>
   <groupId>com.thinkaurelius.titan</groupId>
   <artifactId>titan-core</artifactId>
   <version>0.4.2</version>
</dependency>   
<dependency>
   <groupId>com.thinkaurelius.titan</groupId>
   <artifactId>titan-cassandra</artifactId>
   <version>0.4.2</version>
</dependency>
<dependency>
   <groupId>com.thinkaurelius.titan</groupId>
   <artifactId>titan-all</artifactId>
   <version>0.4.2</version>
</dependency>        


<!-- jstl -->
<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
</dependency>        
</dependencies>

<build>
    <finalName>SpringMVC</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 1

Views: 3351

Answers (2)

Ra&#250;l Moreno
Ra&#250;l Moreno

Reputation: 308

First of all, thanks @BalusC for your answer; I've learnt from it.

As you were using JSTL1.2, it may have been a mismatch between container version and JSTL version:

Answer: https://stackoverflow.com/a/542454/2906290

From http://www.coderanch.com/how-to/java/JstlTagLibDefinitions:

JSTL 1.2 consists of two files (jstl-impl-1.2.jar and jstl-api-1.2.jar) (...) It should be used for JSP 2.1 containers such as Tomcat 6.

If that was not the case, this case may give a hint, as he got the same error, but I'm not sure he was right with his approach as I'm not sure he really revised the versions, or why he couldn't downgrade the JSTL or upgrade the container: https://stackoverflow.com/a/15259704/2906290

Upvotes: 0

BalusC
BalusC

Reputation: 1108722

java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;

The method javax.servlet.jsp.PageContext.getELContext() was introduced in JSP 2.1. The AbstractMethodError basically means that the runtime classpath contains a JSP 2.1 compatible API, but an older versioned implementation, such as JSP 2.0, 1.2, etc.

Normally, both the JSP API and implementation are already provided by the target servletcontainer where you deploy the webapp to, such as Tomcat. Normally, you do not need to mess around with its libraries nor its classpath.

This exception means that you did that. This exception suggests that you for some unclear reason placed either a newer versioned JSP API or an older versioned JSP implementation in webapp's runtime classpath, most likely in flavor of a JAR file in webapp's /WEB-INF/lib. This is namely what many starters incorrectly do when they face compilation errors in their IDE project and didn't at all understand what the "Targeted runtime" setting of the IDE project actually means.

You should never put arbitrarily downloaded servletcontainer-specific JAR files in your webapp's /WEB-INF/lib which originally originate from a servletcontainer of a completely different make/version than your target servletcontainer. It would make your webapp incompatible with the target servletcontainer where you're actually going to deploy to. Instead, you should set/fix the "Targeted runtime" setting to let the IDE point out the target servletcontainer you'd like to deploy to.

See also:

Upvotes: 1

Related Questions