- This topic has 2 replies, 2 voices, and was last updated 13 years, 3 months ago by
Greg Soulsby.
-
AuthorPosts
-
Greg SoulsbyMemberI have multiple web apps to deploy. Dont want to deploy the same Spring and MyEclipse jar files in each one. So is the strategy to
– when scaffolding select the “use eclipse versions of jar files”
– on the target Tomcat server put these Spring and MyEclipse jars into $CATALINA_BASE/shared/classesIs that all that is required?
Go my advice from here http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html where there is line that says
Shared – This class loader is the place to put classes and resources that you wish to share across ALL web applications (unless Tomcat internal classes also need access, in which case you should put them in the Common class loader instead). All unpacked classes and resources in $CATALINA_BASE/shared/classes, as well as classes and resources in JAR files under $CATALINA_BASE/shared/lib, are made visible through this class loader.
cconwayMemberWhat you describe is a viable option but the advisability of using it depends on the version of Tomcat you’re using. For Tomcat 6 (which is the integrated Tomcat in ME4S 10), there is no “shared” classloader, only a common classloader that makes classes available to tomcat and all of your apps. Adding your libs to the common classloader modifies the classloading order which can result in unexpected problems because now the application’s classes are not isolated to just the application, but can impact Tomcat itself.
Here is the classloading reference for Tomcat 6: http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html.
If you do decide to go the shared classes route, you should be aware of these items:
First, as a best practice, I’d use shared/lib instead of shared/classes. By convention, lib is for jar files, classes is for java class files (in exploded form).
Second, even when using the Eclipse classpath containers option on the scaffolding wizard, the jar files are deployed with the project unless you explicitly exclude them. To exclude them from the deployment on a project-level basis:
1. Right-click on the project and select Properties.
2. Select MyEclipse > Web
3. Select the Deployment tab.
4. Un-check the boxes under the “Library Deployment Policies” header.
5. Press Ok to save the changes.
6. Perform a clean build. If the project is deployed to the server, the clean build should remove the libraries already deployed to WEB-INF/lib. Verify by right-clicking on the project in the Servers view and selecting “Browse Deployment Location”.Third, the shared/classes and shared/lib folders (at least in my Tomcat) aren’t on the classpath of the server. To get the libs there, I prepended ${catalina.base}/shared/lib/*.jar to the “common.loader” configuration inside the catalina.properties file. Of course, if you’re using Tomcat 5.5 this configuration would be different.
Greg SoulsbyMemberThanks for the great response – that really helps – I will try this later in the week.
-
AuthorPosts