0

I am trying to run a deployed .war made with the zk framework and Java, in a Debian server with tomcat 10 but it doesn't work. When I checked the log in the file /opt/tomcat/logd/localhost.2021-xx-xx.log, an error message appeared as follows:

java.lang.ClassNotFoundException: org.zkoss.zk.ui.http.HttpSessionListener 

Then, I made some research on the internet and I found a possible solution on this link https://forum.zkoss.org/question/97112/javalangclassnotfoundexception-orgzkosszkuihttphttpsessionlistener/ and I did what is suggested. However, the error continues to appear. It seems that there is a conflict between the zk framework and the server.

  • Tomcat 10 is not compatible with most software libraries available today (cf. [this question](https://stackoverflow.com/q/66806582/11748454) for example). However I would rather expect a `java.lang.ClassNotFoundException: javax.servlet.http.HttpSessionListener` (cf. [this question](https://stackoverflow.com/q/66711660/11748454)). – Piotr P. Karwasz Aug 10 '21 at 21:48
  • Before migrating to tomcat 10 make sure the application still works in the latest tomcat 9 version. This might already produce errors unrelated to the bigger switch to tomcat 10 and the jakarta namespace. Just to be sure and isolate the source of the problem. – cor3000 Aug 11 '21 at 03:01
  • In fact, I tried to establish in the production server, the same environment of my developing server. Locally I have tomcat 9 installed and I realized that the problem was precisely in migrating to the latest version. Thank you all for your comments! – Cindy Estefanìa Miranda Campos Aug 11 '21 at 20:47

1 Answers1

2

I see two potential issues that could cause this.

First: Tomcat 10 implements Jakarta servlet (instead of java servlet). When building your application, make sure that you are using the proper ZK version. The last ZK release has two versions:

  • 9.6.0 : Java EE (tomcat 9 and below)
  • 9.6.0-Jakarta : Jakarta EE (tomcat 10 only)

See the configuration guide here.

Caveat on that, if you are running the Java EE version of ZK in tomcat 10, I'd expect you to get:

[org.zkoss.zk.ui.http.HttpSessionListener]
    java.lang.NoClassDefFoundError: javax/servlet/ServletRequestAttributeListener

which is located in the same place as your current issue, but is not quite the same :D

Second: If you are resolving your dependencies through a dependency management tool such as maven or graddle, it is possible that you are resolving the wrong dependencies.

I'd recommend doublechecking the resolved depencies to make sure that every single one of the ZK jars are resolved in the same version.

You may have a ZK version coming from your main declaration, and a different one coming from a plugin (such as Keikai, ZK spreadsheet, or ZK charts)

From maven for example, running the dependency tree command is a good way to know what is resolved.

MDuchemin
  • 431
  • 2
  • 6