Spring dependency injection with WildFly

I have a web application (war file) that depends (Maven) on another project (jar file) that uses Spring for dependency injection. So in this other project, I have some xml files to declare my beans, in my case business objects. I started using WildFly instead of Tomcat / Jetty and it seems to be called Weld in charge of DI. My web app doesn't use Spring (yet), it's just a simple Jersey RESTful API.
I want my business objects to be injectable (@Inject) in my resources (controllers).

How do I make my beans available, which means how do we mix Spring DI and WildFly DI?

Right now in my web application project I have a WEB-INF / beans.xml file with this:

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:weld="http://jboss.org/schema/weld/beans"
    xsi:schemaLocation="
    http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd
    http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd
    bean-discovery-mode="all">
</beans>

      

But when I try to expand, for this code:

@Inject SomeBO myBO;

      

I am getting this error:

WELD-001408: Invalid dependencies for type SomeBO with @Default qualifiers

Thank.

EDIT
I need to import my beans with xml files, I don't want to comment them out, for example I have a bo.xml (Spring beans) file that contains a declaration like this:

    <bean id="com.xxx.bo.SomeBO" parent="com.xxx.bo._AbstractBO">
        <property name="target">
            <bean class="com.xxx.bo.SomeBOImpl">
                <property name="DAO" ref="com.xxx.dao.SomeDAO"/>
            </bean>
        </property>
    </bean>

      

+3


source to share


1 answer


WildFly implements the Java EE Spec, which means it provides an implementation for CDI . In the case of WildFly, the reference implementation is used, which is Weld. For Java EE 6, there are several tutorials that should explain CDI well.



As for your error, maybe you just need to annotate your SomBO version with @Named

or a valid CDI annotation to make it a CDI bean driven.

0


source







All Articles