3 Replies Latest reply on Mar 5, 2011 1:09 AM by mahdiiran

    Jboss 5.1.0.GA this.getClass().getResource() issue

    mahdiiran

      Hi dear all.

       

      I have a big problem with this.getClass().getResource() function.

      I have a resource named ehr.cfg.xml in two place one in an EAR project and another one in a standalone ejb3 jar.

      When i call this.getClass().getResource("/ehr.cfg.xml") in a class in EAR project the URI return is not belong to EAR project instead of the URI is belong to standalone ejb3 jar, I require to find root directory of deployed project.

      Is there a class-loading Bug in jboss 5.1.0.GA?

        • 1. Jboss 5.1.0.GA this.getClass().getResource() issue
          mahdiiran

          Dear All

          I change this.getClass().getResource() with Thread.currentThread().getContextClassLoader().getResource() but the problem already exist !!! ???

          ANY HELP!

          • 2. Jboss 5.1.0.GA this.getClass().getResource() issue
            alesj

            JBoss' ClassLoading has always had this feature / notion of sharing resources across non-isolated deployments inside same classloading domain.

            Unless you isolate your deployment, one can access any resource from your deployment, if both are in the same CL domain.

            Same goes the other way around.

             

            Read more about it here:

            * http://java.dzone.com/articles/jboss-microcontainer-classloading

            • 3. Re: Jboss 5.1.0.GA this.getClass().getResource() issue
              mahdiiran

              Very thanks for your reply

              I follow your enclosed URL and add some changes to default class loader behavior

              I add the jboss-classloading.xml whit the following content

               

              <classloading xmlns="urn:jboss:classloading:1.0"

                            domain="IsolatedWithParentDomain"

                            parent-domain="DefaultDomain"

                            top-level-classloader="true"

                            export-all="NON_EMPTY"

                            import-all="true"

                            parent-first="false">

              </classloading>

               

              After that I received some ClassCastException related to some duplicated jars like jaxb xmlxcerser jpa and etc

              I fix all Jar conflicts and now my problem solved.

              very thanks.