Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Tomcat Instrument loader

 
Joe Harry
Ranch Hand
Posts: 10084
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any other way around to avoid using this jar file directly in the lib folder of tomcat? I have a tomcat instance that has a couple of other deployments that do not depend on Spring. How do I make those projects co-exist. Can I add this file as a dependency to my project's pom file? I remember doing that once, but then tomcat was not able to find this file and failed during startup. Well, I already tried that and got the following error:

 
Joe Harry
Ranch Hand
Posts: 10084
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I use the Spring-Tomcat instrument jar file in the tomcat lib folder of tomcat deployment which is meant to be used only by one of the applications that will be deployed to this tomcat. I tried adding the jar file to my web applications lib folder but that did not help. I get the same error message as above during tomcat startup. Where else could I try putting this jar file? By any means, I want to avoid using it in the tomcat's lib folder.
 
Joe Harry
Ranch Hand
Posts: 10084
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a wise idea to add a custom location for class loader look up in catalina.properties file? I'm going to give it a try. But fully not convinced this to be a good idea. I would be happy if I have it in my application WEB-INF directory as this jar file is just local to this application and not to tomcat as such. If any of you have any other ideas, please post them here.
 
Joe Harry
Ranch Hand
Posts: 10084
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it be a good idea to add a context.xml inside the META-INF folder of my web app and in this context.xml, I specify the tomcat spring class loader?
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see the reference documentation on this:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/aop.html#aop-aj-ltw-environments

Are you adding the below to you web application context file?



If you read the link I gave you there is a section that that provides another link stating:

For efficiency, the embedded per-web-app configuration style is recommended because it will impact only applications that use the custom class loader and does not require any changes to the server configuration. See the Tomcat 6.0.x documentation for more details about available context locations.
 
Joe Harry
Ranch Hand
Posts: 10084
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should the context.xml should be located in the META-INF folder of the web-app? Correct me if I got this wrong. But what I initially wanted is justified by your statement above. I do not want to use this custom class loader for the entire tomcat server but rather just for this one particular web application. I would give it a try and post the results here. I hope I could get rid of the Class Not Found exception.
 
Joe Harry
Ranch Hand
Posts: 10084
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just understood the whole story behind class loading in tomcat. I was under the impression that if I copy the spring instrument class loader jar file in the lib folder of tomcat, then it will be the default class loader for all the applications that are deployed to this tomcat server. But I guess I'm wrong in my understanding. Apart from copying the file to tomcat's lib folder, I have to explicitly specify in the context.xml of my web application to use this class loader as the default. So far so good. But what happened was, even without the context.xml file, the tomcat used the spring instrument class loader as its default. Why is this? Any idea?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic