cdi

Weld on WebSphere 8

余生颓废 提交于 2019-12-14 01:29:10
问题 Is it possible to replace WebSphere 8's CDI provider (OpenWebBeans) with Weld? Failing that, is there any way to simply disable CDI altogether in WebSphere? Why would I need this? We have a project that was developed against Weld, and unfortunately we've found that it relies on a number of Weld idiosyncrasies. We're able to successfully bootstrap Weld via org.jboss.weld.environment.servlet.Listener in Tomcat and Jetty, but WebSphere's built-in CDI implementation seem to be interfering. 回答1:

cdi produce method ignored

亡梦爱人 提交于 2019-12-13 21:59:20
问题 I am trying get properties from a application.properties file using cdi injection. My producer method is never called when my fields are used. So they are always null.What am I missing , doing wrong ? Here is my producer class: propertyProducer import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi

Java CDI interceptor not working web application with WELD

徘徊边缘 提交于 2019-12-13 19:09:43
问题 I have created a web application which uses Weld-2.2.0 CDI implementation and runs on Tomcat-7. I have created an interceptor to log method calls. But when i run the application, it bypasses interceptor and calls method directly. My interceptor constructs are as below: Interceptor Binding: @Inherited @InterceptorBinding @Retention(RUNTIME) @Target({METHOD, TYPE}) public @interface LogMe{ } Interceptor class: @LogMe @Interceptor public class LogInterceptorImpl { private static final Logger log

Referencing a CDI Bean in a non managed CDI Bean

佐手、 提交于 2019-12-13 16:14:33
问题 Is it possible to obtain an instance of a CDI bean inside a class that is created using the new keyword? We're currently making some enhancements on an old application, and we're always getting a ContextNotActiveException everytime we do a programmatic lookup on CDI Singleton beans in our app. Code for obtaining a reference: public class ClassCreatedWithNew{ public void doSomething(){ MySingletonBean myBean = BeanManagerSupport.getInstance().getBean(MySingletonBean.class); } }

CDI Transactional Interceptor not working

拥有回忆 提交于 2019-12-13 15:23:57
问题 I have a Java SE application with these classes: main: public static void main(String args[]) { Weld weld = new Weld(); WeldContainer container = weld.initialize(); ShopCar sc = container.instance().select(ShopCar.class).get(); sc.execute(); weld.shutdown(); } My DAO(not fully implemented): /** * * @author vFreitas * @param <T> The type T */ public class JpaDAO<T> implements DAO<T>, Serializable { /* The EntityManager of my connection */ private final EntityManager em; /* The class to be

Can I use EJB Stateless Bean with CDI to maintain user session?

强颜欢笑 提交于 2019-12-13 15:12:00
问题 Based on this post http://www.adam-bien.com/roller/abien/entry/ejb_3_1_killed_the I use in my app @Named @Stateless bean for communication with a database (injecting EntityManager here) and display information on a jsf page. It's great facilitation since Java EE 5, but I have one question. Is it secure to use such beans for maintaining a user session (shopping cart etc)? I read a book about ejb 3.0 and I know that the same stateless bean could be used with many clients. What's the best

CDI injection not resolved inside a Jackson Serializer

最后都变了- 提交于 2019-12-13 14:19:27
问题 I'm trying to inject a @RequestScoped object class in a Jackson's JsonSerializer<> : public class DigitalInputSerializer extends JsonSerializer<DigitalInput> { @Inject private UserRequestResources user; @Override public void serialize(DigitalInput value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException { gen.writeStartObject(); gen.writeStringField("user", this.user.getMe().getUser()); On the last line, this.user is null . @RequestScoped public

Using CDI Injection in a Servlet

我们两清 提交于 2019-12-13 12:25:35
问题 I am attempting to @Inject a @SessionScoped bean into a Filter @WebFilter("/*") public class IdentityFilter implements Filter, Serializable { @Inject private LoginUser loginUser; ... where LoginUser is @SessionScoped The intention is for loginUser to represent the logged in user for the session. The problem is it appears that I am not always getting the loginUser from the current session, I am getting 'leakage' between sessions as one session's LoginUser object is being shared with another

OSGi: javax.annotation conflict: Java SE vs Java EE

微笑、不失礼 提交于 2019-12-13 07:35:47
问题 In a Java SE OSGi (Apache Felix) environment, I'm trying to integrate CDI using PAX CDI and Weld 2.2.6.Final. I'm currently getting the following error: ERROR: Bundle org.jboss.weld.osgi-bundle [45] Error starting file:///someDir/org/jboss/weld/weld-osgi-bundle/2.2.6.Final/weld-osgi-bundle-2.2.6.Final.jar (org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve bundle revision org.jboss.weld.osgi-bundle [45.0] because it is exposed to package 'javax.annotation' from

How to use @Alternative extending a concrete class, in a webapp?

自闭症网瘾萝莉.ら 提交于 2019-12-13 07:08:20
问题 I'm trying to disable 2 observer methods of a class which is in a beans archive jar (more specifically, the class LoginListener of Seam 3 Faces module), and use mines instead. I have a web project, with a beans archive in it : app.war \- WEB-INF \- lib \- seam-faces-3.1.0.Final.jar |- my-beans.jar In my-beans.jar I've got that class : @Alternative public class MyLoginListener extends LoginListener { @Override public void observePostLoginEvent(final PostLoginEvent event) { } @Override public