hk2
  1. hk2
  2. HK2-133

Read and Load under "WEB-INF/classes/hk2-locator" Doesn't Work

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Linux 64bit
      JDK v.1.7.0_40
      Tomcat v7.0.34
      HK2 v2.2.0-b20

      Description

      The bellow documentation says that HK2 will be able to find and load "application" inhabitant file under "WEB-INF/classes/hk2-locator." Looking at the class "org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder" by default it seems to always look for a inhabitant file called "default" under the "META-INF/hk2-locator/" instead of looking for inhabitant files under both "META-INF/hk2-locator/" and "WEB-INF/classes/hk2-locator/" resource paths.

      There seems to be a discrepancy between the documentation and what happens and shouldn't HK2 scan for and pickup all inhabitant files under those resource paths regardless of whether they are called application, default, or some arbitrary custom name?

      https://hk2.java.net/integration.html

        Activity

        Hide
        jwells added a comment -

        There are tests in GlassFish under appserver/tests/hk2 that appear to say that hk2 files located in WEB-INF/classes/hk2-locator/application are in fact picked up and used in applications. I'll investigate this a little more, but I think this is working as designed. I do not believe that the ClassPathDescriptorFileFinder is used when discovering hk2 artifacts in Java EE applications.

        Show
        jwells added a comment - There are tests in GlassFish under appserver/tests/hk2 that appear to say that hk2 files located in WEB-INF/classes/hk2-locator/application are in fact picked up and used in applications. I'll investigate this a little more, but I think this is working as designed. I do not believe that the ClassPathDescriptorFileFinder is used when discovering hk2 artifacts in Java EE applications.
        Hide
        jwells added a comment -

        The integration with GlassFish is done in GlassFish (using the generic population facility of hk2). The class that finds the hk2 files is org.glassfish.internal.data.ApplicationDescriptorFileFinder. The file that runs https://hk2.java.net/2.2.0-b21/apidocs/org/glassfish/hk2/api/Populator.html#populate%28org.glassfish.hk2.api.DescriptorFileFinder,%20org.glassfish.hk2.api.PopulatorPostProcessor...%29 is org.glassfish.internal.data.ApplicationInfo when an application is being deployed.

        This looks correct to me and there are tests that verify that it works properly.

        Show
        jwells added a comment - The integration with GlassFish is done in GlassFish (using the generic population facility of hk2). The class that finds the hk2 files is org.glassfish.internal.data.ApplicationDescriptorFileFinder. The file that runs https://hk2.java.net/2.2.0-b21/apidocs/org/glassfish/hk2/api/Populator.html#populate%28org.glassfish.hk2.api.DescriptorFileFinder,%20org.glassfish.hk2.api.PopulatorPostProcessor...%29 is org.glassfish.internal.data.ApplicationInfo when an application is being deployed. This looks correct to me and there are tests that verify that it works properly.
        Hide
        saden added a comment -

        I am using Tomcat. Are you suppose to do anything specific if you're not using Glassfish?

        Show
        saden added a comment - I am using Tomcat. Are you suppose to do anything specific if you're not using Glassfish?
        Hide
        jwells added a comment -

        You can use HK2 in Tomcat, but you will need to do your own bootstrapping and population. The best thing to do is use the https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/DynamicConfigurationService.html, get the https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/Populator.html and write your own https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/DescriptorFileFinder.html.

        It might not be a bad idea for HK2 to provide an implementation of DescriptorFileFinder that would work OOTB in WebApps on platforms like Tomcat.

        Show
        jwells added a comment - You can use HK2 in Tomcat, but you will need to do your own bootstrapping and population. The best thing to do is use the https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/DynamicConfigurationService.html , get the https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/Populator.html and write your own https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/DescriptorFileFinder.html . It might not be a bad idea for HK2 to provide an implementation of DescriptorFileFinder that would work OOTB in WebApps on platforms like Tomcat.

          People

          • Assignee:
            jwells
            Reporter:
            saden
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: