0

This is in continuation to Tomcat restart throws error regarding the missing destroy() method

My tomcat doesn't pick up the servlet-api.jar from the tomcat/lib but it goes and pick up from a shared folder which is not even in the path of CATALINA_HOME (In my case it is same as CATALINA_BASE).

This is because I add the A/Shared_folder as follows in the CATALINA_OPTS at the catalina.bat:

set CATALINA_OPTS=%CATALINA_OPTS% -Djava.library.path="A/Shared_folder" -Xms256m -Xmx256m -verbose:gc

Folder structure is: A/Shared_folder is the shared folder

A/B/tomcat_folder is the tomcat folder

I am really stuck here. I verified with the classloader logs. Once I remove the Djava.library.path="A/Shared_folder", it loads correctly from the tomcat/lib but my application needs remaining jars in the A/Shared_folder to run correctly. Please advise.

Is there any way I can exclude the servlet-api form the Djava.library.path.

Note:- servlet-api.jar versions are different in both location and hence the issue. I am using 9.0.43 tomcat

Coffee_lover
  • 545
  • 6
  • 15
  • 1
    -Djava.library.path sets a path for loading native libraries, so i dont see how this would affect loading java libs? – Gyro Gearless Mar 04 '21 at 18:35
  • 1
    Check your `catalina.properties` file against the [default one](https://github.com/apache/tomcat/blob/master/conf/catalina.properties). Maybe your predecessor changed the `*.loader` variables. Check also the `CLASSPATH` of your server. – Piotr P. Karwasz Mar 04 '21 at 18:59
  • @GyroGearless in the shared folder there is another copy of servlet api. Somehow that is being picked up. – Coffee_lover Mar 05 '21 at 05:50
  • 1
    BTW, you should mention, that you are running under windows. Therefore the system classpath is usually configured through [Procrun](https://stackoverflow.com/a/21885863/11748454). – Piotr P. Karwasz Mar 05 '21 at 09:47
  • but my question is regarding the order of the class loader. shouldn't it be loading the servlet-api jar first from the tomcat/lib since my delegate is set to false. – Coffee_lover Mar 08 '21 at 08:32
  • And how come -Djava.library.path which sets a path for loading native libraries, is also impacting the loader order. – Coffee_lover Mar 08 '21 at 08:33
  • @Coffee_lover: Please [edit](https://stackoverflow.com/posts/66480830/edit) your question and add the contents of `catalina.properties` and `setenv.bat` (if you use `startup.bat/catalina.bat` to start Tomcat). If you use Procrun, copy the value of _"Java classpath"_. My bet is that `catalina.properties` contains `${java.library.path}`. – Piotr P. Karwasz Mar 09 '21 at 09:34
  • No the catalina.properties doesnt have the '${java.library.path}' but the catalina.bat does have this. – Coffee_lover Mar 09 '21 at 20:31

0 Answers0