AnsweredAssumed Answered

Alfresco class loader can't load classes shared in tomcat

Question asked by keweishang on Aug 1, 2012
Latest reply on Aug 1, 2012 by keweishang
Hello,

I have a customized alfresco.war deployed in tomcat and I declared some command processor classes that I created. Instead of putting this classes in the alfresco.war, I want to put them in a tomcat repository and let the tomcat "shared class loader" load these classes.

So I configured the catalina.properties in tomcat by adding this line
shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar
, and I added the myCommandProcessors.jar in the ${catalina.base}/shared/lib/ repository. There are other jar files in this shared repository as well, like the Oracle jdbc driver, which are loaded well by the tomcat shared class loader. But myCommandProcessors.jar cannot be loaded, why? However, when I put the myCommandProcessors.jar in the ${catalina.base}/webapps/alfresco/WEB-INF/lib/, the myCommandProcessors.jar will be loading good, but that's not where I  want to put the the custom jar files to…

I traced the alfresco class load and I found this:
Classloader of command proccessor class:WebappClassLoader
  context: /alfresco
  delegate: false
  repositories:
    /WEB-INF/classes/
———-> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@11568fb5

This is the urls of the classloader:
[file:/home/alfresco/tomcat/webapps/alfresco/WEB-INF/classes/, file:/home/alfresco/tomcat/webapps/alfresco/WEB-INF/lib/FastInfoset-1.2.2.jar, …



Parent Classloader of command proccessor class:org.apache.catalina.loader.StandardClassLoader@11568fb5

This is the urls of the parent classloader:
[file:/home/alfresco/tomcat/shared/classes/, file:/home/alfresco/tomcat/shared/lib/ojdbc6.jar]

Does the line
delegate: false
mean that this class loader does not search classes from it's parent class loader (which is the tomcat shared class loader)?

Thanks.

Outcomes