How does class loading work in tc Server?
search cancel

How does class loading work in tc Server?

book

Article ID: 418825

calendar_today

Updated On:

Products

VMware Tanzu Spring Runtime VMware Tanzu tc Server

Issue/Introduction

Questions about how class loading works in VMware Tanzu tc Server.

Resolution

VMware Tanzu tc Server is built on Apache Tomcat, so it defaults to using the class loading strategy of Tomcat which is parent-last.

Tomcat uses a parent-last class loading strategy by default for web applications, which means it loads classes from the web application first before delegating to parent class loaders. This approach gives the web application's classes higher priority, helping to avoid conflicts with libraries that are bundled with the Tomcat server itself

You could override the class loading strategy by adding property to server.xml:

<Context path="/yourWebApp" docBase="yourWebAppDirectory"> <Loader delegate="true" /> </Context>

However this is not typically recommended due to reasons mentioned above.

Tc Server will use a different WebApplicationClassLoader for each WAR as is the default behavior Tomcat. The main reasons for this is isolation of resources, so applications do not interfere with each other and also to provide an extra layer of security.

Tc Server will automatically create a new WebappClassLoader instance for that application. Developer should only need to place all dependencies within the web application's /WEB-INF/classes directory and any JAR files within its /WEB-INF/lib directory. 

For reference, server.xml and configuration files for tc Server can be found at: https://techdocs.broadcom.com/us/en/vmware-tanzu/spring/tanzu-tc-server/10-1/tc-server/topics-connector-configuration.html