Errai
  1. Errai
  2. ERRAI-63

Classpath scanning for services fails under many deployment scenarios

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Blocker Blocker
    • Resolution: Done
    • Affects Version/s: ErraiBus 1.0 Beta, 1.1.0.M1
    • Fix Version/s: 1.1-Final
    • Component/s: ErraiBus
    • Labels:
      None
    • Environment:
      Scenario 1 - All environments where EAR archives are used
      Scenario 2 - All Windows environments using archive formats of any type.
    • Similar Issues:
      Show 10 results 

      Description

      Classpath scanning fails to find class files and thus fails to find services and extensions under a few major scenarios.

      Scenario 1 - class files within a WAR within an EAR. I believe this likely extends to any nesting of archive formats but specifically EAR formats are neglected in the codebase (ConfigUtil class).

      Scenario 2 - I see some problems under windows filesystems when handling archive formats of any type. The codebase has "/" hardcoded as the file separator which is bad practice and leads to this problem. The File.separator should be used instead.

      I believe most of the problems can be remedied in the ConfigUtil class but I have not been successful testing any changes yet.

      As a note, classpath scanning is done in many other libraries. It seems silly to keep recreating classpath scanning libraries. A few are listed below.
      http://code.google.com/p/reflections/ (based off of Bill Burke's Scannotations)
      http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.html
      http://commons.apache.org/discovery/

      1. errai-bus_ERRAI-63.patch
        5 kB
        Adam Karl
      2. errai-bus_ERRAI-63b.patch
        11 kB
        Adam Karl

        Activity

        Hide
        Adam Karl
        added a comment -

        errai-bus project patch.

        Show
        Adam Karl
        added a comment - errai-bus project patch.
        Hide
        Adam Karl
        added a comment -

        I attached a patch which solves some of the problems dealing with archives and windows file system.

        Note that after doing this classpath scanning takes significantly longer since files within archives are actually scanned. Also note that scanning Guice jars produces massive amounts of logging of warnings with a default JBoss.org 5.1 installation. To avoid this you have to crank down the logging level for the JBoss classloader. This can be avoided by scanning other ways. I also utilize Spring and Jersey and do not see the massive logging so they have solved it somehow.

        Show
        Adam Karl
        added a comment - I attached a patch which solves some of the problems dealing with archives and windows file system. Note that after doing this classpath scanning takes significantly longer since files within archives are actually scanned. Also note that scanning Guice jars produces massive amounts of logging of warnings with a default JBoss.org 5.1 installation. To avoid this you have to crank down the logging level for the JBoss classloader. This can be avoided by scanning other ways. I also utilize Spring and Jersey and do not see the massive logging so they have solved it somehow.
        Hide
        Adam Karl
        added a comment -

        Simple refactoring allows for disabling the auto scan for Errai services. This would be (and is in my case) combined with manual injection of services. I am using Spring to find them for me since Springs classpath scanning is much more mature.

        This same approach would need to be applied for extensions and other auto discovered components but I have only applied it for services as that is my immediate need.

        Show
        Adam Karl
        added a comment - Simple refactoring allows for disabling the auto scan for Errai services. This would be (and is in my case) combined with manual injection of services. I am using Spring to find them for me since Springs classpath scanning is much more mature. This same approach would need to be applied for extensions and other auto discovered components but I have only applied it for services as that is my immediate need.
        Hide
        Adam Karl
        added a comment -

        The above comment was in reference to patch B above.

        Note that the original patch attached here does fix many issues with files ystem traversal and allows discovery of annotated classes inside complex EAR/WAR deployments however the initial design of how that works has side effects such as the loading of every class in your EAR/WAR. This wreaks havoc on perm gen space settings as every class from every JAR in your EAR is loaded. At this time I've elected to skip Errai based classpath scanning altogether which is the reasoning behind patch B.

        Show
        Adam Karl
        added a comment - The above comment was in reference to patch B above. Note that the original patch attached here does fix many issues with files ystem traversal and allows discovery of annotated classes inside complex EAR/WAR deployments however the initial design of how that works has side effects such as the loading of every class in your EAR/WAR. This wreaks havoc on perm gen space settings as every class from every JAR in your EAR is loaded. At this time I've elected to skip Errai based classpath scanning altogether which is the reasoning behind patch B.
        Hide
        Heiko Braun
        added a comment - - edited

        As a side note: We have a config option for disabling the scanning at all:

        errai.auto_discover_services=false in ErraiService.properties will disable the automatic scanning.

        Show
        Heiko Braun
        added a comment - - edited As a side note: We have a config option for disabling the scanning at all: errai.auto_discover_services=false in ErraiService.properties will disable the automatic scanning.
        Hide
        Heiko Braun
        added a comment -

        we did replace the custom implementation with reflections and added some sugar to it. works quiet well

        Show
        Heiko Braun
        added a comment - we did replace the custom implementation with reflections and added some sugar to it. works quiet well

          People

          • Assignee:
            Heiko Braun
            Reporter:
            Adam Karl
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: