34

I'm working on a JSF 2.0 project using Mojarra, PrimeFaces and Tomcat 6.x.

I need to use c:forEach for some primefaces component like dynamic number of p:tab but i have problem with the c:forEach. All the other tag of JSTL work nice.

I have the following error :

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTagStatus

I use the following xmlns:c="http://java.sun.com/jsp/jstl/core", i tried to replace with xmlns:c="http://java.sun.com/jstl/core" but nothing display with the second.

This is the exact version of lib:

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.0.2-FCS</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.0.4-b03</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>2.2.1</version>
</dependency>

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>el-api</artifactId>
    <version>2.2</version>
</dependency>

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>el-impl</artifactId>
    <version>2.2</version>
</dependency>

How i can fix it ?

I can give more specific information if needed.

EDIT: I added and tried different scopes (runtime and compile) but nothing change:

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

The list of repository:

  <repositories>
    <repository>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <layout>default</layout>
      <url>http://repo1.maven.org/maven2</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>maven-repository.dev.java.net</id>
      <name>Java.net Repository for Maven 1</name>
      <url>http://download.java.net/maven/1/</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>maven2</id>
      <name>Java.net Repository for Maven</name>
      <url>http://download.java.net/maven/2</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>prime-repo</id>
      <name>Prime Technology Maven Repository</name>
      <url>http://repository.prime.com.tr</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>JBoss2</id>
      <url>https://repository.jboss.org/nexus/content/repositories/public</url>
    </repository>
    <repository>
      <id>JBoss</id>
      <url>http://repository.jboss.com/maven2</url>
    </repository>
    <repository>
      <id>EclipseLink Repo</id>
      <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>itextpdf.com</id>
      <name>Maven Repository for iText</name>
      <url>http://maven.itextpdf.com/</url>
    </repository>

    <repository>
      <id>guiceyfruit.release</id>
      <name>GuiceyFruit Release Repository</name>
      <url>http://guiceyfruit.googlecode.com/svn/repo/releases/</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </repositories>

This is the content of $TOMCAT_HOME/lib

annotations-api.jar catalina-ha.jar catalina-tribes.jar el-impl-2.2.jar jasper.jar jsf-api.jar
jsp-api.jar servlet-api.jar
tomcat-dbcp.jar
tomcat-i18n-fr.jar catalina-ant.jar
catalina.jar el-api-2.2.jar
jasper-el.jar jasper-jdt.jar
jsf-impl-2.0.4-b03.jar ojdbc6.jar
tomcat-coyote.jar tomcat-i18n-es.jar tomcat-i18n-ja.jar

La Chamelle
  • 2,927
  • 4
  • 36
  • 54
  • 5
    Tomcat doesn't ship with JSTL out the box. You need to instruct your Maven thing to add JSTL. I improved the title and the tagging to attract the right folks. – BalusC Feb 28 '11 at 23:20
  • Possible duplicate of [Include JSTL dependency with Maven](https://stackoverflow.com/questions/2276083/include-jstl-dependency-with-maven) – Koray Tugay May 22 '18 at 00:15

5 Answers5

58

You must include the jstl library in your distribution. This may be provided by the container, although that is not recommended practice. The maven dependency for the current version (as of writing) is here:

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

Although, it's always worth checking the maven central repository for updates.

Software Engineer
  • 15,457
  • 7
  • 74
  • 102
La Chamelle
  • 2,927
  • 4
  • 36
  • 54
  • 3
    @HaikalNashuha Usually at the root of your Maven project. – Dave Newton Jan 15 '12 at 18:17
  • this may help some, it helped me: [maven setup]( http://www.murraywilliams.com/2011/11/running-jstl-1-2-on-tomcat-7-using-maven/comment-page-1/#comment-71019) – jsky Aug 07 '13 at 12:53
  • this thread is old but +1 for the source: By default, Tomcat container doesn’t contain any jstl library. – jmsalcido Oct 02 '13 at 18:51
  • 1
    Actually, the jar does not need to be in $TOMCAT_HOME/lib at all. You should feel free to package it within your web app's war. The dependency is correct though, even though the pre- and post-information is incorrect, so -1 for the bull and well done for finding the correct group id. – Software Engineer Jul 09 '14 at 15:04
  • @EngineerDollery EngineerDollery is right, can you please update the answer? – Koray Tugay Jul 13 '14 at 11:12
17

As Balus said, you just need to add JSTL to your pom.xml because Tomcat doesn't include it. 1.2 is the most recent version:

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
</dependency>
Kaleb Brasee
  • 51,193
  • 8
  • 108
  • 113
7
<!-- standard.jar --> 
<dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    <version>1.1.2</version>
</dependency>

<!-- JSTL --> 
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.1.2</version>
</dependency>

And then you can use the Java Standart Tags and Functions as follows in your jsp page:

<%@ taglib prefix="c" 
       uri="http://java.sun.com/jsp/jstl/core" %>

<%@ taglib prefix="fn" 
       uri="http://java.sun.com/jsp/jstl/functions" %>

This also works alone:

<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
5

I know the question is old, but it's high in the Google results, so I'm adding this.

Newer JSTL version are available (only) under org.glassfish.web groupId. Example:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.servlet.jsp.jstl</artifactId>
    <version>1.2.5</version>
</dependency>

If you are looking for the Jakarta EE version:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>jakarta.servlet.jsp.jstl</artifactId>
    <version>2.0.0</version>
</dependency>
Nicola Isotta
  • 202
  • 3
  • 10
1

In recent Tomcat versions use:

<dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-spec</artifactId>
    <version>1.2.5</version>
</dependency>
<dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-impl</artifactId>
    <version>1.2.5</version>
</dependency>
lainatnavi
  • 1,453
  • 1
  • 14
  • 22