jboss-weld

Using CDI instead of @ManagedBean: UnproxyableResolutionException because super class has no no-args constructor

ε祈祈猫儿з 提交于 2019-12-05 05:12:20
I'm trying to use CDI for my JSF/Java EE application. I have the following class hierarchy: /** * base controller class * also contains some final methods and an inner enum class declaration */ public abstract class AbstractCrudController<K, E> implements Serializable { private Class<E> entityClass; public AbstractCrudController(Class<E> entityClass) { this.entityClass = entityClass; } // ... } import javax.enterprise.context.SessionScoped; import javax.inject.Named; @Named @SessionScoped public class CategoryController extends AbstractCrudController<Long, Category> implements Serializable {

Are CDI event observer methods compatible with EJBs?

妖精的绣舞 提交于 2019-12-05 03:39:47
I have a Singleton EJB (javax.ejb.Singleton version. sigh.) which has a CDI observer method on it. When I try to deploy this to glassfish 3.1 the server fails to deploy the EAR file without any real explanation - simply saying there was an exception during deployment without any more details. SEVERE: Exception while loading the app SEVERE: Exception while shutting down application container .... SEVERE: Exception while shutting down application container : java.lang.NullPointerException This is the CDI event listener : public void updateFromGranule(@Observes @CloudMask GranuleAvailableEvent

CDI - what is the correct bean.xml format?

隐身守侯 提交于 2019-12-05 01:50:22
I have a question about the correct format and usage of the bean.xml file. In my projects I typically used this content for my bean.xml files (no explizit bean declaration used): <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> </beans> This works well in WildFly 8 and 9. But I have deployment issues in GlassFish 4. In the question: Glassfish 4, simple example in CDI fails with WELD-001408

Richfaces 4 a4j:commandLink action not firing in rich:popupPanel

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 00:24:10
问题 I seem to be having a problem where I have an a4j:commandLink on a rich:popupPanel but the action is not firing. The xhtml looks as follows: <rich:popupPanel id="rate-panel" modal="true" height="444" width="780" top="60" show="false" onmaskclick="#{rich:component('rate-panel')}.hide()" styleClass="cs-modal"> /**Some html here**/ <a4j:commandLink immediate="false" action="#{venueScore.up}" render="rate-panel" styleClass="rate love"> <span>Love it</span> </a4j:commandLink> /**Some more html

CDI lifecycle of bean, @Inject and params

荒凉一梦 提交于 2019-12-04 22:02:32
The view and bean were working until I tried to fix non-standard names, and I've now broken the connection between the two. Oddly, the "back" button has the correct link, but content just doesn't show, nor log. Why doesn't Detail.getComments() execute? I've been going through the weld docs and trying to better understand @Inject. There seems to be a lifecycle problem which I don't understand, either. If it's not lifecycle, then I cannot even speculate as to why Detail.getComments() never shows in the glassfish logs: INFO: MessageBean.getModel.. INFO: SingletonNNTP.returning messages.. INFO:

Jetty: adding <resource-env-ref> programmatically

落爺英雄遲暮 提交于 2019-12-04 18:23:58
I have a standalone application with embedded Jetty and Wicket. I'd like to use CDI for injection. So I've found http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#d0e5286 and now I'm trying to add this programatically, but it's quite complex. How do I code that? Other sources I've found are: http://osdir.com/ml/java.jetty.support/2007-02/msg00198.html http://docs.codehaus.org/display/JETTY/JNDI So far I have: Server server = new Server( 8080 ); Context ctx = new Context( server, "/", Context.NO_SECURITY | Context.SESSIONS ); try { //BeanManager new org.mortbay.jetty.plus

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

Is there a way to know if a state is active without catching ContextNotActiveException?

眉间皱痕 提交于 2019-12-04 13:03:40
问题 I would like to know if the RequestScoped context is currently active in a method or not. At the moment, here is what I do : @Inject private BeanManager beanManager; public boolean isRequestScopeActive() { try { if (beanManager.getContext(RequestScoped.class).isActive()) { return true; } else { return false; } } catch (final ContextNotActiveException e) { return false; } } I think it's a bit heavy to catch a ContextNotActiveException just to know if a scope is active or not. Do you have any

How to test EJB method call with Arquillian Weld EE Embedded

我的梦境 提交于 2019-12-04 12:02:28
I would like to test an EJB, and I want to test it with Weld EE Embedded as I don't want to deploy an applicatoin server for that. Here is my class : @RunWith(Arquillian.class) public class EJBTest { @Deployment public static JavaArchive createTestArchive() { return ShrinkWrap .create(JavaArchive.class, "test.jar") .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")); } @Stateless public static class SomeService { public String someMethod() { return "test"; } } @Inject SomeService someService; @Test public void testStatelessCall() { Assert.assertEquals("test",

what is the purpose of including empty beans.xml in CDI implemenations projects?

对着背影说爱祢 提交于 2019-12-04 09:51:36
I am using weld ,a RI of CDI as dependency injection component in my JSF-EJB-JPA web app. I see in my project we have empty beans.xml in META-INF/beans.xml in ejb.jar and WEB-INF/beans.xml in my WAR. I don't get it why we need to keep empty beans.xml when there nothing defined in that file? CDI needs to scan all the classes of a bean archive at start-up and fire a bunch of events because almost any class is automatically a managed bean (read more here ), even if it doesn't have any annotations. This would incur quite a bit of overhead, especially for jar files that are not meant to have any