English 中文(简体)
Struts 1 - struts-taglib.jar is not being found by my web application
原标题:

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 Java - Problem in deploying Web Application for more information

问题回答

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 .srcelsrcmain esourcesMETA-INF ld, 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</taglib-uri>
    <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.

Is /WEB-INF/lib in your classpath ?

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

Doublecheck your URI and the URI in the TLD file from struts-taglib.jar.

Please note URI has been changed recently: http://wiki.apache.org/struts/StrutsUpgradeNotes12to13

Make sure that your struts-taglib-1.3.10.jar is directly under /WEB-INF/lib, not in any sub-folder like /WEB-INF/lib/struts





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签