6 Replies Latest reply on Feb 21, 2012 1:04 PM by Noa Drach

    Accessing a resource inside the EAR from a module

    Noa Drach Novice

      Hello,

       

      I'm migrating an app for 4.2.3 and where I have in the META-INF of the ear a properties file and it was available to all jars in the ear using

       

      ResourceBundle.getBundle("META-INF/myProps");
      

       

      the file is located inside MyEar/lib/MyJar/META-INF

       

      If I do this command inside another EJB jar that is inside the EAR this works OK

      but if I place this line inside a module that my app is using I get

       

      java.util.MissingResourceException: Can't find bundle for base name META-INF/myProps

       

      am I missing something here?

       

      the module is defined as a global module - can that be the problem?

       

      Thanks,

      Noa

        • 2. Re: Accessing a resource inside the EAR from a module
          Noa Drach Novice

          If I understood this post correctly, then I think that putting the resource file at

           

          MyEar/lib/MyJar/META-INF

          should have solved the problem.

           

          but the problem I have is that this works from a code that is written inside the EJB but if one line after that I call code that is written inside a module and this executes the exact same load - it fails.

           

          Attached are:

          1. the EAR file is it is deployed inside jboss
          2. the module folder that you need to add to the modules
          3. 4 eclipse projects that are
            1. the module code
            2. the EJB code
            3. the jar that sits in the lib
            4. the EAR

           

          if you will deploy iy to jboss you can expect the following output:

           

          13:55:01,410 INFO  [stdout] (MSC service thread 1-14) The following execution will pass
          13:55:01,411 INFO  [stdout] (MSC service thread 1-14) before read resource inside the ear
          13:55:01,414 INFO  [stdout] (MSC service thread 1-14) Told you
          13:55:01,415 INFO  [stdout] (MSC service thread 1-14) after read resource inside the ear
          13:55:01,416 INFO  [stdout] (MSC service thread 1-14) The following execution will fail
          13:55:01,417 INFO  [stdout] (MSC service thread 1-14) before read resource inside the module
          13:55:01,421 INFO  [stdout] (MSC service thread 1-14) Told you
          13:55:01,422 ERROR [stderr] (MSC service thread 1-14) java.util.MissingResourceException: Can't find bundle for base name META-INF/logMessages, locale en_US
          13:55:01,423 ERROR [stderr] (MSC service thread 1-14)           at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
          13:55:01,424 ERROR [stderr] (MSC service thread 1-14)           at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
          13:55:01,425 ERROR [stderr] (MSC service thread 1-14)           at java.util.ResourceBundle.getBundle(ResourceBundle.java:705)
          13:55:01,426 ERROR [stderr] (MSC service thread 1-14)           at my.module.DemoModuleAction.loadResource(DemoModuleAction.java:7)
          13:55:01,427 ERROR [stderr] (MSC service thread 1-14)           at my.ejb.StartUp.startup(StartUp.java:37)
          ... 
          13:55:01,472 INFO  [stdout] (MSC service thread 1-14) after read resource inside the module
          
          
          13:55:01,474 INFO  [org.jboss.as] (MSC service thread 1-3) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 7481ms - Started 255 of 336 services (79 services are passive or on-demand)
          13:55:01,519 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "DemoEAR.ear"
          
          
          • 3. Re: Accessing a resource inside the EAR from a module
            Stephen Coy Master

            Is there any particular reason that you need to use a jboss module?

             

            Typically code inside jboss modules will not have visibility of resources anywhere inside your EAR file.

            • 4. Re: Accessing a resource inside the EAR from a module
              Noa Drach Novice

              I have a jar containing code that has a functionality that is shared by several applications.

               

              it used to be in the lib folder - basically I thought that the same way I define the oracle driver as a module, I should also define my jar as a module.

               

              the alternative is for each EAR to hold the jar in it's lib folder?

              • 5. Re: Accessing a resource inside the EAR from a module
                Stephen Coy Master

                The problem with the module idea is that code inside modules cannot "see" resources inside your application.

                 

                Someone maybe able to provide a solution that plays fun and games with the classloading configuration.

                 

                Possibly the simplest solution would be to pass the ResourceBundle up your module code.

                • 6. Re: Accessing a resource inside the EAR from a module
                  Noa Drach Novice

                  Thanks, this is the workaround i implemented so far.

                   

                  I just wondered if i missed something in the modules concept.