views:

890

answers:

3

I am using Struts-1. I have developed a struts-based web application. I am using struts tags in my JSP pages supplied in struts-taglib.jar by inserting the following lines in the JSP file:

<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>

Now the application is working fine when I run it on my localsystem but when I deploy it on a server, it shows the following exception:

org.apache.jasper.JasperException: The absolute uri: http://struts.apache.org/tags-html cannot be resolved in either web.xml or the jar files deployed with this application

From the above exception, it seems that the application hasn't found the struts-taglib.jar file.

But I have put the struts-taglib.jar in /WEB-INF/lib directory. Then where is the problem?

Note: You can also look at http://stackoverflow.com/questions/2452492/java-problem-in-deploying-web-application for more information

A: 

Is /WEB-INF/lib in your classpath ?

Tom
I think that it is the default classpath of any web application. Should there be any file that defines the classpath(s) any web application. My application doesn't have any such file. I developed it in Eclipse and in Eclipse yes `/WEB-INF/lib was in my classpath.
Yatendra Goel
Exactly. You don't need to changed anything to get WEB-INF/lib and WEB-INF/classes in your web app CLASSPATH. It's the default.
duffymo
A: 

After deploying it is the jar file actually in /WEB-INF/lib ? If not will putting it by hand resolve the problem?

kukudas
+1  A: 

You say the JAR does appear in the WEB-INF/lib for the web app; I'll take your word for it and believe you.

I would suggest that you open up the struts-taglib.jar, open the .tld for the tag library, and verify that the <uri> value that you find under the <taglib> root matches the uri for the given prefix in your JSPs. I'm guessing that the URI doesn't match, which means the class loader won't be able to find the tag library even if the JAR is in the CLASSPATH.

It might also indicate whether or not a version change made the URI in your JAR and JSP out of synch.

I just downloaded struts-1.3.10-all.zip and looked at the struts-logic.tld contained within. The value of the <uri> tag is http://struts.apache.org/tags-logic, so it looks like you're okay there.

The .tld files look like they're externalized from the JAR. Look for them under .\src\el\src\main\resources\META-INF\tld, put them in your /WEB-INF, and refer to them explicitly in your web.xml. That should sort you out.

I don't believe .tld in web.xml is necessary anymore, but if the URI thought doesn't pan out you can try adding something similar to this example from "JSTL In Action" to your web.xml (modified accordingly):

<taglib>
    <taglib-uri>http://java.sun.com/jstl/core&lt;/taglib-uri&gt;
    <taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

It could be because Struts 1.0 is rather old at this point. Packaging the .tld in the JAR of the taglib became a common practice after Struts 1.0 was developed.

duffymo