cdi

How to propagate CDI session beans from HTTP session to WebSocket session?

自闭症网瘾萝莉.ら 提交于 2020-01-05 13:38:14
问题 I googled a lot for this problem before posting this question and Accessing HttpSession from HttpServletRequest in a Web Socket @ServerEndpoint is one of the best Questions/Answers I was able to found, but it appears to not solve my problem. I was able to access HttpSession from websocket in this way, but I can't access the same CDI session bean instances as from normal HTTP requests. I tried to store in session the HttpSessionContextImpl Weld instance too and tried to use it on WebSocket

How to propagate CDI session beans from HTTP session to WebSocket session?

二次信任 提交于 2020-01-05 13:37:30
问题 I googled a lot for this problem before posting this question and Accessing HttpSession from HttpServletRequest in a Web Socket @ServerEndpoint is one of the best Questions/Answers I was able to found, but it appears to not solve my problem. I was able to access HttpSession from websocket in this way, but I can't access the same CDI session bean instances as from normal HTTP requests. I tried to store in session the HttpSessionContextImpl Weld instance too and tried to use it on WebSocket

Running JUnit Tests on embedded glassfish 4 causing WARNING: AS-CDI-005

孤街醉人 提交于 2020-01-05 07:51:43
问题 I want to run JUnit Tests on an Embedded Glassfish 4 using CDI. It end up with an endless loop of the following output: WARNING: AS-CDI-005 Okt 22, 2013 4:49:23 PM org.glassfish.weld.BeanDeploymentArchiveImpl handleEntry Can anybody help Chears 回答1: What worked for me is putting your app name in the properties when creating the EJB container Map<Object, Object> properties = new HashMap<Object, Object>(); properties.put(EJBContainer.APP_NAME, "your_app_name"); EJBContainer ejbContainer =

@Asynchronous CDI Events and an @Observes method in @Named bean

淺唱寂寞╮ 提交于 2020-01-05 04:03:38
问题 I have CDI Events in place to notify my JSF application of progress from EJB processes. The code works fine when everything is synchronous. @Stateless public class MySessionBean implements Serializable { @Inject @ProcessEvent Event<ProcessEvent> processEvent; // Also tried to use BeanManager @Asynchronous // This annotation breaks my code public void runLongProcess() { processEvent.fire(new ProcessEvent()); } } . @Named @ViewScoped public class ManagedBean implements Serializable { @EJB

Get the real object from CDI Proxy

六眼飞鱼酱① 提交于 2020-01-05 03:31:11
问题 I looked for a clean CDI solution and not a WELD dependent one but so far nothing... I need to test if every element of a list of objects that I get with @Inject @Any MyInterface beans is a proxy, and when true I need to get the real object to do introspection and get all the properties of the object. My WELD implementation: MyInterface interf = obj; if (isProxy(interf )) { interf = (Config) ((TargetInstanceProxy)interf ).getTargetInstance(); } where isProxy is so defined (CDI solution?):

How to resolve 'Api type [java.util.Set] is not found with the qualifiers' Error when starting TomEE 1.6.0 plus?

自闭症网瘾萝莉.ら 提交于 2020-01-05 03:07:50
问题 Following on from this question TomEE on eclipse, How to call a remote EJB from a JSF Managed bean? I get the following error when I try to start the TomEE 1.6.0 plus server. What should i do? I have searched on the internet and found that this is because of Google Guava 15.0 While I understand what they are talking about I don't know how I can apply the solution to TomEE. The link explains that this error should go away by using open web 1.2.1. I can see that TomEE already uses open web 1.2

How to resolve 'Api type [java.util.Set] is not found with the qualifiers' Error when starting TomEE 1.6.0 plus?

守給你的承諾、 提交于 2020-01-05 03:07:17
问题 Following on from this question TomEE on eclipse, How to call a remote EJB from a JSF Managed bean? I get the following error when I try to start the TomEE 1.6.0 plus server. What should i do? I have searched on the internet and found that this is because of Google Guava 15.0 While I understand what they are talking about I don't know how I can apply the solution to TomEE. The link explains that this error should go away by using open web 1.2.1. I can see that TomEE already uses open web 1.2

Specifying different subclass implementations in CDI

丶灬走出姿态 提交于 2020-01-04 15:32:15
问题 I have two classes, A and B, which need to use a service. There are two services, S1 and S2. S2 extends S1. I wish to inject S1 into class A and S2 into class B. How can I accomplish this in CDI? public class S1 {} public class S2 extends S1 {} public class A { @Inject S1 service; //Ambigious? Could be S1 or S2? } public class B { @Inject S2 service; } 回答1: The @Typed annotation enables restricting bean types so that you can write: public class S1 {} @Typed(S2.class) public class S2 extends

JPA EntityManager not initialized in struts2 and JBOSS 7.1

自古美人都是妖i 提交于 2020-01-04 11:10:35
问题 I am starting struts2 based application with Jboss provided JPA libraries. I have configured data-source in standalone.xml I can see from the jboss administration console that the datasource is created. and the presistence.xml files are read and processed. But if I check the EntityManager instance in Action Class. It always says null. Here is my persistence.xml and Action class snippet <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns

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

好久不见. 提交于 2020-01-04 07:01:06
问题 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