cdi

CDI multithreading

拈花ヽ惹草 提交于 2019-12-11 09:55:10
问题 We want to optimize our application. There is some streight linear work going on, that can be executed in multiple threads with smaller working sets. Our typical service is accessed using the @Inject annotation from within our CDI-managed beans. Also such a service could have it's own dependencies injected, i.e.: public class MyService { @Inject private OtherService otherService; @Inject private DataService1 dataService1; ... public void doSomething() { ... } } Because I can not use @Inject

Using a CDI producer causes ambiguous dependencies exception

ぐ巨炮叔叔 提交于 2019-12-11 09:09:04
问题 I have a requirement to Inject the same instance of an ApplicationScoped bean into several places of my application and have created the following factory class which uses the @PostConstruct annotation to initialize the bean and the @Produces annotation to return the same instance of the bean. @ApplicationScoped public class CommandBusFactory implements Serializable { private static final long serialVersionUID = 1L; private CommandBus commandBus; @PostConstruct public void init() { commandBus

Problems with CDI in setup for functional testing with TomEE (or OpenEJB), Jetty and Selenium

≡放荡痞女 提交于 2019-12-11 08:45:24
问题 I'm trying to setup programatically an environment with Jetty, OpenEJB and WebApps to development and run Selenium tests. Something very similar described in this article: http://tomee.apache.org/functional-testing-with-openejb,-jetty-and-selenium.html. This setup is very good, because I can start selenium test by the IDE or Maven, and use the same code to start a Server for development. I saw this setup working using an old version of Jetty (6.2) and with an unknown EJB container (called

java.lang.IllegalStateException: Unable to load current conversations from the associated request,something went badly wrong when associate was called

纵饮孤独 提交于 2019-12-11 08:15:07
问题 I have the following dialog with a dataTable. The remove button works fine with few lines on the dataTable. <p:dialog id="dlgEditPrices" header="#{msg.contractPriceEditPrices}" widgetVar="EditPricesDialog" modal="true" resizable="false" closable="false"> <h:form id="frmEditPrices"> <h:panelGroup id="displayEditPrices" rendered="#{contractPriceBean.selected != null}"> <p:dataTable id="dataEditPrices" var="item" value="#{contractPriceBean.contractPriceOffers}" editable="true" paginator="false"

CDI Bean not found from JSF page

大城市里の小女人 提交于 2019-12-11 07:54:43
问题 I have a simple xhtml page with an el expression. But this expression won't get resolved and no error is thrown. test.xhtml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xml:lang="en" lang="en"> <h:head> <title></title> </h:head> <h:body> test #{ffs.count} </h:body

Removing beans from session

喜夏-厌秋 提交于 2019-12-11 07:44:39
问题 I have some @SessionScoped CDI beans. Previously all of them were JSF managed beans (changed from JSF managed beans to CDI managed beans). I was doing like the following to remove some session scoped JSF managed after a user successfully places an online order. Map<String, Object> sessionMap = context.getSessionMap(); sessionMap.remove("cartBean"); sessionMap.remove("orderItems"); sessionMap.remove("reviewOrderBean"); sessionMap.remove("intermediateLocaleBean"); sessionMap.remove("localeBean"

“Unexpected invocation state 0” error in Wildfly

大憨熊 提交于 2019-12-11 06:15:42
问题 I created a small example that demonstrates the error. A stateful bean holds a list as its state and injects a stateless bean: @Stateful @RequestScoped public class StatefulBean { @Inject StatelessBean slsb; @Getter // public list getter private List<String> list = new ArrayList<>(); public List<String> sfAdd() { slsb.slAdd(); System.out.println(list); list.add("Z"); return list; } } The stateless bean manipulates the state of the stateful bean by injection: @Stateless public class

Creating new entities while enabling injection

大憨熊 提交于 2019-12-11 05:56:49
问题 I have a method on a stateless session bean which creates a new instance of an entity and persists it. You might normally use new MyEntity() to create the object but I would like injection to populate some of the properties of the entity for me. I got partial success using @Inject @New private MyEntity myNewEntity; in the session bean and then using that instance in my method. The problem I have now is that the second time the method is called, myNewEntity isn't a new object, its the same

Debug update moderl phase, setter not being called

こ雲淡風輕ζ 提交于 2019-12-11 05:49:58
问题 This is a problem of build vs render time I guess. I've a comment section which is a tree of comments. Everything works fine... except for some comments the bean setters is not called. So my understanding is that : when using ui:repeat the composite component is included once at build time, then for each item is rendered with its appropriate value. Why it doesn't work ? no clue. when c:forEach is used, the composite component is integrated multiple times then at render time the item is lost

where to put filter like logic in JSF2

可紊 提交于 2019-12-11 05:34:21
问题 I am currently banging my head where to put a common logic for some authorization stuff in my Java EE 6/JSF 2 webapp: I have the requirement, that all requests that come with a specific cookie should be redirected to another page. I considered 3 solutions: 1) use a servlet 3.0 filter (@WebFilter) this worked, i also could inject my managed beans there, but the managed beans require access to the faces externalContext, which at filter invocation time has not yet been set up, so i got NPE's