cdi

integrating GWT with CDI (Seam/Weld)

倖福魔咒の 提交于 2019-12-12 20:30:24
问题 What's the best way to integrate CDI with GWT? In particular, I'd like to know how to make dependency injection work for my RemoteServiceServlet extensions. Apparently CDI won't work with classes derived from javax.servlet.Servlet. I'm happy to ditch RemoteServiceServlet if there is an alternative. I don't really need DI on the GWT client-side, but would happily use it if it Just Worked. 回答1: It turns out to be a bug in Weld, which is already fixed in version 1.1.0. Intellij IDEA X also has

AJAX pages with CDI beans and @ConversationScoped

和自甴很熟 提交于 2019-12-12 19:39:34
问题 I'm interested What is the proper way to use JSF pages with AJAX when I use CDI. I tested to configure the CDI beans with @SessionScoped but I found that there is a problem with AJAX. Is it proper to use AJAX with CDI beans configured with @ConversationScoped ? And I found that I have to put conversation.begin(); into the Bean constructor and conversation.end(); into Java method which must be when the session is completed. Can I somehow do this automatically? P.S Can I use this code to

Can we share CDI @ApplicationScoped bean instance accross web application in the same EAR?

ぐ巨炮叔叔 提交于 2019-12-12 18:28:17
问题 I have an JavaEE Application that has 2 web applications. I also have another library web module that contains common_bean that annotated by @ApplicationScoped My question is: Can I share common_bean instance across the two web applications? Updated - I did the test In Web App1 (/web1) @WebServlet("/Servlet1") public class Servlet1 extends HttpServlet { @Inject CommonBean commonBean; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,

@PostConstruct Interceptor with @Named @ViewScoped not invoked

十年热恋 提交于 2019-12-12 17:22:53
问题 I have read carefully the article about Interceptors in the Seam/Weld documentation and implemented a InterceptorBinding : @InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE}) public @interface MyLog {} and a Interceptor class: @MyLog @Interceptor public class ErpLogInterceptor implements Serializable { @AroundInvoke public Object logMethodEntry(InvocationContext invocationContext) throws Exception {..} @PostConstruct public Object

How to get CDI in war AND EJB running if both are bundled in an EAR

会有一股神秘感。 提交于 2019-12-12 17:15:26
问题 I'm trying to build an enterprise application which is assembled in an EAR. This application should contain one or more ejb-jars and one or more war 's. I want to make heavily use of CDI , Interceptors and Producers. In the first step I want to use a Log-Producer which is placed in the ejb-jar in all areas of the application. What I did is creating a beans.xml in the ejb/META-INF and the war/WEB-INF/ folders. Creating the EAR works. But deploying to the Glassfish Server (3.1) fails with a

TomEE + CXF configuration reference

混江龙づ霸主 提交于 2019-12-12 15:48:31
问题 So I was trying to find any reference documentation or non-trivial examples for using the three. The 'best' I found was: TomEE/OpenEJB JAXRS refactoring Some tips for TomEE and JAXRS config The TomEE Documentation doesn't list Jax-RS at all, and I was only able to find some examples consisting of a single endpoint class Where can I find a comprehensive reference of configuration options? The main problem is that I'd know how to do most of the things I want when using standalone CXF, but I

Flow scope navigation to start page does not work

别来无恙 提交于 2019-12-12 14:21:57
问题 It is not so much a question, more of a note. With Glassfish4, in a JEE7 application I tried to use the flow scope using programmatic flow definition (java class annotated with @Produces @FlowDefinition). I navigated to the start page of the flow with a h:commandButton (just as it is done in the JEE7 tutorial example https://svn.java.net/svn/javaeetutorial~svn/trunk/examples/web/jsf/checkout-module. When I pressed the button it stayed on the same page, where the button was, instead of going

How to inject ConversationScoped beans in a Servlet

雨燕双飞 提交于 2019-12-12 12:16:43
问题 I need to inject a ConversationScoped bean into a servlet. i use the standard simple @Inject tag and I invoke the servlet with the cid parameter but when it invokes any method in the injected bean I get the following error: org.jboss.weld.context.ContextNotActiveException : WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped Can I inject these beans in servlets or I can inject only Session and Request scoped beans? 回答1: In a servlet the context is

How to tell PMD to ignore @PostConstruct Methods for unused Code

吃可爱长大的小学妹 提交于 2019-12-12 11:39:36
问题 we have a project which is checked by PMD for violations of e.g. unused private methods. Our problem is that we don't know if it is possible to ignore private Methods which are annotated with @PostConstruct . The rule is defined as following: <rule ref="rulesets/java/unusedcode.xml/UnusedPrivateMethod"/> Edit: My goal is to define it once to ignore annotated methods. I would like to prevent writing @SupressWarnings on every method. 回答1: With the hint and advice from HairyFotr i was able to

How to stack custom annotation in Java with @Inject annotation

吃可爱长大的小学妹 提交于 2019-12-12 10:02:25
问题 I saw this several times when browsing.. people are using @Inject annotation with their own to inject EntityManager like this: @Inject @MyEm EnityManager em; because you cannot just inject the EntityManager . You can do it only with @PersistenceContext . Does anybody know how to make this work (with the custom annotation), because I didn't find any information on the net? Give a example if you can, please. 回答1: Basically what you need to do is create a discriminator annotation and use it in