1

A EAR application is composed with an EJB module + WAR module. Both are depending on Deltaspike (1.8.0) libraries. While deploy the application under JBoss EAP 7.0, the output shows the following exception:

Caused by: java.util.ServiceConfigurationError: org.apache.deltaspike.core.spi.config.ConfigSourceProvider: Provider org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.apache.deltaspike.core.util.ServiceUtils.loadServiceImplementations(ServiceUtils.java:66)

The problem happen with CDI View extension ony from the WAR module. The initialization is correct from the EJB module.

What's going wrong with the WAR. Is it a configuration problem ?

ruddy32
  • 21
  • 7
  • 2
    How do you have Deltaspike installed? What it looks like is you've got two versions of Deltaspike installed. – James R. Perkins Sep 27 '17 at 23:09
  • Both EJB and WAR modules embedded in the EAR application are using deltaspike modules. They are using the same version. It seems there is something bad when loading the EJB container and web application. The EJB loading works fine, but the webapp loading fail. – ruddy32 Sep 28 '17 at 05:09
  • 3
    Sorry I shouldn't have used "version". What it looks like is you have Deltaspike being loaded on two different class loaders. Is Deltaspike in the `EAR/lib` directory? Make sure you don't have a Deltaspike library in your `EAR/WAR/WEB-INF/lib` directory. – James R. Perkins Sep 28 '17 at 16:08
  • All deltaspike libraries are located in the EAR/Lib directory. Maybe there are specific settings to fix the problem. As a temporary solution I create a new WAR that include both WAR and EJB content which works fine. – ruddy32 Sep 29 '17 at 06:14
  • 3
    Nothing that I know of. If the issue is just in the WAR you might want to make sure there is not a library in your `WAR/WEB-INF/lib` by mistake. If you're using maven make sure it's marked as `provided` in your WAR project. – James R. Perkins Sep 29 '17 at 17:05

1 Answers1

3

Yes, it is a configuration problem as James R. Perkins suggested in the comments.

If you open the EAR (in any ZIP file viewer), you will notice that there are two copies of Deltaspike libraries:

application.ear
├── lib
│   ├── deltaspike-core-api-1.x.y.jar
│   └── deltaspike-core-impl-1.x.y.jar
├── web-app.war
|   └── WEB-INF
│       └── lib
│           ├── deltaspike-core-api-1.w.z.jar
│           └── deltaspike-core-impl-1.w.z.jar

This confuses the classloader and causes the error above.

To fix this, mark Deltaspike libraries as <scope>provided</scope> in the WAR POM so that they will not be bundled into WAR WEB-INF/lib:

    <dependency>
        <groupId>org.apache.deltaspike.core</groupId>
        <artifactId>deltaspike-core-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.deltaspike.core</groupId>
        <artifactId>deltaspike-core-impl</artifactId>
        <scope>provided</scope>
    </dependency>
mrts
  • 16,697
  • 8
  • 89
  • 72