Uploaded image for project: 'JBoss BPMS Platform'
  1. JBoss BPMS Platform
  2. RHBPMS-3934

Properties file can't be load in LDAPUserGroupCallbackImpl

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 6.0.2
    • 6.0.1
    • Business Central
    • None
    • ER1
    • +
    • Hide
      The two options available for loading property files in the LDAPUserGroupCallbackIml were not functional and buggy.
      The files were not loaded when their location was specified by a system property and neither were they loaded when they were dropped under business-central.war/WEB-INF/classes folder. The only workaround was to add the property files directly in the org.jbpm module.
      This has now been fixed by allowing any valid URL to specify location of the UserGroupCallback property file. In addition to URL protocols (file, http, etc) you can now use classpath. If no protocol is available (no valid URL) the classpath based location is assumed. From classpath the system will try to load first from local class loader (class that requires the reading) and if not found fall back to thread context class loader.
      Show
      The two options available for loading property files in the LDAPUserGroupCallbackIml were not functional and buggy. The files were not loaded when their location was specified by a system property and neither were they loaded when they were dropped under business-central.war/WEB-INF/classes folder. The only workaround was to add the property files directly in the org.jbpm module. This has now been fixed by allowing any valid URL to specify location of the UserGroupCallback property file. In addition to URL protocols (file, http, etc) you can now use classpath. If no protocol is available (no valid URL) the classpath based location is assumed. From classpath the system will try to load first from local class loader (class that requires the reading) and if not found fall back to thread context class loader.

      Description of problem:

      I would like to change the default implementation of UserGroupCallback which is used by business-central (kie-wb).

      I have changed business-central.war/WEB-INF/beans.xml with following line :

      <class>org.jbpm.kie.services.cdi.producer.LDAPUserGroupInfoProducer</class>

      Looking at https://github.com/droolsjbpm/jbpm/blob/6.0.0.GA.x/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserGroupCallbackImpl.java apparently I need to provide jbpm.usergroup.callback.properties.

      It seems that I have two options - either to specify location with system property jbpm.usergroup.callback.properties OR drop this property files on the root of classpath.

      Unfortunately both options are not functional at the moment.

      1) Define location of property file with system property

      String propertiesLocation = System.getProperty("jbpm.usergroup.callback.properties");
      InputStream in = this.getClass().getResourceAsStream(propertiesLocation);

      This is not a way how to load external files, this will try to load file relatively from the root of classpath.

      The correct way how to load external files could look like this :

      private Properties config;
      InputStream is = new FileInputStream(System.getProperty("jbpm.usergroup.callback.properties"));
      config.load(is);

      I haven't submitted a pull request as the story goes on.

      2) Use default location which is
      protected static final String DEFAULT_PROPERTIES_NAME = "/jbpm.usergroup.callback.properties";

      However, this does not work either, because apparently this class is picked up by different classloader, coming from jboss module.

      So, the workaround is to add this property files directly in the org.jbpm module, like this:

      $ pwd
      bpm6/jboss-eap-6.1/modules/system/layers/bpms/org/jbpm/main
      $ $ ls -1 | grep properties
      properties.jar
      $ unzip -l properties.jar
      Archive: properties.jar
      Length Date Time Name
      --------- ---------- ----- ----
      50 04-03-2014 14:53 jbpm.usergroup.callback.properties
      --------- -------
      50 1 file
      $ cat module.xml | grep properties
      <resource-root path="properties.jar"/>

      This workaround is not really nice, and it will obviously not work in other container.

      Both attempts - 1 && 2 fails with
      if (this.config == null)

      { throw new IllegalArgumentException("No configuration found for LDAPUserGroupCallbackImpl, aborting..."); }

      I haven't pasted the complete exception because there is not really anything to add. If I apply the workaround the properties file is correctly loaded.

      Version-Release number of selected component (if applicable):

      How reproducible:

      always

      Steps to Reproduce:
      Please see verbose description.

      Actual results:

      Properties file is not loaded when its location is specified by system property.
      Properties file is not loaded when it is dropped under business-central.war/WEB-INF/classes
      Expected results:
      Properties file is loaded when its location is specified by system property.
      Properties file is loaded when it is dropped under business-central.war/WEB-INF/classes

      Additional info:

              swiderski.maciej Maciej Swiderski (Inactive)
              rhn-support-agiertli Anton Giertli
              Jiri Svitak Jiri Svitak (Inactive)
              Jiri Svitak Jiri Svitak (Inactive)
              Kris Verlaenen, Marek Baluch, Marek Winkler (Inactive), ravindra.tubati, Vikram Goyal (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: