Failed to load or instantiate TagLibraryValidator

2020-03-01 20:21发布

问题:

So I was working with JSTL in OSGi, under Gemini runtime. And I'm getting following exception, when I try to access the url to my servlet: -

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /WEB-INF/login.jsp (line: 3, column: 66) Unable to read TLD "META-INF/c.tld" from JAR file "file:/D:/OSGi%20Runtime/Gemini/gemini-web/dep/com.springsource.javax.servlet.jsp.jstl-1.2.0.v20110728.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV

However, I have checked, that I already have all the necessary bundles in my runtime. The relevant bundle that I have is: -

71  ACTIVE      javax.servlet_3.0.0.v201103241009
73  ACTIVE      javax.el_2.2.0.v201105051105
74  ACTIVE      javax.servlet.jsp_2.2.0.v201103241009
75  ACTIVE      com.springsource.javax.servlet.jsp.jstl_1.2.0.v20110728
121 ACTIVE      com.springsource.org.apache.taglibs.standard_1.1.2.v20110517

There are more bundles, but those are the ones that are relevant. So, I can't understand what went wrong.

From the Spring Source Repository, from where I downloaded the bundle, it's clear that, org.apache.taglibs.standard bundle - Bundle 121, contains that JstlCoreTLV class. So, not sure, what's going on here.

Here's my JSP header I'm using (Just in case, it is relevant): -

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

I'm using: -

  • Servlet 3.0
  • JSP 2.2
  • Gemini Runtime 2.1
  • JSTL 1.2.0

Update: -

The problem described below seems to be solved, and now I'm not getting any warning as shown below. That was because, I was having the taglibs.standard_1.1.2 - (Bundle 121), which was incompatible to others. So, I removed it, and the warnings went away.

So, you can ignore whatever is there from here on. But, The problem above is still there. I'm still getting that JasperException. May be this will help further, as the problem domain is reduced now a little bit thanks to the valuable input from @BalusC.


Part after this is solved. So, you can ignore it: -

Also, I'm not sure that the version of the OSGi JSTL bundle that I have - Bundle 75, is compatible with the other bundles - javax.el, taglibs, servlets, etc, or not. Because I was using JSTL 1.2.1, but I couldn't get the bundle for JSTL 1.2.1. What I got was the bundle I used (JSTL 1.2.0). Why this is bothering me is because of these kinds of messages coming up, when I start my application: -

Jan 22, 2013 7:14:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Jan 22, 2013 7:14:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Jan 22, 2013 7:14:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Jan 22, 2013 7:14:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Jan 22, 2013 7:14:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Jan 22, 2013 7:14:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined

As you can see that there two different URLs shown above: -

  • URI: http://java.sun.com/jstl/core
  • URI: http://java.sun.com/jsp/jstl/core

Now, AFAIK both those URLs, do not belong to same JSTL versions. So, could that raise some problems? And what can be the reason for them to come? I have just used one JSTL bundle.

回答1:

com.springsource.javax.servlet.jsp.jstl_1.2.0.v20110728
com.springsource.org.apache.taglibs.standard_1.1.2.v20110517

You're mixing JSTL 1.2.0 API+impl with JSTL 1.1.2 impl.

The both impls are conflicting with each other which explains all the trouble you're seeing.

Get rid of the 1.1.2 impl.

See also:

  • Our JSTL wiki page


回答2:

This is just a shot in the dark. Not sure if you came upon below links.

The error message you posted "Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV" seems to be pretty common.

From this link : http://christerblog.wordpress.com/2010/05/04/tag-library-woes-deploying-war-on-tomcat-6/

Do you have any conflicting/incompatible jar libraries in your WAR file ?

Another one here also points to incompatible jars in the build path: Unable to read TLD "META-INF/c.tld"



回答3:

I upgraded from Tomcat 8 to Tomcat 9, which has 125: jstl.jar,taglibs-standard-spec-*.jar, in its catalina.properties. Does this mean that jstl is preinstalled, unlike tomcat 8 where jstl 1.2 was needed in the build.gradle ?

Since I had to remove the following lines to get it working

//compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
//compile group: 'javax.servlet.jsp.jstl', name: 'jstl', version: '1.2'

If my answer is incorrect, please let me know I am happy to delete it. Since @BalusC answer gave me the clue.



回答4:

First of all, I don't think I can really answer this question, no idea if this is relevant to you.

I've struggled with this problem too, until I switched to Pax Web. It worked pretty much out of the box. I intended to go back and figure out exactly why my previous setup did not work, but, well, it never happened.

So, if it is possible in your situation, use Pax Web over hand picking your own bundles.