2 Replies Latest reply on Jul 16, 2012 10:29 AM by rajakumar

    In Jboss AS7, jboss-web.xml NOT supporting multiple Virtual Hosts

      Dear group,

       

      The schema definition for Jboss-web.xml file ("http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd") supports mutiple virtualhosts.

      But when we specify multiple virtual hosts for JbossAS7, we are encountering below failures

       

      Message: An element of this type named 'VIRTUAL_HOST' has already been declared

              at org.jboss.metadata.parser.util.MetaDataElementParser.duplicateNamedElement(MetaDataElementParser.java:224)

              at org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser.parse(JBossWebMetaDataParser.java:129)

              at org.jboss.as.web.deployment.JBossWebParsingDeploymentProcessor.deploy(JBossWebParsingDeploymentProcessor.java:69)

              ... 6 more

       

      Is there anyway to recitify this problem?

      And which version of jboss-web dtd file is being used by JbossAS7.

       

      If any one can shed some light on the above, it will be very helpful. Thanks

       

      Best Regards,

      Raj

        • 1. Re: In Jboss AS7, jboss-web.xml NOT supporting multiple Virtual Hosts
          ctomc

          hi,

           

          jboss-web-4.2.dtd was used for jboss 4.2

           

          you should use http://www.jboss.org/j2ee/schema/jboss-web_6_0.xsd for defining jboss-web.xml

           

           

           

          --

          tomaz

          • 2. Re: In Jboss AS7, jboss-web.xml NOT supporting multiple Virtual Hosts

            Hi,

             

            Thanks for the reply. I have used the specified schema file, But still it is NOT working for multiple virtual hosts.

             

            Below is the content of jboss-web.xml

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

            <jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_6_0.xsd"

                version="6.0">

               <virtual-host>vhost1</virtual-host>

               <virtual-host>vhost2</virtual-host>

            </jboss-web>

             

            Below error is occuring during the deployment

            Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018014: Failed to parse XML descriptor "/D:/APPLICATIONS/jboss-as-7.1

            .1.Final/bin/content/CmrStationV2.ear/BusinessWebDynamic.war/WEB-INF/jboss-web.xml" at [7,4]

                    at org.jboss.as.web.deployment.JBossWebParsingDeploymentProcessor.deploy(JBossWebParsingDeploymentProcessor.java:77)

                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1

            .Final]

                    ... 5 more

            Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,4]

            Message: An element of this type named 'VIRTUAL_HOST' has already been declared

                    at org.jboss.metadata.parser.util.MetaDataElementParser.duplicateNamedElement(MetaDataElementParser.java:224)

                    at org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser.parse(JBossWebMetaDataParser.java:129)

                    at org.jboss.as.web.deployment.JBossWebParsingDeploymentProcessor.deploy(JBossWebParsingDeploymentProcessor.java:69)

                    ... 6 more

             

            Please update me if anything incorrect in our jboss-web.xml OR anyother settings to be modified. Thanks in advance

             

             

            I may be wrong, But checking at org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser

            This is trying to create New List first time, but in the subsequent time, this throws exception, rather than adding to existing list.

            If any work around for adding multiple virtual hosts, please update us. THanks

             

                    case 2: // '\002'
                        List virtualHosts = wmd.getVirtualHosts();
                        if(virtualHosts == null)
                        {
                            virtualHosts = new ArrayList();
                            wmd.setVirtualHosts(virtualHosts);
                            virtualHosts.add(getElementText(reader));
                        } else
                        {
                            throw duplicateNamedElement(reader, Element.VIRTUAL_HOST.toString());
                        }
                        break;

             

            Message was edited by: Rajakumar CM