Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add JSTL to Maven?

Tags:

maven

jstl

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

like image 901
La Chamelle Avatar asked Feb 28 '11 22:02

La Chamelle


People also ask

Does Tomcat include JSTL?

Tomcat does not provide the Java Server Tag Library (JSTL), which is required to use JSP pages as Spring views. The IdP status page at /idp/status is built with JSP and will not work without this library. You can download it from here, place it into idp.

Is JSTL used in spring?

Spring provides a couple of out-of-the-box solutions for JSP and JSTL views. Using JSP or JSTL is done using a normal view resolver defined in the WebApplicationContext . Furthermore, of course you need to write some JSPs that will actually render the view.


1 Answers

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.

like image 71
La Chamelle Avatar answered Oct 06 '22 10:10

La Chamelle