Sunday, March 4, 2012

openwebbeans on glassfish3 for jsf-applications

several users would like to use owb on glassfish3. if a full integration isn't needed and the only problem is an exception in jersey during the bootstrapping process, it's quite easy to work around it.

//for a partial integration in GlassFish3 in case of:
//java.lang.NullPointerException at com.sun.jersey.server.impl.cdi.CDIExtension.processAnnotatedField
public class JerseyAwareLoaderService extends DefaultLoaderService
{
@Override
public <T> List<T> load(Class<T> serviceType, ClassLoader classLoader)
{
List<T> result = super.load(serviceType, classLoader);
Iterator<T> resultIterator = result.iterator();
while (resultIterator.hasNext())
{
if (resultIterator.next().getClass().getName().startsWith("com.sun.jersey.server"))
{
resultIterator.remove();
}
}
return result;
}
}
//and in /MEAT-INF/openwebbeans/openwebbeans.properties activate it via:
configuration.ordinal=100
org.apache.webbeans.spi.LoaderService=org.os890.codi.addon.cdibridge.JerseyAwareLoaderService


you need the following owb modules:

- openwebbeans-impl
- openwebbeans-spi
- openwebbeans-web
- openwebbeans-jsf

attention: that isn't a full integration. as you see e.g. jersey can't be used with this workaround.