cdi


How to use CDI Events in Java Jersey?

送分小仙女□ 提交于 2020-01-21 11:57:22
问题 I am trying to follow this post's upvoted answer: Best practice for REST token-based authentication with JAX-RS and Jersey I'm using the CDI approach and in my filter i have the definition: @Inject @AuthenticatedUser Event<String> userAuthenticatedEvent; But, when I run tomcat 7, I get the following error: org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=Event<String>,parent=AuthenticationFilter,qualifiers={

Content Assist for JSF2 + CDI (weld) beans + Eclipse Helios

烂漫一生 提交于 2020-01-20 04:06:56
问题 Im trying JSF2 CDI (weld) beans in eclipse helios instead of ManagedBeans , but can't do the auto completion inside the expression language for my Named beans (the #{myNamedBean. Ctrl + Space } thingy) But OTOH with ManagedBeans, the content assist works well .. Is the content assist for CDI beans supported yet in Eclipse Helios? Anybody got experiences in this ? 回答1: Install JBoss tools. Then by adding <nature>org.jboss.tools.jsf.jsfnature</nature> to the natures section of the .project file

Getting a “WELD-001408 Unsatisfied dependencies error when deploying a class injected with an interface”

孤街醉人 提交于 2020-01-16 13:17:09
问题 I'm doing some unit tests using Arquillian on JUnit4 and Jboss6. There is a facade(SomeFacadeclass) that has the "SomeClass"(which is an interface) injected to it. When Arquillian deploys the test.war for testing the above deployment error pops up. What should i do to solve this? 回答1: I would guess that you don't have an implementation of SomeClass in your bean archives 回答2: Everything was solved. I added the implementation class to the @Deployment archive and some other bunch of dependent

Quarkus / CDI and “java config” DI definitions

断了今生、忘了曾经 提交于 2020-01-16 01:46:16
问题 I just started a quarkus proof of concept. The containers-start time is amazing! Right now, I'm working on the Dependency Injection part. And figuring out the options. https://quarkus.io/blog/quarkus-dependency-injection/ My preferences are: I prefer constructor injection. (This has been going ok). I prefer "java config" so I can follow the "Composition Root" pattern of putting all my application dependency injections in a common place. (See https://blog.ploeh.dk/2011/07/28/CompositionRoot/ )

CDI: pass through qualifier from one injection point to the other

北城余情 提交于 2020-01-15 06:43:12
问题 I'd like to kind of pass-through a qualifier annotation using CDI. With that I mean that I'd want to add a qualifier to an injection point with that qualifier not being applied directly for the "first-level" injection target (because there is only one implementation for this) but a field within ("2nd level") the injected EJB. Is this possible with CDI? Does it maybe already work out-of-the-box? It should look similar to: @Stateless public class MyFirstLevelEJB { @Inject //this guy has

How to write main() using CDI in Java EE?

时光总嘲笑我的痴心妄想 提交于 2020-01-14 04:24:34
问题 I have a no-client application that I wish to run. It will have no clients but it will make HTTP calls and act as client for other services. It would run for perhaps a few hours or days (but it will not require periodic runs -- just one-shot). I want to run it in a Java EE 7 container, because of the benefits of standard Context Dependency Injection (CD), and a standard JAX-RS client (new since Java EE 7). It is also nice to have services such as JMS, JPA. The question is how do I write /

“could not initialize proxy - no session” with an open session available

孤人 提交于 2020-01-13 18:23:37
问题 I work with JSF 2 (MyFaces 2.1.7 and Primefaces 3.4.2), CDI (Weld-servlet 1.1.10), JPA 2 (Hibernate 4.1.7) and Lombok 0.11.2. All this runs on Tomcat 6 and 7. I use the OpenSessionInView pattern, implemented through a Filter . @Advanced @Data @Slf4j public class TransactionalFilter implements Filter, Serializable { private static final long serialVersionUID = 999173590695648899L; @Inject private EntityManager em; @Override public void doFilter(ServletRequest request, ServletResponse response,

@Injection is not working for CDI bean

我的梦境 提交于 2020-01-13 17:06:37
问题 I have a CDI bean where I'm using @ConversationScoped. When I try to do an @Inject for the Conversation object, I get a NPE. @ConversationScoped @Named("customerbean") public class CustomerBean implements Serializable { @Inject private Conversation conversation; private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("ba"); private EntityManager em; private Customer customer; boolean disabled; public CustomerBean() { beginConversation(); customer = new Customer(

@Injection is not working for CDI bean

旧巷老猫 提交于 2020-01-13 17:05:43
问题 I have a CDI bean where I'm using @ConversationScoped. When I try to do an @Inject for the Conversation object, I get a NPE. @ConversationScoped @Named("customerbean") public class CustomerBean implements Serializable { @Inject private Conversation conversation; private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("ba"); private EntityManager em; private Customer customer; boolean disabled; public CustomerBean() { beginConversation(); customer = new Customer(

CDI - ApplicationScoped but configured

空扰寡人 提交于 2020-01-13 07:20:33
问题 Problem Using CDI I want to produce @ApplicationScoped beans. Additionally I want to provide a configuration annotation to the injection points, e.g.: @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) public @interface Configuration { String value(); } I do not want to write a separate producer for each different possibility of value . Approach The usual way would be to make a producer and handle the injection point annotations:

工具导航Map