cdi

injectionPoint.getBean() returns null if bean is an EJB bean in Java EE 7 (CDI 1.1)

久未见 提交于 2019-12-21 02:36:08
问题 I want to get bean from producer method in order to read its properties. In some scenarios the bean is a EJB Singleton bean. I've simplified my code to focus on the problem. My simple qualifier: @Qualifier @Retention(RUNTIME) @Target({TYPE, METHOD, FIELD, PARAMETER}) public @interface InjectMe {} Simple producer: @Dependent public class SimpleProducer { @Produces @InjectMe public String getInjectMe(InjectionPoint ip) { // ip.getBean() returns null for some reason return "ip=" + ip + ", bean="

injectionPoint.getBean() returns null if bean is an EJB bean in Java EE 7 (CDI 1.1)

三世轮回 提交于 2019-12-21 02:35:20
问题 I want to get bean from producer method in order to read its properties. In some scenarios the bean is a EJB Singleton bean. I've simplified my code to focus on the problem. My simple qualifier: @Qualifier @Retention(RUNTIME) @Target({TYPE, METHOD, FIELD, PARAMETER}) public @interface InjectMe {} Simple producer: @Dependent public class SimpleProducer { @Produces @InjectMe public String getInjectMe(InjectionPoint ip) { // ip.getBean() returns null for some reason return "ip=" + ip + ", bean="

Are JSF 2.x @ViewScoped managed beans thread safe?

折月煮酒 提交于 2019-12-20 10:28:57
问题 I've been googling for a couple hours on this issue to no eval. WELD docs and the CDI spec are pretty clear regarding thread safety of the scopes provided. For example: Application Scope - not safe Session Scope - not safe Request Scope - safe, always bound to a single thread Conversation Scope - safe (due to the WELD proxy serializing access from multiple request threads) I can't find anything on the View Scope defined by JSF 2.x. It is in roughly the same bucket as the Conversation Scope in

Is it possible to inject EJB implementation and not its interface using CDI?

元气小坏坏 提交于 2019-12-20 09:37:32
问题 My configuration is: Wildfly 8.2.0, Weld Is it possible to inject in bean and not in its interface in CDI ? @Stateless class Bean implements IBean { ... } interface IBean { ... } @SessionScoped class Scoped { @Inject Bean bean; //Fail @Inject IBean iBean; //OK } EDIT : More Info in my previous question: Stateless EJB implements interface injection failed 回答1: Yes you can, but as EJB inject the business view the only business view you are exposing is the @Local view which is the default when

What are the best debugging tricks with Weld/CDI?

时间秒杀一切 提交于 2019-12-20 09:21:43
问题 One of the beauties with Java EE 6 is the new dependency injection framework - CDI with the Weld reference implementation - which has prompted us to start migrating internally to JSR-330 in an implementation agnostic manner, with the explicit target of being able to have a core jar which is frozen, and then being able to add extra jars providing new modules replacing functionality in the core jar. I am now in the process of making the above work with Weld, and to be frank there is simply too

application managed transactions in J2EE

与世无争的帅哥 提交于 2019-12-20 07:05:30
问题 Does anyone have an example of the best way to begin, commit/rollback a transaction from within a CDI managed bean within a J2EE 6 container.? I have run into a particular case where the annotated approach won't work for me (I'm calling the method from another method in the same class) and I need to set the transaction boundaries manually. I would like to know what I can do in my code that would replicate the behavior of the following annotation: @TransactionAttribute(TransactionAttributeType

How to inject objects of the same class with different scopes?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 06:25:01
问题 In terms of simplicity and correctness, what is the best way to inject objects of the same class with different scopes? In a servlet I want to have injected objects of the same class with different scopes. Still don't know if going to use jsf. Simplicity: Making a Qualifier and a producer method for each scope is too much; making an interface, two classes and adding and alternative in beans.xml is also too much; having an Address#isCurrent() method doesn't make sense. Correctness: JSR299, 3

Enabling EJB Injection into Vaadin 7 UI via Usage of Vaadin-CDI-Integration Addon

本小妞迷上赌 提交于 2019-12-20 04:18:05
问题 I wasn't able to successfully integrate the official Vaadin-CDI-Integration-Addon, since after finishing the official integration instructions, the following Exception was thrown in case I reloaded the already published URL localhost:8080/App/?restartApplication . javax.servlet.ServletException: com.vaadin.server.ServiceException: java.lang.IllegalStateException: UI id has already been defined The following little workaround is a tested, working solution, which completes the official

Omnifaces exception on deployment on Tomcat 7

社会主义新天地 提交于 2019-12-20 02:52:35
问题 I'm trying to add Omnifaces 2.1 to a web application to use FullAjaxExceptionHandler and possibly other functionality in Omnifaces 2.1. I've read and followed following post by BallusC and am still stuck: How to install and use CDI on Tomcat? Tried to install Weld 2.2.9.Final and configure as described above. I am using the following: JSF 2.2, EL 2.2, Servlet 3, Java 7 web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http:/

How to inject a Session Bean into a Message Driven Bean?

谁都会走 提交于 2019-12-19 19:55:55
问题 I'm reasonably new to Java EE, so this might be stupid.. bear with me pls :D I would like to inject a stateless session bean into a message-driven bean. Basically, the MDB gets a JMS message, then uses a session bean to perform the work. The session bean holds the business logic. Here's my Session Bean: @Stateless public class TestBean implements TestBeanRemote { public void doSomething() { // business logic goes here } } The matching interface: @Remote public interface TestBeanRemote {