0

In Airpal used Guice for DI framework, in my project we are using glassfish 4.1 payara server RESTful web services, Jersey version 2.21. issue 1: if use Guice got some runtime exceptions

Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001409: Ambiguous dependencies for type Validator with qualifiers @Default at injection point [UnbackedAnnotatedField] @Inject private org.hibernate.validator.internal.cdi.interceptor.ValidationInterceptor.validator at org.hibernate.validator.internal.cdi.interceptor.ValidationInterceptor.validator(ValidationInterceptor.java:0) Possible dependencies: - org.apache.bval.cdi.ValidatorBean@33aeb01, - ValidatorBean [id=org.hibernate.validator.internal.cdi.ValidatorBean_default] . Please see server.log for more details.

issue2: if didn't use Guice how can bind airlift client in jersey 2.21 RESTful.

Please help me. anybody know this issue who are using Airpal+presto+glassfish4.1+jersey2.21+maven3.0

Aruna
  • 21
  • 2

1 Answers1

0

It seems that since both Guice and standard Java EE CDI use the same @Inject annotations, the CDI mechanism is triggered but fails to find dependencies, because your applcation is configured with Guice.

The simplest solution with GlassFish/Payara is to disable implicit CDI when deploying the application (there is a checkbox in Admin console when deploying, or an option to asadmin command).

You can disable CDI in the application archive in a XML descriptor too. Have a look at Payara Server docs about disabling CDI or filtering CDI scanning. Note that most options are available only in Payara Server and not in GlassFish 4.1.

The CDI is triggered either by - putting beans.xml into you application (I don't expect you put it there, because you're using Guice, but check if it wasn't generated by your IDE for some reason) - annotating one or more classes with annotations that trigger CDI - e.g. any EJB annotation (@Stateless, @Stateful,...)

OndroMih
  • 7,280
  • 1
  • 26
  • 44