users@glassfish.java.net

Re: Cannot deploy application that includes xerces .jar to ...

From: <forums_at_java.net>
Date: Tue, 1 Nov 2011 22:21:27 -0500 (CDT)

Did some surfing and found some clues and a workaround.  Xerces seems to be
a replacement for the default XML parser included in the JDK, which has some
provision for supporting alternate XML parsers, and apparently GlassFish (or
the JDK itself, or J2EE, or something) isn't happy that there are two
different XML parsers vying for attention.  It seems that the default one
may already be loaded when Xerces insists on getting in on the action.

I found something about "application-specific class loading" here:
download.oracle.com/docs/cd/E19798-01/821-1752/gatej/index.html [1] and here:
blogs.oracle.com/sivakumart/entry/classloaders_in_glassfish_an_attempt [2]. 
The second link suggests that, "An application can be configured to  use a
different JAXP implementation than the one bundled with the JDK, by using
the --libraries attribute [3] while deploying the application," but I
couldn't find any documentation about how to use the --libraries attribute,
much less how to get NetBeans to use it when it does an in-place deployment
of a project I'm actively developing.  The page did have enough information
to give me a workaround, however.  It indicated that jars could be added to
the following directories to get GlassFish to load them:

\* domains/domain1/lib - domain wide scope, common classloader add the jars
automatically
\* domains/domain1/config/cluster1-config/lib - config wide, update
classpath-prefix or classpath-suffix
\* domains/domain1/lib/applibs - application scope, added to application
class loader automatically
\* domains/domain1/config/cluster1-config/lib/ext - adds to java.ext.dirs [4]
automatically

I first tried putting the xerces .jar in domains/domain1/lib/applibs, but
that didn't resolve my problem.  When I put it in domains/domain1/lib,
however, it did.  The link in my initial question references the same
workaround, but of course that poster wasn't any happier with that solution
than I am - so much for making deployment easy by having everything packaged
up in a nice war file.

Coming from the JSE/Swing world in which I've spent the bulk of the past
decade, I have to say it's taking me quite some time to become comfortable
with web servers and JSF - a lot of voodoo going on under the hood.


[1] http://download.oracle.com/docs/cd/E19798-01/821-1752/gatej/index.html
[2]
http://blogs.oracle.com/sivakumart/entry/classloaders_in_glassfish_an_attempt
[3] https://glassfish.dev.java.net/nonav/javaee5/docs/DG/beade.html#gatej
[4] http://java.sun.com/j2se/1.5.0/docs/guide/extensions/extensions.html

--
[Message sent by forum member 'krahe']
View Post: http://forums.java.net/node/859515