mardi 21 juillet 2015

Java EE EAR dependency to deployed JAR artifact

I am currently stuck with the following issue. I have an EAR deployed, containing a WAR and a few libraries. Also, a JAR artifact is deployed.

The WAR contains a Singleton class periodically scanning for changes of available deployed JAR artifacts using the ServiceLoader. The JARs contain implementations of a service contained in a JAR in the EAR/lib.

The ServiceLoader is returning an empty result, so no services are loaded.

Summary: Project structure:

wildfly/standalone/deployments
    ---> my.ear
        ---> lib/libs.jar
        ---> my.war
    ---> first.jar
    ---> second.jar
    ---> nth.jar

With the JARS containing a service implementation of an interface defined in one of libs.jar.

The thought behind this project structure:

The services itself are divided into a "core" (the ear lib) and independent modules (the JAR artifacts) and could be used in a Java SE environment and are wrapped into an Java EE project, providing this standalone project as a microservice that will be used by other applications. The microservice should work, whether there are 0 or N deployed JAR artifacts, and new or obsolete artifacts can be deployed/undeployed at runtime of the microservice.

Why is my service loader from the WAR not recognizing the services in the JARs? Are there better ways of achieving what I want?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire