4 Replies Latest reply on Jul 10, 2011 9:22 PM by Brian Wallis

    Shared loader-repository

    Brian Wallis Master

      I am trying to port an existing app to AS7 (it is currently running is AS5/6). This is a quite old application that needs a lot of work to update it. This work is gradually being done but for the moment we have to live with a lot of the problems in the code. It was originally an application that embedded a version of tomcat to handle a web interface. A couple of years ago it was turned about and became a few war files deployed into 3 separate tomcat instances. This has again changed to being a few war files deployed into one or two JBoss instances. I think we are progressing :-)

       

      Enough history. We have a feature so that we can develop and deploy new REST or SOAP interfaces outside of our normal release cycle by having these interfaces contained in their own war files. So that these can have access to the internal service APIs in the core product we share the loader repository used by the war by declaring it in the jboss-web.xml deployment descriptor, like so:

       

      {code:xml}

      <jboss-web>

        <class-loading java2ClassLoadingCompliance="false">

        <loader-repository>

                                    au.com.infomedix:archive=InfomedixAppClassLoader

                                    <loader-repository-config>java2ParentDelegation=false

        </loader-repository-config>

        </loader-repository>

        </class-loading>

        <context-root>admin</context-root>

      </jboss-web>

      {code}

       

      Both wars have the same loader repository name.

       

      This is not ideal, bit of a hack really, but works quite well for us.

       

      Is there a way that I could achieve the same thing in JBoss AS7?

       

      thanks

       

      P.S. It would be nice if I could build a war that could be deployed in both AS6 and AS7. The loader-repository element in the jboss-web.xml is not part of the schema anymore in AS7. It would have been nice if it was valid in the schema in AS7 but generated a runtime warning. Now I need two different wars if I am using isolated class loaders in AS6. If the loader-repository was just ignored I think it would just work in AS7 since isolation is the default behaviour.

        • 1. Re: Shared loader-repository
          Kabir Khan Master

          If your 'core' deployment is called core-app.war, and you have an additional deployment called additional.war, you can configure additional.war to see classes from core.war by adding the following additional.war/META-INF/MANIFEST.MF:

          Manifest-Version: 1.0

          Dependencies: deployment.core-app.war

          To have visibility the other way might be possible, although I don't know how off the top of my head. Please check back if that is the case

          1 of 1 people found this helpful
          • 2. Re: Shared loader-repository
            Brian Wallis Master

            Thanks, that may fix it but I have another issue. The war I am deploying also uses RESTEasy and I just cannot get it to act on the annotations to activate the REST interface.

             

            My MANIFEST.MF file now has the following in it

             

            {code}

            Manifest-Version: 1.0

            Dependencies: deployment.udr-app.war,

                org.jboss.resteasy.resteasy-jaxrs services,

                org.jboss.resteasy.resteasy-jsapi,

                org.jboss.resteasy.resteasy-jaxb-provider services,

                org.jboss.resteasy.resteasy-jackson-provider services,

                org.jboss.resteasy.async-http-servlet-30,

                org.jboss.resteasy.resteasy-cdi services,

                org.jboss.resteasy.resteasy-multipart-provider services,

                org.jboss.resteasy.resteasy-atom-provider services

             

            {code}

             

             

            I have no idea if this is correct or not. I believe that I need to have the services initialised to get the annotations to work.

             

            At the moment it all deploys but there are no REST services available. I just get a 503 "The requested service () is not currently available"

            • 3. Re: Shared loader-repository
              Stuart Douglas Master

              You should not need to list the resteay dependencies.

               

              How is your app using jax-rs? Have you sub-classed Application? Can you post the full log and details of the way the app is structured?

              • 4. Re: Shared loader-repository
                Brian Wallis Master

                I added the rest easy dependencies when the app didn't work. It deploys fine but does not seem to activate the URLs to access the web services.

                 

                {code:xml}

                CPFRestAdmin.war

                  - META-INF

                     - MANIFEST.MF

                  - WEB-INF

                     - classes - there is a single REST class

                     - jboss-web.xml

                     - lib (empty)

                     - web.xml

                {code}

                 

                jboss-web.xml:

                 

                {code}

                <jboss-web>

                  <context-root>admin</context-root>

                </jboss-web> 

                {code}

                 

                web.xml:

                 

                {code:xml}

                <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

                  <display-name>CPFRestAdmin</display-name>

                </web-app>

                {code}

                 

                The class code is a bit like this:

                 

                {code:java}

                 

                @Path("query")

                public class RestAdminQuery

                {

                 

                    @GET

                    @Path("version")

                    public String getVersion()

                    {

                        Version cmd = new Version();

                ---

                    }

                }

                {code}

                 

                so the URL http://localhost:8080/admin/query/version should call the above function.

                 

                This is deployed to an AS7 CR1 appserver. The same war works in AS6 with the addition of the following to the jboss-web.xml file (for access to the core application classes)

                 

                {code:xml}

                <class-loading java2ClassLoadingCompliance="false">

                                    <loader-repository>

                                              au.com.infomedix:archive=InfomedixAppClassLoader

                                              <loader-repository-config>java2ParentDelegation=false

                                              </loader-repository-config>

                                    </loader-repository>

                          </class-loading>{code}

                 

                 

                Updated to add AS6 jboss-web.xml contents