cdi

CDI - conditional installation

Hi all, I have several components which are application scoped. Depending on which environment I am in, I want to install one or the other. In JBoss Seam, I would use @Install(false), then configure the bean that I wanted through components.xml. Is there a similar method for doing this in CDI / WELD? Thanks, Walter ...

Hibernate - CDI

I have a few Hibernate Envers listeners which I use for audit purposes. I am just getting started on CDI and so far am pleasantly surprised by its simplicity and power. Since it seems everything is integrating CDI functionality, I thought I'd raise the question, is Hibernate supporting it or will it? Not only would it be nice to have ...

CDI - handling errors

Hi all, I am migrating my Seam 2 powered application to CDI and one of the things that is critical for me to retain is the error handling. In Seam 2, I simply replaced the default exception handler with my own, but in CDI, I am guessing I'll have to use an Interceptor. How would I set this up as using an Interceptor requires me to spe...

CDI not working in ear deployed to glassfish v3.0.1

I have some problem with using weld logger injection. Scenario: I have ear with ejb-jar inside. This is my ejb bean: @Stateless @LocalBean public class PartnersService { @Inject Logger log; @PersistenceContext(unitName = "Utopia") EntityManager em; public PartnersService() { } public OasysPartnerEntity g...

CDI with ejb 3.1 , weld-logger on glassfish v3.0.1

Scenario: 1) create maven ear project, create war project inside 2) add beans.xml to war project`s WEB-INF/ 3) creat simple @Steateless bean project - http://drp.ly/1j5C3t ejb bean : @Stateless @LocalBean public class TestEjb { @Inject Logger log; public TestEjb() { } @Schedule(hour = "*", minute = "*", secon...

<h:dataTable> and SessionScoped beans

Hi all! Problem: searching for some more suitable design . Goal: I want to have table of some user information and with button "change password" in column for each user, after click : "change password" button disappeared (rendered ="false") and a inputSecreat field appeared - user entering the password and submitting it (by clicking ...

How to avoid ConcurrentModificationExceptions when using EJB3.1 @Asynchronous.

[My Setup: Java EE 6 application, with EJB3.1, CDI/Weld, JSF2 running on Glassfish 3.0.1] I read some articles about the new @Asynchronous methods in EJB3.1, but none of them mentioned the dangers of asynchronous methods and what you really have to care about. In my app i'm having an @Asynchronous E-Mail service, sending lots of mails...

JEE6: Switching to CDI - Best resources

I have a small yet complete JEE 6 application at hand. The traditional annotations are being used: @Resource, @EJB, @Singleton, @PostConstruct, @PreDestroy, @PersistenceContext, @ManagedBean, @ManagedProperty, @RequestScope, @ApplicationScope,... I would like to evaluate whether it makes sense to introduce CDI, and to standardize ...

Why use @PostConstruct ?

In a managed bean, @PostConstruct is called after the regular Java object constructor. Why would I use @PostConstruct to initialize by bean, instead of the regular constructor itself? ...

How conversation scope in implemented in CDI?

It is done through some session key that holds some structure? ...

JSF 2 localization (managed bean)

I have a properties file for localization: foo=Bar title=Widget Application This is tied in as a resource-bundle in the faces-config: <resource-bundle> <base-name>com.example.messages.messages</base-name> <var>msgs</var> </resource-bundle> I can access this just fine in the facelets view using EL: <title>#{msgs.title}<...

"Unable to convert ejbRef for ejb" on CDI (Weld) injection of @Stateless EJB into @SessionScoped JSF2 bean in Glassfish

[UPDATE: After discussion on the Glassfish forums/ML at http://forums.java.net/jive/thread.jspa?messageID=480532 a bug was filed against Glassfish https://glassfish.dev.java.net/issues/show_bug.cgi?id=13040 for this issue.] I'm trying to inject a local no-interface view of a @Stateless EJB into a JSF2 @Named @javax.enterprise.context.Se...

Can you get jboss weld to continually scan for newly added classes during development?

hi. i'm setting up a JSF2 project on tomcat 6.0.29 with weld. also using jrebel - not sure if that makes a difference. In testing out JRebel i can see that updating classes that existed when the container was started are handled fine. however, if i ADD a newly defined CDI component class and re-explode the app without restarting the a...

CDI - Observing Container Events

Hi all, I am trying to observe both the startup and shutdown events for a CDI web application. I have an ApplicationScoped bean that listens for those events: @ApplicationScoped public class PrettyfacesStartupObserver { private static final Log LOGGER = LogFactory.getLog(PrettyfacesStartupObserver.class); public PrettyfacesSt...

GlassFish, CDI and Constructor Injection

Is constructor injection supported in GlassFish 3.1's implementation of CDI for managed beans? I have a @Singleton EJB into which I want to inject another managed bean (contained in the same EJB module) using constructor injection. Field injection does work. But with constructor injection I get a NullPointerException from AbstractSinglet...

Embedded Glassfish - EJB 3.1 - @Schedule

Hi all, I am new to Java EE 6 and working on getting a number of demo applications running finally. I have an application scoped bean that has a @Schedule annotation on it that should in theory trigger that method every minute. However, that method doesn't appear to ever be invoked. It simply writes to the logs that it was called. C...

Can CDI be lessened towards JSE?

JSR-330 dependency injection can be applied to both JSE and JEE environments, while JSR-299 is titled "Contexts and Dependency Injection for the Java EE platform". Except strictly JEE-oriented features, what CDI features make sense on JSE either? Any examples available? Thanks! [Revised] Here's Weld on JSE. ...

CDI - Event Observers

Hi all, I have event observers which all observe the same event, so I have an abstract superclass which observes that event and then the subclass overrides / implements the specific functionality. The problem with this is that it doesn't observe the event unless I put the event observer method in the subclass (which defeats the purpose...

How JEE6 makes the link between Observer and Observee (Observer Pattern)

Hello, I've read some blog articles about Observer pattern implementation on JEE6 and something bother me... I can't find any information atm so i ask there... I've found the following exemples: @Stateless [...] public class ParisJugService { @Inject Event event; public void helloParis(){ System.out.println("Hello P...

CDI injectionpoint @httpparam problem

I follow the Weld's doc in the section 4.11. The InjectionPoint object There is a very interesting example about how to obtain the http parameter using CDI but i copy-pasted the code into netbeans, everything compiles, but has an deployment error Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Injection point ...