0 Replies Latest reply on Sep 15, 2004 5:16 AM by Mads Pultz

    WAR isolation in 3.2.2

    Mads Pultz Newbie

      Hi,

      I'm trying to isolate a WAR file as described on:

      http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

      In my small example I'm trying to force a servlet to a use version of Xerces that I distribute with the servlet (located under WEB-INF/lib). It fails during deployment with the following exception:

      10:52:52,967 INFO [STDOUT] JDOM Exception: org.jdom.JDOMException: Could not load default SAX parser: org.apache.xerces
      .parsers.SAXParser: SAX2 driver class org.apache.xerces.parsers.SAXParser does not implement XMLReader
      10:52:52,967 ERROR [STDERR] org.jdom.JDOMException: Could not load default SAX parser: org.apache.xerces.parsers.SAXPars
      er: SAX2 driver class org.apache.xerces.parsers.SAXParser does not implement XMLReader
      10:52:52,967 ERROR [STDERR] at org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:495)
      10:52:52,967 ERROR [STDERR] at org.jdom.input.SAXBuilder.build(SAXBuilder.java:341)
      10:52:52,967 ERROR [STDERR] at org.jdom.input.SAXBuilder.build(SAXBuilder.java:684)
      10:52:52,967 ERROR [STDERR] at org.jboss.mx.metadata.XMLMetaData.build(XMLMetaData.java:242)
      10:52:52,967 ERROR [STDERR] at org.jboss.mx.modelmbean.XMBean.(XMBean.java:191)
      10:52:52,967 ERROR [STDERR] at org.jboss.mx.modelmbean.XMBean.(XMBean.java:218)
      10:52:52,967 ERROR [STDERR] at org.jboss.web.tomcat.mbean.ServletInfo.createServletMBean(ServletInfo.java:45)
      10:52:52,967 ERROR [STDERR] at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.createWebContext(EmbeddedTomcatService
      .java:543)
      10:52:52,967 ERROR [STDERR] at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.performDeploy(EmbeddedTomcatService.ja
      va:309)
      10:52:52,967 ERROR [STDERR] at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:428)
      10:52:52,967 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      10:52:52,967 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      10:52:52,967 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      10:52:52,977 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
      10:52:52,977 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      10:52:52,977 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      10:52:52,977 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java
      :284)
      10:52:52,977 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      10:52:52,977 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      10:52:52,977 ERROR [STDERR] at $Proxy6.deploy(Unknown Source)
      10:52:52,987 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:30
      2)
      10:52:52,987 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)

      10:52:52,987 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractD
      eploymentScanner.java:201)
      10:52:52,997 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymen
      tScanner.java:274)
      10:52:52,997 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      10:52:52,997 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      10:52:52,997 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      10:52:53,007 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      10:52:53,007 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java
      :284)
      10:52:53,007 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      10:52:53,017 ERROR [STDERR] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      10:52:53,017 ERROR [STDERR] at $Proxy0.start(Unknown Source)
      10:52:53,017 ERROR [STDERR] at org.jboss.system.ServiceController.start(ServiceController.java:394)
      10:52:53,017 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
      10:52:53,027 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      10:52:53,027 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      10:52:53,027 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java
      :284)
      10:52:53,037 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      10:52:53,037 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      10:52:53,037 ERROR [STDERR] at $Proxy4.start(Unknown Source)
      10:52:53,047 ERROR [STDERR] at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      10:52:53,047 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      10:52:53,047 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      10:52:53,047 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      10:52:53,057 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
      10:52:53,057 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:52:53,057 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      10:52:53,057 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      10:52:53,067 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      10:52:53,067 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java
      :284)
      10:52:53,067 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      10:52:53,077 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      10:52:53,077 ERROR [STDERR] at $Proxy5.deploy(Unknown Source)
      10:52:53,077 ERROR [STDERR] at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
      10:52:53,077 ERROR [STDERR] at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
      10:52:53,087 ERROR [STDERR] at org.jboss.Main.boot(Main.java:150)
      10:52:53,087 ERROR [STDERR] at org.jboss.Main$1.run(Main.java:395)
      10:52:53,087 ERROR [STDERR] at java.lang.Thread.run(Thread.java:536)
      10:52:53,087 ERROR [STDERR] Caused by: java.lang.ClassCastException
      10:52:53,087 ERROR [STDERR] at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:131)
      10:52:53,097 ERROR [STDERR] at org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:487)
      10:52:53,097 ERROR [STDERR] ... 57 more
      10:52:53,097 ERROR [STDERR] Caused by:
      10:52:53,097 ERROR [STDERR] java.lang.ClassCastException
      10:52:53,097 ERROR [STDERR] at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:131)
      10:52:53,097 ERROR [STDERR] at org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:487)
      10:52:53,097 ERROR [STDERR] at org.jdom.input.SAXBuilder.build(SAXBuilder.java:341)
      10:52:53,107 ERROR [STDERR] at org.jdom.input.SAXBuilder.build(SAXBuilder.java:684)
      10:52:53,107 ERROR [STDERR] at org.jboss.mx.metadata.XMLMetaData.build(XMLMetaData.java:242)
      10:52:53,107 ERROR [STDERR] at org.jboss.mx.modelmbean.XMBean.(XMBean.java:191)
      10:52:53,107 ERROR [STDERR] at org.jboss.mx.modelmbean.XMBean.(XMBean.java:218)
      10:52:53,117 ERROR [STDERR] at org.jboss.web.tomcat.mbean.ServletInfo.createServletMBean(ServletInfo.java:45)
      10:52:53,117 ERROR [STDERR] at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.createWebContext(EmbeddedTomcatService
      .java:543)
      10:52:53,117 ERROR [STDERR] at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.performDeploy(EmbeddedTomcatService.ja
      va:309)

      However, the application apparently works as intended. It prints out Xerces version 2.6.2 and not 2.0.1 which is bundled with JBoss. But I do not like the exception during deployment. Anyway to get rid of it?

      If I tell Tomcat to isolate war files globally (by editing deploy/jbossweb-tomcat41.sar/META-INF/jboss-service.xml) the situation is worse. When the web-console is deployed NullPointerExceptions are thrown. My servlet deploys fine. However, it does not write the correct version of Xerces when I hit the servlet (2.0.1 and not 2.6.2 which is the one I distribute).

      My code is below. Any suggestions to what is going on. Is it at all possible to distribute ones own XML parser?

      import org.apache.xerces.impl.Version;
      
      import java.io.*;
      
      import javax.servlet.http.*;
      import javax.servlet.*;
      
      public class HelloServlet extends HttpServlet {
       public void doGet(HttpServletRequest req,
       HttpServletResponse res)
       throws ServletException, IOException {
       PrintWriter out = res.getWriter();
      
       System.out.println("I'm hit. I'm using Xerces version " + Version.fVersion);
       out.println("Hello, world!");
       out.println("I'm using Xerces version " + Version.fVersion);
       out.close();
       }
      }
      


      My jboss-web.xml looks like this:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE jboss-web
       PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
      
      <jboss-web>
       <class-loading java2ClassLoadingCompliance="false" >
       <loader-repository>
       jboss.cl.test:loader=JBossCLExample.war
       <loader-repository-config>
       java2ParentDelegaton=false
       </loader-repository-config>
       </loader-repository>
       </class-loading>
      </jboss-web>
      


      My web.xml looks like this:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
      <web-app>
      
       <servlet>
       <servlet-name>hello</servlet-name>
       <servlet-class>HelloServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>hello</servlet-name>
       <url-pattern>/hello</url-pattern>
       </servlet-mapping>
      
      </web-app>