0 Replies Latest reply on Sep 18, 2016 5:40 AM by Kiran Mohan

    WildFly ignores META-INF/services/java.util.prefs.PreferencesFactory

    Kiran Mohan Newbie

      I am deploying an ear with the below structure to WildFly 9.0.2.

       

          app.ear

             |- app-ejb.jar

             |- preferences-lib.jar

             |- META-INF/jboss-deployment-structure.xml

       

      The preferences-lib.jar contains a custom PreferencesFactory implementing java.util.prefs.PreferencesFactory. Also defined is META-INF/services/java.util.prefs.PreferencesFactory.

       

          preferences-lib.jar

                  |- com/**

                  |- META-INF/services/java.util.prefs.PreferencesFactory

       

       

      By default WildFly ignores META-INF folder but allows it to be imported using the jboss-deployment-structure.xml. I have tried various combinations but WildFly keeps ignoring the META-INF folder and consequently I can't use the custom preferences factory in my application.

       

      I have also tried adding a dummy jar with just META-INF/services/java.util.prefs.PreferencesFactory as a wildfly modules. That doesn't work either.

       

      Please help me fix this META-INF/services import issue.

       

      Code: wildfly-playground/app-only-preference-factory at master · KiranMohan/wildfly-playground · GitHub

       

      (This is related to https://developer.jboss.org/thread/271689. But trying to avoid setting system wide property for java.util.prefs.PreferencesFactory.)

       

      Update:

      Turns out the problem is with the Java Preferences class which uses system class loader to load the service provider.

      I fixed this by writing my own implementation of the Preferences.systemRoot() function where it first checks for a service provider without using the system class loader.

      The code is available in github link mentioned above.