jboss-weld

Resolution of external (3rd party) beans in weld

I know it is still not quite popular, since the spec was released just a few months ago. I haven't "installed" weld yet, I'm just reading, and by this question I want to make sure I've understood this important point correct: Is resolution of beans that are in 3rd-party jars achieved by declaring them as <alternatives> in your beans.xm...

Differences between Java EE 6 CDI Implementations

I've looked at JBoss' Weld Reference Implementation of JSR-299 Contexts and Dependency Injection, and I wanted to know how others CDI implementations compare to each other. Specifically, I know about Weld, Resin CanDI (by Caucho), and Apache OpenWebBeans. ...

how to instantiate more then one CDI/Weld bean for one class ?

In Spring it was possible to instantiate any class by defining the corresponding bean in xml conf. It was also possible to instantiate more then one bean for the same class with different parameters..... Are the such features in CDI as well, namely is it possible to create different instances of the same class with different initializ...

hibernate fail mapping two tables

Hi guys, I'd like to understand how it is possible: Until I was working with one table everything worked fine, when I have mapped another table it fails as shown below: Glassfish start INFO: configuring from resource: /hibernate.cfg.xml INFO: Configuration resource: /hibernate.cfg.xml INFO: Reading mappings from resource : hibernate_ce...

Dependency Injection with @Inject in Weld (JSR-299 RI). How is the corresponding @Produces found?

I have played with the JSR-299 Reference Implementation "Weld" with the purpose of using it in a stand-alone application, and I have had a look at the documentation, and marveled at the magic. My question is how the producer of a given object to be @Inject'ed is found? Either the java compiler produces hints for annotations which is ea...

Google Guice vs. JSR-299 CDI / Weld

Weld, the JSR-299 Contexts and Dependency Injection reference implementation, considers itself as a kind of successor of Spring and Guice. CDI was influenced by a number of existing Java frameworks, including Seam, Guice and Spring. However, CDI has its own, very distinct, character: more typesafe than Seam, more stateful and less X...

Injecting logger, weld

Hi. I am trying to replace standard logger initialization by some injection 1-st. I was trying to use weld weld logging in stateless bean/webservices @Stateless @WebService public class EchoSSL { @Inject private Logger log; public EchoSSL() { } public String echo(String msg) { log.debug("Log test"); ...

JSF 2.0: use Enum values for selectOneMenu

I'm using JSF 2.0 and want to fill a selectOneMenu with the values of my Enum. A simple example: // Sample Enum public enum Gender { MALE("Male"), FEMALE("Female"); private final String label; private Gender(String label) { this.label = label; } public String getLabel() { return this.label; } } Unfortunately, ...

Are @ManagedBean's obsolete in JavaEE6 - because of @Named in CDI/Weld?

Because of CDI (and its implementation Weld), every POJO in JEE6 can be annotated with @Named, which makes the POJO accessible to the view. Does that mean that ManagedBeans are completely obsolete now? Or do i miss something where @ManagedBean still makes sense? ...

CDI timeout results in an NPE

Is there a way (in JSF 2) to catch a Conversation timeout and redirect a user to a new page? I'm getting nasty NullPointerExceptions when the conversation times out. I could redirect the user on all NPE's, but that seems like too big a net. ...

How to inject a non-serializable class (like java.util.ResourceBundle) with Weld

I want to create a Producer that makes it possible to inject a java.util.ResourceBundle into any class in order to get localized Strings easily. My ResourceBundle-Producer looks like this: public class ResourceBundleProducer { @Inject public Locale locale; @Inject public FacesContext facesContext; @Produces p...

Where should I declare my CDI resources?

JSR-299 (CDI) introduces the (unfortunately named) concept of a resource: http://docs.jboss.org/weld/reference/1.0.0/en-US/html/resources.html#d0e4373 You can think of a resource in this nomenclature as a bridge between the Java EE 6 brand of dependency injection (@EJB, @Resource, @PersistenceContext and the like) and CDI's brand of dep...

How to cascade dependency resolution w/ CDI (WELD)

I would like to have a central weld container that holds all my services and so on. This container would however be wrapped by a second container which contains local settings. The goal is if a dependency cannot be found in the outer container then I would like to then search the inner container. How can I achieve this? I would prefer t...

Is there an equivalent in CDI(WELD) to build definitions (as done in Guice modules) and then create an Injector ?

I like the way Guice makes it fairly straight forward to manually create your own modules each with their own bindings done in code. CDI on the other hand seems to rely more on magic rather than programmatic access to sest bindings. Am i wrong or how can one achieve the same effect with WELD. Any code sample would be appreciated... CLA...

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 ...

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...

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...

Weld injection failing when calling a method from an super/abstract class with Wicket.

Hi all. I am having a problem with weld-wicket. When @Inject-ing an EJB that inherits from an abstract class, if I attempt to call a method from the abstract class I get an ejb-ref error. However if I call a method from the concrete class it works perfectly. I can override methods and call them, and I can delegate an overridden method ...

Running a very simple Weld SE project in Eclipse

I've been using Seam 2 (also started looking into Java EE 6) in my web apps and a couple of days ago I found out that Seam's CDI can be leveraged in an SE application with Weld. According to Weld's Documentation page for Weld SE the setup is trivial. So I tried to setup an Eclipse project with a single class HelloWeld, weld-se.jar and th...

"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...