1

I'm having some trouble using the CDI producer shared between different modules. The idea is to declare the producer in module Common.jar :

@Qualifier
@Retention(RUNTIME)
@Target({ TYPE, METHOD, FIELD, PARAMETER })
public @interface Property {
    @Nonbinding
    String value() default "";

    @Nonbinding
    boolean required() default true;
}

And :

@ApplicationScoped
public class PropertyProducer implements Serializable {


@Property
@Produces
public String produceString(final InjectionPoint ip) {
    return "needed string";
}

And to use it in a different module in model.jar :

@Inject
@Property("model.needed.string")
private String neededString;

This result with the following exception at the run time :

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type String with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private neededString
WELD-001475: The following beans match by type, but none have matching qualifiers:
  - Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @Produces @BatchProperty public org.jberet.creation.BatchBeanProducer.getString(InjectionPoint)]

The structure is as follow : project structure

Any ideas ?

Thank you.

user1594978
  • 23
  • 1
  • 4
  • Do you have any beans.xml in common.jar? Your producer class is annotated? Please share some more code to help diagnostic. – Rouliboy Jan 11 '18 at 19:25
  • Hi Rouliboy, I reedited my original question. – user1594978 Jan 11 '18 at 19:45
  • You deploy your application in a war file? – Rouliboy Jan 11 '18 at 20:24
  • I have a war and 3 jars, model.jar and common.jar (concerned in my question above) are deployed separately. – user1594978 Jan 11 '18 at 20:36
  • This may be the problem. In which jar do your inject your Property? Why your jar are not included in the war? – Rouliboy Jan 11 '18 at 20:45
  • The producer is declared in common.jar and I try to inject in model.jar. I wanted this to be used as a factorized way. Is it mandatory to always put all the deployable archives in the same final archive ? Wildfly context doesn't handle the modularity ? – user1594978 Jan 11 '18 at 21:03
  • Take a look at this link to see how you can deploy use, on wildfly, jar which are out of a war : https://stackoverflow.com/questions/39122046/adding-jars-as-deployment-in-wildfly-10 – Rouliboy Jan 11 '18 at 21:15
  • I thought it might exist a simpler hack ^^, anyway, i put all my archives in a final EAR and deployed, that fixed my dependency. – user1594978 Jan 11 '18 at 22:19

0 Answers0