cdi

Can I use CDI to @Inject a class in Jersey 1.x?

自闭症网瘾萝莉.ら 提交于 2019-12-23 20:13:06
问题 I think I'm asking this question but for Jersey 1.x: Dependency injection with Jersey 2.0 I'm using Glassfish 3, CDI and Jersey 1.x. I have a @WebService that is injecting a class like this: @Inject Foo foo; I've tested this in the @WebService and it works. But the same line of code in my Jersey resource throws a NPE when it tries to use foo . I think Jersey 1.x is ignoring the CDI annotations. How can I get dependency injection working like it does in my @WebService ? Foo is a pojo and my

CDI Injecting services into JPA managed Entities

拟墨画扇 提交于 2019-12-23 15:19:00
问题 I'm sure this is strongly related to this question but the op on that question has a bit of a scenario that I'm not sure even makes sense for DI. So here's what I understand, it's generally not a good idea to try to mix a JPA Entity with a CDI Bean because both are generally done by creating proxy objects. Here's what I envisioned, but from what I've read this is not possible. @Entity public class MyUniqueObject implements Serializable { @Inject private transient Logger log; @Inject private

org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456: Argument resolvedBean must not be null

懵懂的女人 提交于 2019-12-23 12:29:10
问题 Injecting EJBs into entity listeners is available, since JPA 2.1. WildFly 9.0.2 final however, fails with the following exception. 15:41:12,125 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 149) MSC000001: Failed to start service jboss.persistenceunit."Test.ear/Test-ejb.jar#Test-ejbPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."Test.ear/Test-ejb.jar#Test-ejbPU": javax.persistence.PersistenceException: [PersistenceUnit: Test-ejbPU] Unable to

BeanManager on Apache Tomcat 7.0.47 cannot create resource instance

ぃ、小莉子 提交于 2019-12-23 11:53:13
问题 running on: Apache Tomcat 7.0.47 OmniFaces 1.6.3 JSF Mojarra 2.1.26 CDI Weld 2.1.0.Final Threre is an RuntimeException on Apache Tomcat 7.0.47 by accessing JNDI "java:comp/BeanManager". The CDI BenManager is bound to " java:comp/env/BeanManager " vut not reached in your BeanManager Class. /** * Perform automatic initialization whereby the bean manager is looked up from the JNDI. If the bean manager is * found, then invoke {@link #init(Object)} with the found bean manager. */ private void init

CDI injection in a JSP

馋奶兔 提交于 2019-12-23 11:46:09
问题 Within a JSP it is possible to use CDI managed beans using EL expressions such as ${myBean.myAttribute}. No problem here. I would like to use "regular injection" (i.e. without using EL expressions) with @Inject in JSP files, for example : <%! @Inject MyBean myBean; %> then later <%= myBean.getMyAttribute() %>. Even if that example can be achieved using EL expressions, some other use cases cannot. This does not seem to be completely supported by app servers: - JBoss 6.0.0, JBoss 6.1.0, Resin 4

JSF Named Bean, Eager application scoped (aka @ManagedBean(eager=true) )

断了今生、忘了曾经 提交于 2019-12-23 10:09:30
问题 Is there any way to initialize Named Bean annotaded by javax.inject.Named / javax.enterprise.context.ApplicationScoped like @ManagedBean(eager=true) from javax.faces package? @Named @ApplicationScoped public Mail() { ... } I want to load this class when application starts, not when webapplication refers to this bean. ps. JSF 2.1 Bean Injected by Glassfish 3.1 回答1: You can create a CDI extension that has the @Observes AfterBeanDiscovery parameter on one of his methods. There you can

How to modularize an Enterprise Application with OSGi and EE6?

跟風遠走 提交于 2019-12-23 09:38:03
问题 I know that there are already some questions related to this topic but I couldn't find a real solution yet. Currently I am developing applications with EE6, using JPA, CDI, JSF. I would like to take a more modular approach than packaging everything into a WAR or EAR and deploy the whole thing on an Application Server. I am trying to design my applications as modular as possible by separating a module into 3 maven projects: API - Contains the interfaces for (stateless) services Model -

JAX-RS resource error: Couldn't find JAX-B element for class java.lang.String and some more exceptions

℡╲_俬逩灬. 提交于 2019-12-23 09:35:06
问题 When I do an OPTIONS call on the rest resource 'queue' from the Java EE 7 SDK example 'async-chat', I get many exceptions, when the log level for jersey is set to FINE (org.glassfish.jersey.level=FINE). The same exceptions happen in my code, given below. Both applications run correctly. Are these exceptions irrelevant (just thrown when the logging level is on FINE)? If not, why are they thrown? I tested several GlassFish 4 installations and also GlassFish 4.0.1. They all show the same

WELD-001408 Unsatisfied dependencies when injecting EntityManager

半城伤御伤魂 提交于 2019-12-23 08:53:19
问题 I have @Stateless bean which implements two interfaces (remote and local). I have also added @LocalBean anotation for accessing bean with a no-interface view. @Stateless @LocalBean public class WeatherDataBean implements WeatherDataBeanRemote, WeatherDataBeanLocal { @Inject private EntityManager entityManager; public WeatherDataBean () { } // ....attributes, getter & setter methods .... } I use @Inject for this reason taken from this example of JBoss AS7 quickstart: We use the "resource

WELD-001408 Unsatisfied dependencies when injecting EntityManager

孤者浪人 提交于 2019-12-23 08:52:20
问题 I have @Stateless bean which implements two interfaces (remote and local). I have also added @LocalBean anotation for accessing bean with a no-interface view. @Stateless @LocalBean public class WeatherDataBean implements WeatherDataBeanRemote, WeatherDataBeanLocal { @Inject private EntityManager entityManager; public WeatherDataBean () { } // ....attributes, getter & setter methods .... } I use @Inject for this reason taken from this example of JBoss AS7 quickstart: We use the "resource