Attempting to instantiate bean with CDI from a running web application
I have a jar that contains @Stateless class defined as
@Stateless
public class TestBean() {
@Inject
AnotherBean bean2;
public String getThis() {
return bean2.getAString();
}
}
A web application (with a dependency on this jar) running wildfly 10.1.0 wants to instantiate this bean and use its methods. The web application invocation method can be a rest endpoint (called by some other web application) or just a regular java method.
What's the best way to create a TestBean? I've tried several solutions, none of which work.
For example this
and this one
Does CDI work for a regular Java application?
I am new to CDI and how does it work, I am wondering if this is well explained somewhere?
+3
source to share
1 answer