weld

Re-inject CDI bean if some injected property changed

你。 提交于 2019-12-25 03:03:01
问题 I have a bean BeanA with injected property private int url : class BeanA { @Value(${"db.url"}) private String url; private DbConnection connection; } Let us say this Value annotation is similar to Spring Value . During initialization, connection will be initialized by using injected property into url field. And also there is some PostConstruct and PreDestroy methods in BeanA . My question is: is it possible to dynamically reinstantiate BeanA when url property changed. I have mechanism of

CDI invalid bean archive scanning in Jetty (not in Tomcat)

此生再无相见时 提交于 2019-12-24 04:57:08
问题 I thought I got the most about Weld and CDI but this assumption is always demonstrating false. This time I am facing a weird behavior about bean scanning. Everything (a multi-module maven project) runs fine in Tomcat, but I got problems when it runs in the Maven Jetty 9 plugin: java.lang.IllegalStateException: WELD-ENV-000033: Invalid bean archive scanning result - found multiple results with the same reference: /home/myuser/workspace/my-root-project/my-web-module/target/classes at org

startup class in Weld

拈花ヽ惹草 提交于 2019-12-23 21:16:42
问题 I am trying to define a startup class for my application in Weld CDI with @Singleton and @Startup annotations (running on tomcat 7), but my PostConstruct method is never called. Here is my Startup class: import java.util.List; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.ejb.Startup; import javax.inject.Inject; import javax.ejb.Singleton; import javax.persistence.EntityManager; import se.raindance.squid.core.domain.SquidSettings; @Singleton @Startup

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

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

WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped

半世苍凉 提交于 2019-12-23 08:17:08
问题 I have searched every where, but seem I cannot find out the best answer for me to resolved this error, there is my stack trace, can somebody tell me what happening with me, I have spent twos date to finding this error....:( 16:55:02,405 SEVERE [org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler] (Thread-16 (HornetQ-client-global-threads-982087879)) exception during timer execution: org.activiti.engine.ActivitiException: Exception while invoking TaskListener: WELD

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

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

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

JavaEE CDI in Weld: Generic Events?

狂风中的少年 提交于 2019-12-22 10:02:52
问题 I have an idea for a specific event handling based on generics, but seems like Weld can't handle them. I asked google but couldn't find an alternative CDI extension for this. Question : is there a CDI extension, that can handle event propagation of generic-typed events? In the following the explicit problem I have. I have three general events, EntityCreated, EntityChanged and EntityDeleted. The base class for them is defined like this: public abstract class DatabaseEvent<TargetType> { public