0

I am running a web application from NetBeans 13 (also recently upgraded).

I just upgraded to Tomcat 10 and therefore changed all import statements in the application from javax.servlet to jakarta.servlet.

When I run the application, I still get an exception:

java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.TagLibraryValidator

I have checked to ensure that I don't include any Tomcat APIs in my WEB-INF/lib, and I don't.

Also, if I include

<Loader jakartaConverter="TOMCAT" />

in my META-INF/context.xml, my application runs correctly.

Therefore, I think that there is still a reference to javax.servlet somewhere in my code or in my NetBeans config but I'm not sure what else I can update. Is there something I need to update in the JSP's themselves?

I updated the web-app element in my WEB-INF/web.xml file from

<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

to:

<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
                      https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
  version="5.0">

This did not fix the issue.

Also, I noticed that in the project.properties file, there is a property called j2ee.platform which is set to 1.7-web. Can it be that this references the old javax libraries and needs to be changed? How can I change this and to what should it be changed if so? Is there something via the NetBeans console that allows me to change this?

theyuv
  • 1,556
  • 4
  • 26
  • 55
  • It sounds like you're loading/importing an old JSP taglib somewhere. – Mark Rotteveel May 19 '22 at 09:45
  • Thanks. I am using the jstl library that came with Netbeans (1.2.1) and I see that its classes still reference `javax` packages. Could that be the issue? Netbeans has the option to import jakarta libraries (`Jakarta EE Web 9` or `Jakarta EE 9 API`) but it doesn't seem like those have the same tags as jstl. Would adding this [jakarta standard tag library](https://mvnrepository.com/artifact/jakarta.servlet.jsp.jstl/jakarta.servlet.jsp.jstl-api/2.0.0) as a dependency instead work? Or do jstl users need to use Tomcat9 instead of Tomcat10? – theyuv May 19 '22 at 11:16
  • That is the issue. You'll need to use a JSTL version for Jakarta 9+. Unfortunately I can't offer specific help, because I haven't really touched JSP for over a decade, and the same with NetBeans. – Mark Rotteveel May 19 '22 at 11:17
  • Thanks again. Any idea what can be done if I also depend on this library: [htmlcompressor](https://mvnrepository.com/artifact/com.googlecode.htmlcompressor/htmlcompressor/1.5.2), which also references the old `javax` packages. – theyuv May 19 '22 at 12:00
  • You'll probably need to fork https://github.com/serg472/htmlcompressor and fix the package references, it doesn't seem to have been updated in a while. – Mark Rotteveel May 19 '22 at 12:05
  • Check section titled [Installing JSTL on Tomcat 10+](https://stackoverflow.com/a/4928309) – BalusC May 19 '22 at 13:44

0 Answers0