cdi

CDI inject EJB into POJO on Glassfish v3

流过昼夜 提交于 2019-12-10 17:45:48
问题 Is it possible to inject EJB 3.1 beans into POJO using CDI on Glassfish v3? My classes (in EJB module): @Singleton @LocalBean @Startup @Named public class NewSingletonBean { @PostConstruct public void init(){ System.out.println("NewSingletonBean INIT"); } } _ @Singleton @LocalBean @Startup @DependsOn(value="NewSingletonBean") public class NewSingletonBean2 { @Inject NewSingletonBean newSingletonBean; @PostConstruct public void init(){ System.out.println("NewSingletonBean2 INIT"); System.out

Configuring Spring to ignore dependencies annotated with @Inject

非 Y 不嫁゛ 提交于 2019-12-10 17:34:34
问题 I have an EJB class in which I need to inject two beans - one should be injected by the EJB container and other is a Spring Container. @Stateless @Interceptors(SpringBeanAutowiringInterceptor.class) @LocalBean public class SomeClass { @Inject private EJBClass a; @Autowired private SpringComponent b; } Here, the Spring interceptor trying to intercept the injection of bean 'a' and it's getting failed. I want the EJB container to inject the bean 'a' and Spring container to inject bean 'b'.

Implementing @RequestParam in CDI/WELD using Qualifier and InjectionPoint as @HttpParam

£可爱£侵袭症+ 提交于 2019-12-10 17:32:39
问题 The glassfish error INFO: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context '/NNTPjsf' INFO: WEB0671: Loading application [NNTPjsf] at [/NNTPjsf] SEVERE: Exception while loading the app INFO: only once... INFO: NNTP.loadMessages... SEVERE: Exception while loading the app : WELD-001408 Unsatisfied dependencies for type [FacesContext] with qualifiers [@Default] at injection point [[field] @Inject net.bounceme.dur.nntp.HttpParamProducer.facesContext] org.jboss.weld.exceptions

Remove/destroy session scoped CDI managed bean

血红的双手。 提交于 2019-12-10 16:48:29
问题 I have a session scoped CDI managed bean: @Named @SessionScoped public class SampleBean implements Serializable { // ... } I need to remove this bean from the session after a certain flow for which I used the following code like as seen in this answer: ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); ec.getSessionMap().remove("sampleBean"); However, it does not work and the SampleBean remains in the session. Am I missing something? 回答1: In contrary to JSF managed

WELD-001409 Ambiguous dependencies for type [EagerBeansRepository]

ぃ、小莉子 提交于 2019-12-10 15:54:14
问题 I'm trying to migrate my JSF application to CDI. I have implented the following changes: Added an empty beans.xml file to WEB-INF Changed @ManagedBean 's to @Named Changed All the scopes I have to CDI Scopes (Session, View, Request) Changed all @EJB and @ManagedProperty to @Inject However, an Omnifaces error is preventing deployment as I'm getting the following error three times: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [EagerBeansRepository]

CDI Events, scope of their propagation

橙三吉。 提交于 2019-12-10 15:37:41
问题 Here's a recurrent problem that I have and I think maybe CDI events can help me but I'm not sure. I have two users interacting in a website, I want them to share an instance of a bean so they can both share an activity. So far the only way I know how to do this is by pushing data to the database then having two different beans, one for each user, continuosly check for changes. My question is, if a sessionscoped bean observes an event, do every sessionbean of every user get notified when i

How do you find CDI beans of/in the current view (scope)?

て烟熏妆下的殇ゞ 提交于 2019-12-10 15:16:22
问题 In a Java EE 6, CDI 1.1.x, Seam 3 etc. environment , we need to find all CDI beans of the current view ( @ViewScoped ). What I have tried so far is using: @Named @ViewScoped public class ViewHelper { @Inject private BeanManager beanManager; public doSomethingWithTheBeanInstances() { Set<Bean<?>> beans = this.getBeanManager().getBeans( Object.class, new AnnotationLiteral<Any>(){} ); // do something ... } } However, this returns all beans it manages. I need to find only those within the scope

Injecting a stateless EJB into Servlet

有些话、适合烂在心里 提交于 2019-12-10 15:11:19
问题 I'm trying to inject a stateless EJB into servlet. But it is not working. Did I understand something wrong? If I do this in a @WebService annotated class, I can use the injected EJB without problems. My EJB: @Stateless public class doSomethingService { public void doSomething() { System.out.println("DO SOMETHING"); } } My Servlet: @WebServlet("/testservlet") public class test_servlet extends HttpServlet { private static final long serialVersionUID = 1L; @Inject private doSomethingService

Injecting @EJB in OmniFaces @Eager bean causes “Severe: No valid EE environment for injection of org.omnifaces.cdi.eager.EagerBeansRepository”

 ̄綄美尐妖づ 提交于 2019-12-10 14:54:33
问题 Using @ApplicationScoped @Named @Eager , my @EJB -injected @Stateless beans are not properly instantiated and evaluate to null . I had an @ApplicationScoped @ManagedBean(eager=true) that was used to schedule a few jobs. Some @Stateless beans were injected using @EJB annotation, and that worked fine. In the move to CDI annotations, I added the OmniFaces @Eager annotation as substitute for @ManagedBean(eager=true) which is missing in standard CDI: import javax.annotation.PostConstruct; import

@ApplicationScoped in a cluster

荒凉一梦 提交于 2019-12-10 14:05:28
问题 I don't have a clustered environment at present, but I was curious about @ApplicationScoped behaviour in a clustered environment. Is there going to be only one across the cluster or is still still one per JVM in the cluster? I have read that @Singleton gets created per JVM in How singleton is javax.ejb.Singleton in a clustered environment? 回答1: References to @ApplicationScoped are proxied, so they will be correctly resolved by the CDI container. That holds true no matter how many nodes are