top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Use of custom classloader?

0 votes
335 views

I want my web apps running on Tomcat 7.0.35 to use a custom classloader.

The reason is that I want each web app classloader instance to do some processing to set up the classpath for the web app it belongs to. I have the following questions:

1) Is org.apache.catalina.loader.WebappClassLoader a good class to derive my custom classloader from? Is it a good choice going forward for later versions of Tomcat?

2) Is there a recommended way for my custom classloader to identify which web app it belongs to? It needs to identify which web app it is for so that it will know what jars to put on its classpath.

posted Jun 4, 2014 by Sonu Jindal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Look at VirtualWebappLoader (it feels that it suits your needs)

Also the same trick that it does can be performed from a * . There is no need to extend WebappLoader just for that.

A Listener and a WebappLoader have access to Tomcat's Context class and can get the paths.

The VirtualWebappLoader is not available in Tomcat 8, replaced by new Pre/Post/... resources APIs.

Beware that webapp's classloader should be able to produce class path that is used by JSP compiler (Eclipse JCP or by external javac depending on how your Tomcat is configured). Tomcat WebappClassLoader has API for that.

answer Jun 5, 2014 by Abhay Kulkarni
Similar Questions
+1 vote

We have a set up like Apahce (80,443) redirects the request to Tomcat (8080) using mod_jk.

The new requirement is to route the request from the same apache to another tomcat (8090). Hence I made the different config file for apache with different ports (86,4444) and different worker for mod_jk which routes the request to tomcat.

Now the issue is when I hit the url http://:86 and after providing the credentials, it is redirecting to https://:86 and throwing the below error.

Error in browser:

Secure Connection Failed

An error occurred during a connection to x.x.x.x:86. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)

Error in logs:

"x16x03x01" 501

[Thu Jan 08 08:22:46 2015] [debug] ssl_engine_io.c(1523): OpenSSL: I/O error, 11 bytes expected to read on BIO#1bf568 [mem: 1f3930]
[Thu Jan 08 08:22:46 2015] [debug] ssl_engine_kernel.c(1806): OpenSSL: Exit: error in SSLv2/v3 read client hello A
[Thu Jan 08 08:22:46 2015] [info] (70014)End of file found: SSL handshake interrupted by system [Hint: Stop button pressed in browser?!]
[Thu Jan 08 08:22:46 2015] [info] Connection to child 3 closed with abortive shutdown(server pritoolvca1.sw.ericsson.se:443 [2], client 153.88.164.216)
[Thu Jan 08 08:23:53 2015] [error] [client 172.17.136.153] Invalid method in request x16x03x01

Could you please suggest where it might went wrong and the way forward..

+1 vote

I'm trying to figure out how I can create custom session cookies. I've found the Manager interface for creating the sessions, but there's nothing about the actual session cookie. I don't see anything in the Valve interface that will let me do this either. Is this possible in Tomcat 7 (or 8?).

...