Saturday, September 26, 2009

Classloaders, shared directory and endorsed directory of Tomcat 5.5 and 6.0

Tomcat 5.5 Class Loader: http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
Tomcat 6.0 Class Loader: http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

Tomcat 5.5

Class loader hierarchy
image  (from tomcat 5.5 document)

Class loaders:

  • Boostrap, System
  • Common:
    visible to both Tomcat internal classes and to all web applications.
    Related directories
    • classes and resources in: $CATALINA_HOME/common/classes
    • jar files in: $CATALINA_HOME/commons/endorsed, $CATALINA_HOME/commons/i18n and $CATALINA_HOME/common/lib
  • Catalina
    include all classes and resources required to implement Tomcat 5 itself. These classes and resources are TOTALLY invisible to web applications.
    Related directories:
    • classes and resources in: $CATALINA_HOME/server/classes
    • jars in: $CATALINA_HOME/server/lib
  • Shared
    Shared resources are shared across all web applications. (They are not used by Tomcat internal classes).
    Related directories
    • classes and resources in: $CATALINA_BASE/shared/classes
    • jars in: $CATALINA_BASE/shared/lib
  • WebappX
    Load web app specific resources and jars.
    Related directories
    • classes and resources: <web-app-dir>/WEB-INF/classes
    • jars: <web-app-dir>/WEB-INF/lib

Note: $CATALINA_BASE (not $CATALINA_HOME) is used class loader “Shared”.

#   CATALINA_HOME   May point at your Catalina "build" directory.
#
#   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions
#                   of a Catalina installation.  If not present, resolves to
#                   the same directory that CATALINA_HOME points to.

Tomcat 6.0

Class loader hierarchy
image   (from tomcat 6.6 document)
Similar to the hierarchy in tomcat 5.5. 
The difference is that class loaders Catalina and Shared are not present in tomcat 6.6.
For Class loader Common, the related directories are different. In tomcat 6, classes, resources and jars under directory $CATALINA_HOME/lib (in tomcat 5.5, the directory is $CATALINA_HOME/common/classes, $CATALINA_HOME/common/lib, etc) are loaded by class loader Common.

These directories under which classes and resources are searched for can be changed by modifying configuration file $CATALINA_HOME/conf/catalina.properties.
Default values for class loader search directories are:

common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar
server.loader=
:shared.loader=

If you still want to use shared directory in the way specified in tomcat 5.5, you can change value of property shared.loader.
For example: shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

Endorsed directory

Tomcat 5.5

“Tomcat utilizes this mechanism by including the system property setting
-Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed in the command line that starts the container. Therefore, you can replace the parser that is installed in this directory, and it will get used even on a JDK 1.4 system.”

Tomcat 6.0

Tomcat utilizes this mechanism by including the system property setting
-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS in the command line that starts the container.

Variable JAVA_ENDORSED_DIRS is specified in file setclasspath.sh: 
    JAVA_ENDORSED_DIRS="$BASEDIR"/endorsed

Variable BASEDIR is specified in file catalina.sh:
    BASEDIR="$CATALINA_HOME"

In other words,
    in tomcat 5.5, the default endorsed directory is $CATALINA_HOME/common/endorsed
    in tomcat 6.0, the default endorsed directory is $CATALINA_HOME/endorsed

Thursday, September 24, 2009

Apache ten years

Some really nice articles/interviews about Apache Software Foundation:
http://dev.day.com/microsling/content/blogs/main/apachebirthday.html
ASF highlights: 1999-2009 http://www.apache.org/press/highlights.html
Details about how ASF works: http://www.apache.org/foundation/how-it-works.html
eWeek: 11 Apache Technologies that Have Changed Computing in the Last 10 Years
http://www.eweek.com/c/a/Application-Development/11-Apache-Technologies-that-Have-Changed-Computing-in-the-Last-10-Years-469693/

Saturday, September 12, 2009

SVN: exclude some files out of version control (using svn:ignore)

Sometimes, you don’t want SVN to include all you files in the source code directory because they may be temporary files generated by developers or tools (vimcreates .swp file when a file is opened in vim).
SVN book: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.ignore.html

Two ways

o   Global change: it is applied to all svn operations performed using the runtime configuration. In other words, it changes the configuration of svn application (not a specific directory/file under control of svn)

o   Bind configuration to a specific version tree using svn:ignore property.

o   The ignore pattern checking is applied only during adding of unversioned directories/files to svn control.
Once an object is under Subversion's control, the ignore pattern mechanisms no longer apply to it. In other words, don't expect Subversion to avoid committing changes you've made to a versioned file”

o   Its value contains a list of NEWLINE-delimited file pattern

o   They don’t override global global-ignores configuration, but append to the list

o   “the patterns found in the svn:ignore  property apply only to the directory on which that property is set, and not to any of its subdirectories.”
Use switch –R if you want to apply it recursively.

o   Usage
svn propset svn:ignore -F file-contains-ignore-patterns path-ignore-to-be-applied
Examples:
    svn propset svn:ignore -F .svn-ignore .
    #recursive. If you change the direcotry tree after this command is run,
    #you need to return following command to make the newly created directories/files controlled also by ignore pattern.
    svn -R propset svn:ignore -F .svn-ignore .   
    # edit a property

    svn propedit svn:ignore .     #edit the ignore patterns using the preconfigured editor.
Note:
  *)  If you use a file to specify ignore patterns, you must rerun the command
              "svn propset svn:ignore -F your-patter-file ."
    to make svn reread the file after the pattern file is changed.
  *)  One alternative is to use
              "svn propedit svn:ignore ."
       to edit the property configuration. Then the change you made immediately takes effect. However, the new property value will not be written back to the original pattern file. You can use command
    "svn propget svn:ignore . >  pattern-file"
to export the new value to your pattern file.

o   File Pattern
*: match any sequence of characters
?: match single character
[char-set]: match the specified char set.

o   Command “svn add”
When you use wildcards, you should be careful because it may make svn bypass the ignores check.
See http://svnbook.red-bean.com/trac/ticket/115.
Basically, “svn add * bypasses the ignores system. However, it has been fixed. So if you are using a latest svn version, it should not be a problem.
Anyway, use “svn add --force . when you can (it makes svn check the whole specified directory tree).

o   Command “svn status” won’t list ignored directories/files.
Use “svn status --no-ignore” to list status of all files including ignored ones.

Tuesday, September 08, 2009

test

Hello, worl