weld-se

Weld using alternative producer from src/test/META-INF/beans.xml

≯℡__Kan透↙ 提交于 2019-12-21 21:34:24
问题 I am trying to use Weld SE 2.3.0.Final to swap an alternative implementation of an injected dependency during testing by supplying a different beans.xml in src/test/resources/META-INF It always seems to use the main version of beans.xml though and I'm not sure why. First of all here are the supporting classes Engine.java public interface Engine { void start(); void stop(); } DefaultEngine.java @Vetoed public class DefaultEngine implements Engine { public void start() { System.out.println(

Bean discovery problems when using weld-se with Gradle application plugin

微笑、不失礼 提交于 2019-12-10 12:32:29
问题 I am building a Gradle-based Java SE application built on top of Hibernate as my ORM of choice. My plan is to use weld-se to be able to use CDI annotations for injections of EntityManagers throughout the application. Based on the common HibernateUtil helper class found in the Hibernate documentation, I moved towards JPA interfaces and added @Produces annotations to provide producer methods (I have added an empty META-INF/beans.xml as well): package dao; import javax.enterprise.inject.Disposes

Weld using alternative producer from src/test/META-INF/beans.xml

点点圈 提交于 2019-12-04 17:51:43
I am trying to use Weld SE 2.3.0.Final to swap an alternative implementation of an injected dependency during testing by supplying a different beans.xml in src/test/resources/META-INF It always seems to use the main version of beans.xml though and I'm not sure why. First of all here are the supporting classes Engine.java public interface Engine { void start(); void stop(); } DefaultEngine.java @Vetoed public class DefaultEngine implements Engine { public void start() { System.out.println("Cough cough vrummmmm"); } public void stop() { System.out.println("Phhhut clank"); } } Car.java public

No active contexts for scope type javax.enterprise.context.RequestScoped when invoking a bean from a thread

霸气de小男生 提交于 2019-11-29 09:24:05
While using Weld-SE 2.1.2.Final to obtain a bean and to invoke it from a thread, I encounter the following exception: Exception in thread "main" org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped My bean is annotated with @RequestScooped. If I annotate @ApplicationScoped then it works fine, but I need to keep @RequestScooped. Here is a reproducer : public static void main(String[] args) throws Exception { Weld weld = new Weld(); WeldContainer container = weld.initialize(); final MyPojo pojo = container

No active contexts for scope type javax.enterprise.context.RequestScoped when invoking a bean from a thread

我们两清 提交于 2019-11-28 02:47:56
问题 While using Weld-SE 2.1.2.Final to obtain a bean and to invoke it from a thread, I encounter the following exception: Exception in thread "main" org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped My bean is annotated with @RequestScooped. If I annotate @ApplicationScoped then it works fine, but I need to keep @RequestScooped. Here is a reproducer : public static void main(String[] args) throws Exception {