I'm using Websphere 8.5 and its internal Java EE frameworks, Apache OpenWebBeans for DI & Apache MyFaces for view. I also have a JAR with some beans annotated with "@Named" (so, they're OpenWebBeans managed beans). This JAR is in the "WEB-INF/lib" directory of my web application and in the application's classpath.
I was told that I should put a "beans.xml" file in every JAR that I want the CDI implementation to find and manage beans. I did just that (there's a "beans.xml" file in the "META-INF" folder of the application and in the same folder of the JAR) and everything works flawless in Tomcat 7 (I can access my beans on JSF pages, everything gets injected and resolved without any problems, etc). I'm running Tomcat with Apache Open Web Beans 1.2 and MyFaces 2.0 JARs inside the application's "WEB-INF/lib".
Now, the problem: in Websphere, with the same configuration (without the framework JARs inside the application's "WEB-INF/lib", just my bean's JAR) I get a NoClassDefFoundError referring to a JSF class, "javax.faces.component.behavior.Behavior" everytime I try to load a page (no page loads, btw). Bizarrely, when I remove all "beans.xml" files from the application and from the JAR, everything works as expected with JSF (except OpenWebBeans bean loading and management, of course, since there's no "beans.xml" present).
I searched everywhere for this problem and can't find any clue about it. I know that this class is avaliable to websphere, since I searched the server JARs and found it at "WEBSPHERE_INSTALL\plugins\javax.j2ee.jsf.jar" (and also because without the "beans.xml", this class is found and everything works properly), but I have no clue why this JAR isn't loaded when any"beans.xml" file is present in the application's classloader. Can somebody help, please?
WebSphere really needs a WEB-INF/beans.xml file in your WAR! Otherwise WAS doesn't 'activate' CDI. This is actually not required by the spec, bnd adding this file at least isn't forbidden. It will simply make all your classes in WEB-INF/classes CDI beans. Just having the META-INF/beans.xml in some jars around doesn't help.
That's the way WAS works, it's a minor thing once you know it. I didn't even bother to create a PMR ;)