Hi everyone,

In my application I need to use a library that requires two custom
Charset implementations which are delivered in a jar, with proper SPI
meta information (META-INF/services/...). It works under Eclipse when
doing unit-tests.

This all is using Apache Tomcat 6.0.18, under Sun Java 1.6.0_07, Linux
2.6 (Kubuntu 8.04.2).

I've included the encoding-library jar in $WEBAPP/WEB-INF/lib, and
when I delpoy my webapp, an ExceptionInInitializerError is thrown as
one of the classes statically references the charset (private static
final Charset DEFAULT_CHARSET = Charset.forName("...");).

However when I test this with custom ServletContextListener [1] it is
able to find my custom Charset-implementations.

Looking at OpenJDK6 java.nio.charset.Charset implementation it's
"private static Charset lookupviaProviders(final String charsetName)"
does the lookup using
java.security.AccessController.doPriviledged(PriviledgedAction<T>).
It's priviledged action seems to always create a new anonymous class
instance that wraps ServiceLoader.load(CharsetProvider.class,
cl).iterator() and iterate it until it's exhausted or a charset is
found...

I guess the System's ClassLoader cannot see the webapp's libraries at
all? Or is this a fault in Tomcat's webapp -classloader, not exposing
SPI meta information?

This question has been brought up before; by Christoph Kutzinski in
2005 [2], but was left unanswered.

Is it impossible to have webapps that benefit from SPIs and custom
charset-implementations?

1 = http://www.rifers.org/paste/show/8801
2 = http://marc.info/?l=tomcat-user&m=111927941225330&w=2

-- 
-- Joonas Koivunen

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to