users@glassfish.java.net

Re: CDI standard extensions: supported yet?

From: <glassfish_at_javadesktop.org>
Date: Mon, 12 Jul 2010 17:09:47 PDT

> Actually, I'm surprised that it works at all.

Me too. :-D

> META-INF/services is poor man's service registry that
> only works well in a Java SE classpath and is
> notoriously hard to use in multi-classloader
> environments like OSGi or Java EE.

And yet it is a requirement of the JSR-299 specification that it be present for portable extensions, and the Java EE 6 specification does not amend this specification in any way. Yes, I agree with you; it's all rather fragile.

> Given that CDI is implemented as an OSGi bundle
> within the container and your extension lives in your
> web app,

(Well, to be fair, that was the pilot error: I moved the portable extension into a library jar that now resides in my ear file's lib directory. It is now invoked and things are injected properly and all that. However, this (as always) leads to another problem, which I'll describe shortly.)

So my current problem is that my CDI portable extension--though instantiated and called at all the right moments--cannot actually "see" anything useful. I'll explain.

My portable extension has an afterDeploymentValidation() method that accepts a BeanManager. The JSR 299 specification indicates that this method is called after a successful deployment, and I can verify that this method is indeed called.

In that method, I ask the BeanManager to give me every single bean it knows about, like this:

[code]
final Set<Bean<?>> beans = beanManager.getBeans();
[/code]

The results I get back do not include the EJBs that are located in my .ear file.

I looked through the JSR 299 specification and the Java EE 6 specification, and neither [i]seems[/i] to indicate whether this is a reasonable thing or not.

What I'm [i]trying[/i] to do is get programmatically notified by Weld upon each successful deployment of every EJB in my ear file. I can't seem to make this work. Does anyone know if this is possible? I see no reason that it shouldn't be.

(My new development cycle seems to be: code, test, deploy, scratch head, post forum message, wait two days, file bug report, repeat.... :-) Pretty good-natured about all this, though; at least this isn't JBoss.)

Best,
Laird
[Message sent by forum member 'ljnelson']

http://forums.java.net/jive/thread.jspa?messageID=477416