cdi

How inject EJB into abstract CDI class?

拥有回忆 提交于 2019-12-11 00:26:26
问题 I have a problem with injecting an EJB into an abstract class which is the parent of my JSF CDI beans. In my project I am using MyFaces CODI 1.0.5 (ViewScope), Omnifaces 1.3, PrimeFaces 3.4.2 and GlassFish 3.1.2. The application is an EAR, the abstract class is in an EJB module and the JSF CDI beans are in a WAR module: webframework-demo.ear |__ webframework-war.war -> concrete JSF CDI bean |__ webframework-ejb-lib.jar -> abstract class with EJB injection |__ lib\ |__ shared libs My abstract

Using @Context in JAX-RS Provider to provide context information to CDI beans

ε祈祈猫儿з 提交于 2019-12-10 23:58:16
问题 I have some web-service (JAX-RS, WildFly 9, Resteasy) @RequestScoped public class SomeService{ // operations } Now I want to extract context information like user agent, which can be done using @Context private HttpHeaders httpHeaders; It seems only be possible to inject this context in JAX-RS-related classes, but not in CDI beans called by the webservice. It is possible to put it into the webservice but this clutters the service with stuff not related to the core response of the service.

Using JAX-RS (RESTEasy) with CDI (Weld) in Tomcat 7

孤人 提交于 2019-12-10 21:04:07
问题 In a JSF 2.0 application (running on Tomcat 7 and using weld 1.1.1.Final), I want to propose my user to download some binary files (.doc, .pdf etc). In order to fulfil that need, I want to use a JAX-RS (RESTEasy 2.2.0.Final) resource bean (annotated with @Path ). The problem is that inside that bean, I want to call a service from a field annotated with @Inject annotation. Actually, like a weld user trying a similar thing I've got a NullPointerException : Weld doesn't inject me my service. So

Order of @PostConstruct and inheritance

时光怂恿深爱的人放手 提交于 2019-12-10 20:56:15
问题 Let's suppose we have the following classes public abstract class AbstractFoo { @PostConstruct private void doIt() { // } } public class Foo extends AbstractFoo { @PostConstruct private void doIt() { // } } When AbstractFoo.doIt() and Foo.doIt() will be called - what is the order? 回答1: @PostConstruct is the last thing to get executed in the initialization of a given managed bean, relative to its position in the inheritance chain. From the spec The container must ensure that: Initializer

CDI: Why are there unsatisfied dependencies in the following setup?

妖精的绣舞 提交于 2019-12-10 20:25:53
问题 Ear file: ear +--lib | +--API jar | | +-- com.foobar.Greeter.class (interface) | | (look, ma, no META-INF/beans.xml on purpose) | | | +--JAX-RS endpoint jar | +-- com.foobar.GreeterResource.class (has @Inject Greeter greeter;) | +-- META-INF/beans.xml | +--EJB jar | +-- com.foobar.GreeterBean implements com.foobar.Greeter (@Stateless, @Local) | +-- META-INF/beans.xml | +--JAX-RS skinny war (no libs) +-- WEB-INF/beans.xml (maybe not necessary?) +-- WEB-INF/classes/com.foobar.Application (empty

Deployment of multiple, depended CDI jars in one EAR

耗尽温柔 提交于 2019-12-10 20:05:14
问题 i have a question about how to deploy multiple jars which contains CDi implementations together with a webapp. This is my Jar Structure -------- ---------- ------------ | WAR | <-- | API Jar | <-- | Data Jar | -------- ---------- ------------ ^ | -------------- | Common Jar | And many more implementations -------------- The WAR itself is the webapp which uses classes which are defines in the API Jar. The API jar only contains Interfaces, Annotations, non-logic classes, Qualifiers etc... The

Using @Inject Instance<blah> in Spring

一个人想着一个人 提交于 2019-12-10 18:49:29
问题 I know that Instance is not part of JSR 330, but is there a Spring equivalent? I'm interested in the fact that Instance implements Iterable, so Provider will not be the correct answer. public interface Report { ... } (there are 2 classes implementing Report with @Named annotations) @Named public class ReportRunner { @Inject private Instance<Report> reports; } results in: No qualifying bean of type [javax.enterprise.inject.Instance] found for dependency... 回答1: Closing this question out

How to implement MVP using Vaadin CDI and Navigator?

十年热恋 提交于 2019-12-10 18:35:00
问题 I would like to implement the MVP pattern in my web application using Vaadin. I am using the Vaadin Navigator and the CDIViewProvider, something like so: //MyUI.java public class MyUI extends UI { @Inject CDIViewProvider viewProvider; Navigator navigator; @Override protected void init(VaadinRequest vaadinRequest) { //UI setup navigator = new Navigator(this, someContainer); navigator.addProvider(viewProvider); getNavigator().navigateTo("myView"); } } //MyViewImpl.java @CDIView("myView") public

How can I update a collection that is @Produces @ApplicationScoped?

梦想的初衷 提交于 2019-12-10 18:27:00
问题 I'm currently migrating away from Seam's @Factory annotation. Combined with @Observer , I could do this: @Factory(value = "optionsList", scope = ScopeType.APPLICATION) @Observer("entity.modified") public List<MyBean> produceEntityOptions() { List l = getEm().createQuery('select e from entity e').getResultList(); Contexts.getApplicationContext().set("optionsList", l); return l; } Which would cache a list of possible options for use in e.g. <f:selectItems> (the actual computation can be more

java.io.NotSerializableException: org.jboss.weld.bean.ManagedBean

杀马特。学长 韩版系。学妹 提交于 2019-12-10 18:06:21
问题 Given the following CDI bean in JSF 2.2.6 running on GlassFish server 4.0. import javax.inject.Named; import javax.faces.view.ViewScoped; import java.io.Serializable; import org.primefaces.model.LazyDataModel; @ViewScoped @Named("myBean") public class MyBean extends LazyDataModel<T> implements Serializable { @Inject //Injecting an EJB. private MyLocalEJB service; private static final long serialVersionUID = 1L; } This causes the following exception to be thrown on undeployment of the