1

I created another post but apparently I wasn't clear: Wildfly 14 CDI: WELD-001408 on 3rd part JAR after migration from JBoss 7

I am migrating a system from java7 to java8 and from jboss7 to wildfly14. One of the systems has several EJBs and classes that uses @Inject to initialize the objects. It's an old system and it works perfectly.

After doing the deploy in Wildfly 14 I got several errors like this:

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type InterfaceZaakIdentificatieGenerator with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private nl.interaccess.zakenmagazijn.converter.impl.ZaakCreatieToEntityConverter.zaakIdentificatieGenerator
  at nl.interaccess.zakenmagazijn.converter.impl.ZaakCreatieToEntityConverter.zaakIdentificatieGenerator(ZaakCreatieToEntityConverter.java:0)

After researching, I saw that this is a very common error and it happens because in Wildfly they use a newer version of CDI with Weld and adding bean-discovery-mode="all" solves the problem, but in my case even after adding that to the file it still gives me that error.

This is my beans.xml (located at /project-war/src/main/webapp/WEB-INF/beans.xml):

<?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"
       version="1.1" bean-discovery-mode="all">
    <interceptors>
        <class>nl.interaccess.zakenmagazijn.manager.WsdlFaultAdvice</class>
        <class>nl.interaccess.zakenmagazijn.profiler.ZakenmagazijnProfilerImpl</class>
        <class>nl.interaccess.zakenmagazijn.profiler.ZTCProfilerImpl</class>
    </interceptors>
</beans>

Important: As I said, the system is working perfectly on JBoss7, so it is not a wrong annotation or any other kind of bug in the code, it has to be configuration related.

Adding some more info for a more concrete example:

The interface:

package nl.interaccess.zakenmagazijn.ztc;

public interface InterfaceZtcKermZaken {    
    GetZoekKenmschermZTCPlusAntwoord getZaken(GetZoekKenmschermZTCPlusZoeken request);
}

The implementation:

package nl.interaccess.zakenmagazijn.ztc;

@LocalBean
@Stateless(name = "ZtcKermZakenImpl")
@TransactionTimeout(value = 5, unit = TimeUnit.MINUTES)
@Perf4jZTCProfiler
public class ZtcKermZakenImpl extends ZTCQueryUtils implements InterfaceZtcKermZaken {

    @Override
    public GetZoekKenmschermZTCPlusAntwoord getZaken(GetZoekKenmschermZTCPlusZoeken request) {
        //Implementation
    }

}

The place where I get the error when trying to inject:

package nl.interaccess.zakenmagazijn.manager;

@LocalBean
@Stateless(name = "ZakenmagazijnManager")
@WsdlFaultAdviceBinding
@Perf4jZakenmagazijnProfiler
public class ZakenmagazijnManagerImpl implements ZakenPortType {

    @Inject
    private InterfaceZtcKermZaken ztcKerm;

}
André Silva
  • 103
  • 8
  • 1
    Possible duplicate of [Wildfly 14 CDI: WELD-001408 on 3rd part JAR after migration from JBoss 7](https://stackoverflow.com/questions/55949635/wildfly-14-cdi-weld-001408-on-3rd-part-jar-after-migration-from-jboss-7) – Kukeltje May 03 '19 at 14:05
  • What is different here from your other question https://stackoverflow.com/questions/55949635/wildfly-14-cdi-weld-001408-on-3rd-part-jar-after-migration-from-jboss-7? Just edit that question... – Kukeltje May 03 '19 at 14:06
  • The answer provided at https://stackoverflow.com/questions/55949635/wildfly-14-cdi-weld-001408-on-3rd-part-jar-after-migration-from-jboss-7 is proper. The beans.xml defines the behavior only for the archive its part of. Adding and modifying the beans.xml in your main app does not change anything, it has to be done in the third party jar, where the beans are. Take a look at the answer provided at your other question, it already provides an workaround – Thomas Herzog May 05 '19 at 08:22
  • @ThomasHerzog: then please mark/flag/close this question as a duplicate. – Kukeltje May 05 '19 at 15:22
  • @ThomasHerzog : in fact, that answer does not apply to this one. OK, now I understand that the 3rd part jar need to be fixed somehow, but at this exact moment, the errors I'm getting is from classes inside my own project. I don't know why it was showing errors on the jar and now it only shows about my own classes. So the problem is: even after adding the bean-discovery-mode I still get that Exception when trying to inject classes inside my own project, so I guess for those ones I should be able to fix somehow, but only by adding bean-discovery-mode is not doing the trick. – André Silva May 06 '19 at 07:27
  • Could you add the interfaces with implemenations, annotations and with packages? Then somehow the CDI Comtainer does not add the class or the injection point needs maybe to be qualified. Where you put your beans.xml, maybe its not recognized? – Thomas Herzog May 06 '19 at 08:33
  • @ThomasHerzog : I added some info at the question, take a look. I though the same about the beans.xml, maybe Weld is not finding it, so just for test I copied from /src/main/webapp/WEB-INF and pasted into /src/main/resources/META-INF and I got this message during boot: `WFLYWELD0018: Found both WEB-INF/beans.xml and WEB-INF/classes/META-INF/beans.xml. It is not portable to use both locations at the same time. Weld is going to use the former location for this deployment.` So that shows that weld found both of them... any guesses ? – André Silva May 06 '19 at 14:14
  • Take a look here maybe this helps https://stackoverflow.com/questions/8663476/ejb-not-visible-to-ejb-manager-cannot-use-cdi-or-jndi-to-reference-it. It is mentioned that the annotation LocalBean requires an with Local annotation annotated interface. Give it a try. Also try to inject it via Ejb annotation. – Thomas Herzog May 06 '19 at 14:27

0 Answers0