cdi

@Inject-ed value null in @FacesComponent

断了今生、忘了曾经 提交于 2019-12-10 10:25:07
问题 I have the impression that CDI is not working with classes that have a @javax.faces.component.FacesComponent . Is this true? Here's my example, that doesn't work. The MyInjectableClass is used at other points in the code where injection is not a problem, so it must be about the @FacesComponent annotation I think. The class I want to inject: @Named @Stateful public class MyInjectableClass implements Serializable { private static final long serialVersionUID = 4556482219775071397L; } The

CDI @TransactionAttribute for bean

若如初见. 提交于 2019-12-10 10:12:28
问题 I am experimenting with CDI on a test application. I have a DAO which injects a container managed JTA persistence context like this: public class TestDAO implements Serializable { @PersistenceContext private EntityManager entityManager; public void insertEntity(Test test) { entityManager.persist(test); } } Now I have a CDI controller bean like this: @Named @SessionScoped public class TestController implements Serializable { @Inject private TestDAO testDAO; public void finishGame() { testDAO

Get access to session scoped CDI bean from request scoped CDI Bean

坚强是说给别人听的谎言 提交于 2019-12-10 09:26:39
问题 I have already one session scoped CDI bean, which keeps currently logged in user data. Now, from another, request scoped I would like to access to this bean to get some data. I have some operation to do, which is dependent on user login. That's the only information I need. How to access it? AccountBean.java: @Named("accountBean") @SessionScoped public class AccountBean implements Serializable { private static final long serialVersionUID = 16472027766900196L; @Inject AccountService

Using CDI instead of @ManagedBean: UnproxyableResolutionException because super class has no no-args constructor

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 03:15:03
问题 I'm trying to use CDI for my JSF/Java EE application. I have the following class hierarchy: /** * base controller class * also contains some final methods and an inner enum class declaration */ public abstract class AbstractCrudController<K, E> implements Serializable { private Class<E> entityClass; public AbstractCrudController(Class<E> entityClass) { this.entityClass = entityClass; } // ... } import javax.enterprise.context.SessionScoped; import javax.inject.Named; @Named @SessionScoped

Are CDI event observer methods compatible with EJBs?

守給你的承諾、 提交于 2019-12-10 03:03:30
问题 I have a Singleton EJB (javax.ejb.Singleton version. sigh.) which has a CDI observer method on it. When I try to deploy this to glassfish 3.1 the server fails to deploy the EAR file without any real explanation - simply saying there was an exception during deployment without any more details. SEVERE: Exception while loading the app SEVERE: Exception while shutting down application container .... SEVERE: Exception while shutting down application container : java.lang.NullPointerException This

Is it possible to destroy a CDI scope?

陌路散爱 提交于 2019-12-10 02:36:51
问题 I'm working on a Java EE application, primarily JAX-RS with a JSF admin console, that uses CDI/Weld for dependency injection with javax.enterprise.context.ApplicationScoped objects. Minor debugging issues aside, CDI has worked beautifully for this project. Now I need some very coarse-grained control over CDI-injected object lifecycles. I need the ability to: Remove an injected object from the application context, or Destroy/delete/clear/reset/remove the entire application context, or Define

Inject producer method that returns String CDI

心已入冬 提交于 2019-12-10 02:23:37
问题 I would like to inject constant string message to managed bean in JSF web application using CDI, here is producer class: @Named @RequestScoped public class StringProducer { @Produces @Named("message") @RequestScoped public String getMessage() { return "Hello World"; } } and here is how it is injected in another managed bean: @Inject Named("message") String message; but this always result in exception: org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001435 Normal scoped bean int

CDI object not proxyable with injected constructor

本秂侑毒 提交于 2019-12-10 01:23:26
问题 When trying to inject arguments into the constructor of a CDI bean (ApplicationScoped), I'm encountering the following issue: Caused by: org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001435: Normal scoped bean class xx.Config is not proxyable because it has no no-args constructor - Managed Bean [class xx.Config] with qualifiers [@Default @Named @Any]. at org.jboss.weld.bean.proxy.DefaultProxyInstantiator.validateNoargConstructor(DefaultProxyInstantiator.java:50) at org.jboss

Injecting RequestScoped CDI Bean into ApplicationScoped CDI Bean via Producer class

蓝咒 提交于 2019-12-09 20:59:02
问题 This article explains that you can inject RequestScoped beans into ApplicationScoped beans and the client proxy will point to the correct instance during a request: Bean instance of a shorter scope injected in a bean instance of a larger scope in CDI - how does it work? How does this work when using a separate producer class that does some extra processing and produces the RequestScoped bean? Upon deployment to the application server I get a DeploymentException due to ambiguous dependencies

java ee6: override CDI alternative

牧云@^-^@ 提交于 2019-12-09 13:53:17
问题 I'm using Glassfish 3.1.2.2, java ee6. I have a library in which a class uses CDI to get a helper class. I would like in one specific project where I use that library, to override that CDI dependency and force the library to use my own helper class, specific to that project instead. I can modify the library at will, but by default it should use its default helper class, so that behaviour doesn't change for other users of the library. This should be the perfect application of the @Alternative