I'm working on an API (backend project) which uses some common/shared libraries containing the shared source codes. So, I'm working on a feature which will be added into all of ours backends, that's all for my context.
This API is based on Jersey 2.x, Jackson, CDI 1.2, JPA, Hibernate etc , configured to be deployed on Weblogic 12c and the project had been created with Maven.
So, I'm working on a simple case: I created an "Interface" into appropriate common library (ref-common) (to be sure ours API implements the same interface) and into the API, I created the implementation (war).
THE interface (located into the library):
package be.company.ref.common.properties;
public interface ApplicationProperties {
...
}
The implementation (located into the war):
package be.company.ref.appname.config;
import be.company.ref.common.properties.ApplicationProperties;
i...
public class ApplicationPropertiesImpl implements ApplicationProperties {
...
}
In a second time, I created a kind of healthCheck based on dropwizard which will be used by all of ours APIs (located into the library):
package be.company.ref.common.healthcheck;
import be.company.ref.common.properties.ApplicationProperties;
import com.codahale.metrics.health.HealthCheck;
i...
/**
* Performs a health check of an API.
*/
@ApplicationScoped
public class NomenclatureApiHealthCheck extends HealthCheck {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(NomenclatureApiHealthCheck.class);
private WebTarget esbClient;
private String serviceUrl;
private static final String url = "/healthcheck";
NomenclatureApiHealthCheck() {
}
@Inject
NomenclatureApiHealthCheck(WebTarget esbClient, ApplicationProperties properties) {
this.esbClient = esbClient;
this.serviceUrl = properties.getServiceUrlNom();
}
@Override
protected Result check() throws Exception {
...
}
}
The configuration (located into the API):
package be.company.ref.appname.config;
import be.company.ref.common.healthcheck.DatabaseHealthCheck;
import be.company.ref.common.healthcheck.NomenclatureApiHealthCheck;
import com.codahale.metrics.health.HealthCheckRegistry;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
@Startup
@Singleton
public class HealthCheckConfiguration {
@Inject
HealthCheckRegistry registry;
@Inject
DatabaseHealthCheck databaseHealthCheck;
@Inject
NomenclatureApiHealthCheck nomenclatureApiHealthCheck;
@PostConstruct
public void configure() {
registry.register(ComponentNames.DATABASE_APPNAME.name(), databaseHealthCheck);
registry.register(ComponentNames.NOMENCLATURE_API.name(), nomenclatureApiHealthCheck);
}
}
My issue occurs when I deploy the API:
25-sept.-2020 16 h 13 min 39 s,SSS CEST> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application "ref-dimeco-front_war".
weblogic.management.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type ApplicationProperties with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] @Inject be.company.ref.common.healthcheck.NomenclatureApiHealthCheck(WebTarget, ApplicationProperties)
at be.company.ref.common.healthcheck.NomenclatureApiHealthCheck.<init>(NomenclatureApiHealthCheck.java:28)
at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:95)
at com.oracle.injection.integration.CDIAppDeploymentExtension.activate(CDIAppDeploymentExtension.java:43)
at weblogic.application.internal.flow.AppDeploymentExtensionFlow.activate(AppDeploymentExtensionFlow.java:39)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:752)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ApplicationProperties with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] @Inject be.company.ref.common.healthcheck.NomenclatureApiHealthCheck(WebTarget, ApplicationProperties)
at be.company.ref.common.healthcheck.NomenclatureApiHealthCheck.<init>(NomenclatureApiHealthCheck.java:28)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
Truncated. see log file for complete stacktrace
Extract of the pom.xml of the API (ref-common contains the interface and the healthcheck):
<dependency>
<groupId>be.company.ref.common</groupId>
<artifactId>ref-common</artifactId>
<version>${ref-common.version}</version>
</dependency>
Basically, The API is packaged with the shared library and deployed on weblo.
Take in account, I posted the "ApplicationPropertiesImpl" without @nnotation because I tried @ApplicationScope and @Singleton but because neither work, I tried without any @annotation.
So, could you explain why this error occurs when I deploy my API because I don't understand my error.
Thanks in advance.