aspose file tools*
The moose likes Spring and the fly likes Spring Tomcat Instrument loader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Tomcat Instrument loader" Watch "Spring Tomcat Instrument loader" New topic
Author

Spring Tomcat Instrument loader

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

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:



SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

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

Joined: Sep 26, 2006
Posts: 9426
    
    2

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

Joined: Sep 26, 2006
Posts: 9426
    
    2

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

Joined: Mar 07, 2010
Posts: 1666
    
    7

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.


[How To Ask Questions][Read before you PM me]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

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

Joined: Sep 26, 2006
Posts: 9426
    
    2

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Tomcat Instrument loader