0

I am using Weblogic 12b as App server. My application uses Jersey 2.5.1 with Guice3 in my project. I have a class called Application derived from org.glassfish.jersey.server.ResourceConfig. On server startup I am getting error as below:

Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ServiceLocator with qualifiers @Default
  at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public Application(ServiceLocator)
  at Application.<init>(Application.java:22)

        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.validateProducer(Validator.java:417)
        at org.jboss.weld.injection.producer.InjectionTargetService.validateProducer(InjectionTargetService.java:36)
        at org.jboss.weld.manager.InjectionTargetFactoryImpl.validate(InjectionTargetFactoryImpl.java:135)

It seems it is taking WELD in place of google Guice for DI.

Same issue I am getting in business Tier where EJB classes are composed of Java Classes and they are injected using @Inject.

I have even tried to change he import @Inject to google inject but the exception changed but not resolved.

I tried to use beans.xml in web-inf

@ApplicationPath("/")
public class Application extends ResourceConfig {

    @Inject
    public Application(final ServiceLocator serviceLocator) {
    }
}
Vega
  • 27,856
  • 27
  • 95
  • 103

1 Answers1

2

You need to effectively disable CDI.

You can do this by adding a WEB-INF/beans.xml file to your application that contains:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="none">
</beans>

Note the bean-discovery-mode="none".

If your project contains additional jars with classes that might look CDI beans then you will also need to add a similar META-INF/beans.xml file to those as well.

However, I suspect that this may lead to other unrelated issues. Normally application servers like to control the lifecycle of your classes and this includes those related to JAX-RS.

Steve C
  • 18,876
  • 5
  • 34
  • 37