Thursday, February 18, 2010

Configure endorsed libraries in Tomcat 6

Keywords:
Tomcat 6 endorsed java.endorsed.dirs Endorsed Standards Override Mechanism XML libraries xerces

Problem:
If your webapp needs its own XML libraries (xerces in particular) how do you get Tomcat 6 to use this and not the JAXP APIs packaged into the JSE? This used to be as simple as dropping them into ${CATALINA_BASE}/common/endorsed but there's only a ${CATALINA_BASE}/lib folder ...

Solution:
Thankfully found the solution in this blog (and comments).

Simply, create a ${CATALINA_BASE}/endorsed folder and drop the jar files in there. Tomcat will be setup to use this if it exists.


Notes:
No explicit mention of this in Tomcat 6 Class Loader notes

It does note the -Djava.endorsed.dirs system property is set but you need to check setclasspath.[bat|sh] for when it's set and what it's set to by default - ie ${CATALINA_BASE}/endorsed.

2 comments:

Anonymous said...

The default endorsed path is ${CATALINA_HOME}/endorsed, not ${CATALINA_BASE}/endorsed.

See http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html#XML_Parsers_and_Java

Rodrigo Labanca said...

I had a problem with JAX-WS version 2.2 on Java 6. The endorsed libs on ${JAVA_HOME}/lib/endorsed wasn't working.

But now it's working now!!

Thank you very much!