cdi

How to exclude a class from scanning with CDI 1.0

早过忘川 提交于 2019-12-23 07:26:24
问题 I would like to exclude a class from scanning in CDI 1.0. I'm using the default implementation of CDI in WebLogic 12.1.12 (Weld, CDI 1.0). I saw several web sites and docs with CDI 1.1 but not with the previous release . 回答1: With Weld, you can use a custom XML namespace in beans.xml to exclude classes from scanning: <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:weld="http://jboss.org/schema/weld/beans"> <weld:scan> <weld:exclude

TomEE on eclipse, How to call a remote EJB from a JSF Managed bean?

我的未来我决定 提交于 2019-12-23 05:25:30
问题 I want to have JSF 2.0 page in one instance of TomEE server calling a Remote EJB running under a different TomEE server, (both obviously running on different ports). This is what I have done in eclipse... AppEJB - is a EJB project that contains all the ejb code. AppEJBInterfaces - This project contains all the remote interfaces, the idea is that this jar will be added to the class path of the web application project containing JSF front end. AppWeb - is the Dynamic Web Application project

Local Thread linked with RequestScope

心不动则不痛 提交于 2019-12-23 04:43:47
问题 I have a web service built with VRaptor that uses CDI (weld 2.1.2.Final). I need to parallelize some of the processing made by the server (statistical analysis of industrial alarms). I'm doing that using a ExecutorService and Callable instances, unfortunately I need one Request Scoped dependence inside my Threads. Because of that dependence I'm facing this error: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped Is there a way to link the Threads to the

Logger, convert from @Inject to producer

喜夏-厌秋 提交于 2019-12-23 02:45:25
问题 I am having trouble implementing a Login interface like the example Simple CRUD Web Application with JSF 2.1, PrimeFaces 3.5, EJB 3.1, JPA (ORM) / EclipseLink, JAAS , MySQL On TomEE's mailing list, I have been told that the LoginController.java I am using tries to inject Logger, but Logger injection is not managed by CDI. I have been told to use a producer instead. Not knowing what it is, I searched on the internet and I found this example But I am still not confortable with it, so please

WELD-001300 when trying to lookup BeanManager by JNDI

别来无恙 提交于 2019-12-22 17:52:01
问题 I configured Jetty 9.2.5 + Weld 2.2.7 (currently the latest versions) as described by the Weld documentation. Everything works fine, except the lookup of the BeanManager by JNDI. Lookup of other JNDI entries just work as expected. I got the error (note this is not a javax.naming.NameNotFoundException ) javax.naming.NamingException: WELD-001300: Unable to locate BeanManager The code I use: BeanManager beanManager = null; try { final Context ctx = new InitialContext(); try { // JNDI name

@Named behaving different from @ManagedBean

霸气de小男生 提交于 2019-12-22 14:41:04
问题 I'm currently migrating a project from JBoss 4.2.2 to JBoss 6.0.0 and I'm also adding Dependency Injection with CDI and migrate from JSF 1.2 to JSF 2.0. I added a beans.xml file to both the ejb-package, as well as the war-package. Now I have a xhtml page that uses the managed bean LoginBean.java . The beans had been configured in the faces-config.xml like this: <managed-bean> <description>Sample description</description> <managed-bean-name>loginBean</managed-bean-name> <managed-bean-class>com

@Named behaving different from @ManagedBean

随声附和 提交于 2019-12-22 14:40:34
问题 I'm currently migrating a project from JBoss 4.2.2 to JBoss 6.0.0 and I'm also adding Dependency Injection with CDI and migrate from JSF 1.2 to JSF 2.0. I added a beans.xml file to both the ejb-package, as well as the war-package. Now I have a xhtml page that uses the managed bean LoginBean.java . The beans had been configured in the faces-config.xml like this: <managed-bean> <description>Sample description</description> <managed-bean-name>loginBean</managed-bean-name> <managed-bean-class>com

@Dependent @javax.ejb.Singleton versus @ApplicationScoped @javax.ejb.Singleton?

拥有回忆 提交于 2019-12-22 13:55:29
问题 In essence, what is the difference between these two classes: @ApplicationScoped @Singleton class A {} @Dependent @Singleton class B {} Contextual EJB instances I prefer not to use @Inject when looking for EJB:s, unless the EJB is a @Stateful and I want the CDI container to manage the stateful's life-cycle which could be very convenient. Otherwise, using @Inject to retrieve a contextual EJB instance is a bit dangerous. For example, a @Remote client-view cannot be retrieved using CDI unless we

Why my @ApplicationScope CDI bean not updated?

末鹿安然 提交于 2019-12-22 12:54:41
问题 In my application, I have an @ApplicationScoped CDI bean to store some information from the database: @Named @ApplicationScoped public class MrBean { @EJB private SoyaBean soyaBean; private List<Toys> myToys; @PostConstruct public void prepareMrBean() { this.myToys = soyaBean.getToys(); } public void updateToys() { this.myToys = soyaBean.getToys(); } } I also have a AddToy.xhtml page which would simply add a toy to the database. The backing bean is as following: @Named @RequestScoped public

Issue with EJB 3.1 injected with CDI bean while running JUnit

回眸只為那壹抹淺笑 提交于 2019-12-22 10:25:09
问题 I created a EJB3.1 and injected CDI bean using the @inject but facing some issues while unit testing however when tested from the servlet its working fine. I have the beans.xml in the WEB-INF folder. Below is my EJB code: @Stateless public class CdiUsingEjb { @Inject private HelloServletCDIPojo helloServletCDIPojo; public String greet() { assert helloServletCDIPojo != null; return helloServletCDIPojo.from(); } } Below is my CDI bean: public class HelloServletCDIPojo { public String from() {