5 Replies Latest reply on Aug 30, 2011 9:14 AM by grodd

    Manipulating class-path order jboss-deployment-structure.xml

    grodd

      In JBoss AS 6 the classpath of the jars contained within the deployment can be directly manipulated using the jboss-structure.xml file, allowing you to force certain jars to be searched before others.

       

      Ex:

       

      <structure>

        <context>

          <path name="" />

          <metaDataPath>

            <path name="META-INF" />

          </metaDataPath>

          <classpath>

            <path name="lib/TestJar1.jar"/>

            <path name="lib/TestJar2.jar"/>

            <path name="lib/TestJar3.jar"/>

            <path name="lib" suffixes=".jar"/>

          </classpath>

        </context>

      </structure>

       

       

      Is there a way to do this in the jboss-deployment-structure.xml file that is used with JBoss AS 7?  I've tried using the resources element to specify an ordering, but that didn't seem to work.

        • 1. Re: Manipulating class-path order jboss-deployment-structure.xml
          jaikiran

          Why do you want the ordering? You have multiple jars within your app with a different version of the same class?

          • 2. Re: Manipulating class-path order jboss-deployment-structure.xml
            grodd

                 Unfortunately, yes that is the case.   We have two applications, (client based and server based) that share a lot of code.  Some classes used by the client were changed to make them more suitable for the server based application.  These changes weren’t integrated back into the client code; instead a copy of the class was made (with modifications) and put on the classpath before the unmodified class.

                  In Jboss 4 this was accomplished by putting the classes in a jar with a number in the front exploiting the lexicographical load ordering of jars.  When we upgraded to 6, we used the classpath entry in the jboss-structure.xml file to specify the order.  Ideally, these modified classes wouldn't exist, but there are some incompatibilities that would make it difficult/time consuming to integrate the code that has been changed.

            • 3. Re: Manipulating class-path order jboss-deployment-structure.xml
              grodd

              On a side note, I may have found a bug in the parsing of jboss-deployment-structure.xml when I add a filter to a resouce-root like this:

               

               

              <resource-root path="lib">

                <filter>

                   <include path="/**" />

                </filter>

              </resource-root>

               

               

              I end up getting this exception...

               

               

              16:20:34,755 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."myEar.ear".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myEar.ear".PARSE: Failed to process phase PARSE of deployment "myEar.ear"

                at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

                at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_20]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_20]

                at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]

              Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Error loading jboss-structure.xml from C:\servers\jboss-as-7.0.1.Final\standalone\tmp\vfs\temp6da2fecd4aea20e0\myEar.ear-4b5e7025d8eaa324\contents\META-INF\jboss-deployment-structure.xml

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:402)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:375)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:289)

                at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

                ... 5 more

              Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[40,5]

              Message: Unexpected content of type 'element end' named 'filter'

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.unexpectedContent(DeploymentStructureDescriptorParser.java:483)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parseResourceRoot(DeploymentStructureDescriptorParser.java:909)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parseResources(DeploymentStructureDescriptorParser.java:827)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parseModuleStructureSpec(DeploymentStructureDescriptorParser.java:686)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parseModule(DeploymentStructureDescriptorParser.java:660)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parseStructureContents(DeploymentStructureDescriptorParser.java:581)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parseDocument(DeploymentStructureDescriptorParser.java:510)

                at org.jboss.as.server.deployment.module.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:396)

                ... 8 more

               

              Has anyone else seen this?

               

              -Jarod

              • 4. Re: Manipulating class-path order jboss-deployment-structure.xml
                venkman

                Same Error here.

                 

                I generated a jboss-deployment-structure.xml EXACTLY like mentioned here (with xml processing instruction in front)

                 

                https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

                 

                copy it in the META_INF of my ear, deployed it and got the error above mentioned.

                 

                I'm using the 7.0.1

                 

                Any suggestions?

                • 5. Re: Manipulating class-path order jboss-deployment-structure.xml
                  grodd

                  I'm pretty sure this is a bug so I've submitted a report to JIRA https://issues.jboss.org/browse/AS7-1681. Hopefully the fix will make it into 7.0.2.  My original problem is still an issue though.