weld

How to inject EntityManager in CDI (weld)?

南楼画角 提交于 2019-11-30 08:49:02
In my project , I use JSF+JPA+CDI+WildFly 8.2 in the persistence layer. I have a BasicDao , like this: public class BasicDao<M, K> { private org.jboss.logging.Logger logger = org.jboss.logging.Logger .getLogger("BasicDao"); @Inject @Primary protected EntityManager em; Class<M> mclass; public EntityManager getEm() { return em; } public void setEm(EntityManager em) { this.em = em; } @Transactional(value=TxType.NOT_SUPPORTED) public M find(K id){ return em.find(mclass, id); } @Transactional(value=TxType.REQUIRED) public void insert(M inst){ this.em.persist(inst); } @SuppressWarnings("unchecked")

Why is the interceptor not called in the same service class?

血红的双手。 提交于 2019-11-29 13:54:35
I want to use interceptors in a Java-SE application and I am using weld as CDI implementation and i'm testing this here: The Main-Class: public static void main(String[] args) { WeldContainer weldContainer = new Weld().initialize(); Service service = weldContainer.instance().select(Service.class).get(); service.methodCall(); service.methodCallNumberTwo(); } The Service-Class: public class Service { @TestAnnotation public void methodCall(){ System.out.println("methodCall...!"); methodCallNumberTwo(); } @TestAnnotation public void methodCallNumberTwo(){ System.out.println("methodCallNumberTwo...

WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications

…衆ロ難τιáo~ 提交于 2019-11-29 04:35:06
I am using tomcat v7 with Weld v2.2.9.Final and myFaces v2.2.7 after restart server in eclipse IDE and reload page I getting this error. I have no clue why this error appear to me. It has to be connected with http request or so. If I open close browser it start work. SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.environment.servlet.Listener org.jboss.weld.exceptions.IllegalStateException: WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications at org

Why is the interceptor not called in the same service class?

一个人想着一个人 提交于 2019-11-28 07:44:39
问题 I want to use interceptors in a Java-SE application and I am using weld as CDI implementation and i'm testing this here: The Main-Class: public static void main(String[] args) { WeldContainer weldContainer = new Weld().initialize(); Service service = weldContainer.instance().select(Service.class).get(); service.methodCall(); service.methodCallNumberTwo(); } The Service-Class: public class Service { @TestAnnotation public void methodCall(){ System.out.println("methodCall...!");

How to disable WELD on WildFly

老子叫甜甜 提交于 2019-11-28 07:44:10
How to fully disable WELD on WildFly. I don't need it, because I use another DI framework. Exception 0 : javax.enterprise.inject.UnsatisfiedResolutionException: Unable to resolve a bean for 'org.springframework.data.mongodb.core.MongoOperations' with qualifiers [@javax.enterprise.inject.Any(), @javax.enterprise.inject.Default()]. at org.springframework.data.mongodb.repository.cdi.MongoRepositoryExtension.createRepositoryBean(MongoRepositoryExtension.java:104) at org.springframework.data.mongodb.repository.cdi.MongoRepositoryExtension.afterBeanDiscovery(MongoRepositoryExtension.java:79) at sun

WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications

流过昼夜 提交于 2019-11-27 18:32:03
问题 I am using tomcat v7 with Weld v2.2.9.Final and myFaces v2.2.7 after restart server in eclipse IDE and reload page I getting this error. I have no clue why this error appear to me. It has to be connected with http request or so. If I open close browser it start work. SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.environment.servlet.Listener org.jboss.weld.exceptions.IllegalStateException: WELD-000227: Bean identifier index

How to programmatically inject a Java CDI managed bean into a local variable in a (static) method

自作多情 提交于 2019-11-27 04:12:42
How can I programmatically inject a Java CDI 1.1+ managed bean into a local variable in a static method? To inject an instance of class C : javax.enterprise.inject.spi.CDI.current().select(C.class).get() This is available in CDI 1.1+ Use for instance this utility class . You basically have to obtain instance of BeanManager and than grab the bean you want from it (imagine something like JNDI lookup). Update You could also use CDI utility class offered in CDI 1.1 SomeBean bean = CDI.current().select(SomeBean.class).get(); @BRS import javax.enterprise.inject.spi.CDI; ... IObject iObject = CDI

How to disable WELD on WildFly

天涯浪子 提交于 2019-11-27 01:45:58
问题 How to fully disable WELD on WildFly. I don't need it, because I use another DI framework. Exception 0 : javax.enterprise.inject.UnsatisfiedResolutionException: Unable to resolve a bean for 'org.springframework.data.mongodb.core.MongoOperations' with qualifiers [@javax.enterprise.inject.Any(), @javax.enterprise.inject.Default()]. at org.springframework.data.mongodb.repository.cdi.MongoRepositoryExtension.createRepositoryBean(MongoRepositoryExtension.java:104) at org.springframework.data

How to programmatically inject a Java CDI managed bean into a local variable in a (static) method

℡╲_俬逩灬. 提交于 2019-11-26 12:26:33
问题 How can I programmatically inject a Java CDI 1.1+ managed bean into a local variable in a static method? 回答1: To inject an instance of class C : javax.enterprise.inject.spi.CDI.current().select(C.class).get() This is available in CDI 1.1+ 回答2: Use for instance this utility class. You basically have to obtain instance of BeanManager and than grab the bean you want from it (imagine something like JNDI lookup). Update You could also use CDI utility class offered in CDI 1.1 SomeBean bean = CDI