- This topic has 10 replies, 2 voices, and was last updated 19 years, 5 months ago by
Riyad Kalla.
-
AuthorPosts
-
mwunderlichMemberDear all,
I have problems getting the basic JSTL core library working. I have searched the forum archives and the web, but to no avail.
My JSP page looks like this:<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <html> <body> <c:forEach var="i" begin="1" end="10" step="1"> <c:out value="${i}" /> </c:forEach> </body> </html>
My web-xml is this:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> </web-app>
Dear all,
I have problems getting the basic JSTL core library working. I have searched the forum archives and the web, but to no avail.
My JSP page looks like this:<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>
<%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%><html>
<body>
<c:forEach var=”i” begin=”1″ end=”10″ step=”1″>
<c:out value=”${i}” />
</c:forEach>
</body>
</html>My web-xml is this:
<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app version=”2.4″
xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”></web-app>
I am using Tomcat 5 and JSTL 1.1. “c.tld” is my web-inf directory and the two libraries jstl.jar and standard.jar are in “web-inf/lib”.
So, everything should be fine – in theory. However, I keep getting the following error:java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/Tag
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
java.net.URLClassLoader.access$100(URLClassLoader.java:56)
java.net.URLClassLoader$1.run(URLClassLoader.java:195)
java.security.AccessController.doPrivileged(Native Method)[etc.]
So, it seems like the tag can’t be found. Any ideas why that is?
Cheers,
“c.tld” is in my web-inf directory and the two libraries jstl.jar and standard.jar are in “web-inf/lib”.
So, everything should be fine – in theory. However, I keep getting the following error:java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/Tag java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:620) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) java.net.URLClassLoader.defineClass(URLClassLoader.java:260) java.net.URLClassLoader.access$100(URLClassLoader.java:56) java.net.URLClassLoader$1.run(URLClassLoader.java:195) java.security.AccessController.doPrivileged(Native Method)
[etc.]
So, it seems like the tag can’t be found. Any ideas why that is?
I am using Tomcat 5.5.4, Eclipse 3.1.1. and MyEclipse 4.0.3. I have tried setting up new projects with both JSTL 1.0 and 1.1. I even tried manually removing all libraries and tld’s and leaving only standard.jar and jstl.jar in the web-inf/lib directory.Cheers,
Martin
January 17, 2006 at 12:19 pm #244682
Riyad KallaMemberMartin,
Tag is part of the jsp-2.0 spec. In Tomcat this is in the common/lib/jsp-api.jar file. If you check your build path do you have the J2EE 1.4 Library added to your build path? It should include this file.January 17, 2006 at 2:05 pm #244687
mwunderlichMemberThanks a lot for the reply! I should have mentioned that I checked for jsp-api before. The library jsp-api.jar is there alright in the directory common/lib of my Tomcat folder. In addition, I just tried importing j2ee.jar as an external library. It is listed in the project preference’s build path, but no success.
I hope to get this sorted soon, because I am stuck on a project where I had planned to use JSTL.
Cheers,
Martin [/quote]
January 17, 2006 at 2:05 pm #244688
mwunderlichMemberThanks a lot for the reply! I should have mentioned that I checked for jsp-api before. The library jsp-api.jar is there alright in the directory common/lib of my Tomcat folder. In addition, I just tried importing j2ee.jar as an external library. It is listed in the project preference’s build path, but no success.
I hope to get this sorted soon, because I am stuck on a project where I had planned to use JSTL.
Cheers,
Martin [/quote]
January 17, 2006 at 2:52 pm #244695
Riyad KallaMemberMartin,
The problem is that the JAR that contains the required class is not in your build path so Eclipse cannot find it. You can either add jsp-api.jar and servlet-api.jar to your project’s build path as External JARs, or make sure that the J2EE 1.4 Library is in your path.January 17, 2006 at 4:11 pm #244710
mwunderlichMemberThe J2ee library is there on the build path. Just to make sure, I also explicitly added jsp-api and servlet-api to the build path. I can see the missing Tag class in the eclipse project. It’s still not working. Any other ideas?
Cheers,
Martin
January 17, 2006 at 4:13 pm #244711
Riyad KallaMemberAre you getting this exception during runtime or during build time of the app?
January 17, 2006 at 5:30 pm #244716
mwunderlichMemberDuring run time, when I try to access the JSP on the localhost.
January 17, 2006 at 6:25 pm #244719
Riyad KallaMemberAhh I thought you were getting this at build time. If you are getting this at run time, check your deployed apps WEB-INF/lib dir. Make sure NO jsp-api.jar or servlet-api.jar OR j2ee.jar JARs are in there. Your app server provides those for you.
Now go into your common/lib dir and confirm that jsp-api and servlet-api.jar are both there. Now double check that you are deploying your app to Tomcat 5 and not Tomcat 4, Tomcat 4 won’t have these files, but 5 will.
January 18, 2006 at 3:52 am #244738
mwunderlichMemberIt’s working now! Brilliant, what a relieve. I can’t really say what the problem was. When I checked again this morning for those jar files, according to your advice, all I could find in web-inf/lib were jstl.jar and standard.jar. In Tomcat’s common/lib I found jsp-api-jar and servlet-api.jar alright. However, when I tried to access the jsp again, I got a different error:
“org.apache.jasper.JasperException: /index.jsp(7,4) According to TLD or attribute directive in tag file, attribute value does not accept any expressions”
I was able to fix this by changing my URI from
<%@ taglib prefix=”c” uri=”http://java.sun.com/jstl/core”%>
to
<%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%>.Right so, I am off coding away now – until the next time it grinds to a halt. 🙂 (Is it just me or is it always like that – moving from one block to the next?)
Cheers,
Martin
January 18, 2006 at 7:35 am #244748
Riyad KallaMemberGlad it’s working now Martin.
(Is it just me or is it always like that – moving from one block to the next?)
It certainly feels like that, but I would say that only lasts a few weeks before you come to recognize all the errors and what they mean. For example, your problem above “According to TLD or attribute directive…” in another thread had a user stumped for 1 week, but you knew what the problem was right away. The trick is learning all the hickups 🙂
-
AuthorPosts