cdi

EJB Interceptors and transaction lifecycle OR how to intercept a commit/failure event?

可紊 提交于 2020-01-04 07:01:00
问题 I have an EJB interceptor and I follow the BCE pattern suggested by Adam Bien, that is, all EJB calls on the boundary starts and finish a transaction which means there is no nested EJB calls (there might be nested CDI injected Bean calls though, but those should be inside the same transaction started at the ejb Boundary). So in those ejb Boundaries I have an interceptor and I want to intercept or know if after the method call of the EJB the transacction commited already? (that is, if a

Referencing CDI managed bean from Facelets error page

谁说我不能喝 提交于 2020-01-04 04:12:06
问题 I'm having a hard time trying to get a generic error-page to work in a (really simple) WAR project that uses JSF 2, Facelets and CDI. My application server is WebLogic 12c, which should support all of this out-of-the-box, but it fails to show the error page. When I deploy the exact same WAR to a Glassfish application server, it works. I'm leaning towards blaming WebLogic for being buggy in the CDI department, but could use some additional expertise to see if my approach is wrong. Here's what

Unable to resolve any beans for Type: xxx; Qualifiers: [@javax.enterprise.inject.Any()]

半城伤御伤魂 提交于 2020-01-04 02:57:11
问题 I have a LoginProvider interface: public interface LoginProvider { boolean login(String username, String password); } And 2 different implementations: public class LoginProvider1Impl implements LoginProvider { @Override public boolean login(String username, String password) { ... } } public class LoginProvider2Impl implements LoginProvider { @Override public boolean login(String username, String password) { ... } } Then a producer annotation: @Qualifier @Retention(RetentionPolicy.RUNTIME)

WELD-001408 Unsatisfied dependencies

随声附和 提交于 2020-01-03 17:06:18
问题 I have a very famous error, but I can't solve it. I'm trying to run arqullian test for my application. I've done everything according to the official documentation. The long search for solution to the problem given nothing. 16:49:42,713 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."test.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".WeldService: org.jboss.weld.exceptions

How do I @Inject a CDI @ApplicationScoped bean into a @RequestScoped JAX-RS bean?

為{幸葍}努か 提交于 2020-01-03 13:35:34
问题 I've added the @ApplicationScoped CDI annotation to a simple bean: @ApplicationScoped public class History { And tried to then @Inject this into a JAX-RS (resteasy) bean: @RequestScoped @Path("/history") public class HistoryAPI { @Inject private History history; But history remains null. I've got a beans.xml file in WEB-INF. I've tried a lot of variations on this theme, but while the app server (Wildfly) acknowledges it's starting with CDI I can't get the injection to work. Any ideas what I"m

How do I @Inject a CDI @ApplicationScoped bean into a @RequestScoped JAX-RS bean?

怎甘沉沦 提交于 2020-01-03 13:34:16
问题 I've added the @ApplicationScoped CDI annotation to a simple bean: @ApplicationScoped public class History { And tried to then @Inject this into a JAX-RS (resteasy) bean: @RequestScoped @Path("/history") public class HistoryAPI { @Inject private History history; But history remains null. I've got a beans.xml file in WEB-INF. I've tried a lot of variations on this theme, but while the app server (Wildfly) acknowledges it's starting with CDI I can't get the injection to work. Any ideas what I"m

How do I combine @Asynchronous and Weld/CDI Events and @Observes(during=TransactionPhase.AFTER_COMPLETION) in Glassfish 3.1

谁说胖子不能爱 提交于 2020-01-03 11:30:08
问题 First of all let me state, that the following code example worked just fine in GF 3.0.1. The troubles started when we switched to GF 3.1. I'm using a method @Asynchronous public void executeFlowStep( @Observes(during=TransactionPhase.AFTER_COMPLETION) ExecuteFlowStepEvent executeFlowStepEvent) { Since the switch, whenever this should receive an ExecuteFlowStepEvent I get the following error message: WELD-000401 Failure while notifying an observer of event [package].ExecuteFlowStepEvent No

CDI not working with Java EE Batch under jberet implementation

二次信任 提交于 2020-01-03 03:01:19
问题 I have a Java EE batch application implemented with jberet deployed on WildFly application server. This application also expose a REST api to trigger a job on demand. I have following class creating beans to be injected: public class Factory { @Produces public JsonValidator getJsonValidator() { return JsonSchemaFactory.byDefault().getValidator(); } Injecting the above bean in the REST api works fine: @Path("my-resource") public class MyResource{ @Inject private JsonValidator jsonValidator;

Inject a Entity into a ViewScoped Bean

只愿长相守 提交于 2020-01-03 02:28:33
问题 I am new to CDI and want to use this for a JSF2 application. The class MyUser is a simple @Entity -Bean and a object is created in a @PostConstruct method in bean: @Stateful @Named @javax.faces.bean.SessionScoped public class UserBean implements Serializable { @Named private MyUser user; //setter and getter //@PostConstruct } Accessing the user in a JSF pages works like a charm: #{user.lastName} . But now I want to access this object from other beans, e.g. in this @ViewScopedBean : @Named

CDI - Injecting objects dynamically at runtime

穿精又带淫゛_ 提交于 2020-01-02 15:52:56
问题 How do I inject objects at runtime? For example, if I want to inject DerviedOne, DerivedTwo objects at runtime into the Test class in the following example, how do I do that? I found a few examples in Spring, but I'm not using Spring. This is a Dynamic Web Project with CDI using Java EE 6. public abstract class Base { public Base(String initiator) { this.initiator = initiator; } public abstract void process(); public void baseProcess() { System.out.println("base process"); process(); } public