How do I tell JBoss 4.2.3.GA to load jars in my wa

2020-08-01 05:34发布

问题:

I deploy a web archive and that war references a jar file that conflicts with those in $JBOSS_HOME/server/default/lib. I can go and remove the offending jars manually, but I'd prefer a solution that allows me to specify my jars over JBoss's. I would even like to just tell JBoss to exclude specific jars, if that's even possible.

The closest I've come was to add something in jboss-web.xml in my war's META-INF directory, but I'm clearly not doing something right there. This is what I have so far:

<?xml version="1.0" encoding="UTF-8"?>

<jboss-web>
  <class-loading java2ClassLoadingCompliance="false">
    <loader-repository>com.amce:archive=WHATEVER</loader-repository>
    <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
  </class-loading>
</jboss-web>

This fails spectacularly with errors like this:

ERROR [13]] Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory
    at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128)
    at com.sun.faces.config.ConfigureListener$WebXmlProcessor.getConfiguredFactory(ConfigureListener.java:697)
    at com.sun.faces.config.ConfigureListener$WebXmlProcessor.scanForFacesServlet(ConfigureListener.java:669)
   ...

That error leads me to believe I'm just specifying the jboss-web syntax incorrectly (is there an xml schema somewhere)? However I'm not even sure I'm heading down the right path. Is there anyway I can do this without modifying JBoss in anyway?

回答1:

java2ParentDelegation=false. Read here for more details.

Java EE class loading details: Java EE class loading standard



回答2:

jboss-web.xml belongs in your app's WEB-INF directory, not META-INF. your xml file looks right, I compared it to WAR i have deploye to Jboss-4.x