2 Replies Latest reply on Apr 15, 2017 3:59 PM by mulderbaba

    ServiceLoader cannot load extension

    mulderbaba

      We are in the process of upgrading version of HK2 for Payara application server to 2.5.0 and bumped into a problem where ServiceLoader cannot load extension class for org.hibernate.validator.internal.cdi.ValidationExtension.

      hk2 v2.5.0 ditches its own-bundled bean-validator and bean-validator-cdi and uses hibernate-validator and hibernate-validator-cdi. bean-validator and bean-validator-cdi were OSGI'ed bundles but hibernate-validator-cdi was lacking this info in its manifest file. Even I create that info w/ bnd tool, deploying an application to the server that contains @Inject Validator validator results with:

       

      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Validator with qualifiers @Default

        at injection point [BackedAnnotatedField] @Inject com.org.net.micro.demo.ScheduleView.validator

        at com.org.net.micro.demo.ScheduleView.validator(ScheduleView.java:0)

       

      And the real problem behind that is Service loader cannot load the regarding CDI extension class:

      [2017-03-09T01:28:34.588+0300] [Payara 4.1] [WARNING] [] [ServiceLoader] [tid: _ThreadID=108 _ThreadName=admin-thread-pool::admin-listener(2)] [timeMillis: 1489012114588] [levelValue: 900] [[

        Could not load service class org.hibernate.validator.internal.cdi.ValidationExtension]]

       

      Weld version is 2.4.2.Final, I couldn't find a decent reason of why ServiceLoader cannot delegate the loading mechanism to OSGI loader for this extension classes.

        • 1. Re: ServiceLoader cannot load extension
          mkouba

          Hi Mert,

          it's the responsibility of an integrator to load the extensions and pass the set to the Weld Bootstrap API, either as a param of org.jboss.weld.bootstrap.api.CDI11Bootstrap.startExtensions() or as a part of the deployment - org.jboss.weld.bootstrap.spi.Deployment.getExtensions(). So it's probably not a Weld issue. You should check the Payara integration code. Also I'm not sure how HK2 is related (AFAIK it's used as an internal DI solution in Payara/GlassFish).

          • 2. Re: ServiceLoader cannot load extension
            mulderbaba

            Hi Martin,

             

            This was related to HK2 since with version 2.5.0 they gave up bundling hibernate validator as an OSGI'fied artifact and directly depend on the hibernate-validator artifacts instead. And the problem was with the hibernate-validator-cdi artifact since it was not OSGI'fied that is it was not containing import-export package definitions in its MANIFEST files. I filed a bug for that and hibernate guys fixed that.

             

            Thanks for the response.