3 Replies Latest reply on Aug 4, 2016 6:03 AM by Kiran Mohan

    WildFly + java Preferences cannot find custom preferences class in classpath

    Kiran Mohan Newbie

      I am deploying an EAR with the below structure to Wildfly 9.0.2

       

          my.ear

            |-my.sar    (it is a SAR archive)

            |-lib

               |-myPreferencesImpl.jar

       

      I am able to load the classes in lib/myPreferencesImpl.jar from my.sar (like class.forname(com.my.PreferencesFactory) directly. However, java.util.prefs.Preferences.factory is not able to load com.my.PreferencesFactory. I am passing `Djava.util.prefs.PreferencesFactory=com.my.PreferencesFactory` as command line parameter during WildFly startup.

       

      Below is the exception thrown.

       

           Caused by: java.lang.ClassNotFoundException: com.my.PreferencesFactory from [Module "org.jboss.as.jmx:main" from local module loader @76a3e297 (finder: local module finder @4d3167f4 (roots: /CSA_wildfly/wildfly/modules,/CSA_wildfly/wildfly/modules/system/layers/base))]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

          at java.lang.Class.forName0(Native Method)

          at java.lang.Class.forName(Class.java:348)

          at java.util.prefs.Preferences.factory(Preferences.java:254)

       

       

      Please help me fix this.

       

      Update: fixed by migrating the startup service using JMX Service to a @Singleton + @Startup EJB. No other changes were required.
      The complete application migration is still going on. Hoping that it is really fixed.