Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Fix for CDI Component Initialization on IBM WebSphere 8.5.5.12 Update #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* @author robc
*/
public class CDIComponentProviderFactoryInitializer {

private static final Logger LOGGER = Logger.getLogger(CDIComponentProviderFactoryInitializer.class.getName());

private static final String BEAN_MANAGER_CLASS = "javax.enterprise.inject.spi.BeanManager";
Expand All @@ -73,8 +73,15 @@ public static void initialize(WebConfig wc, ResourceConfig rc, WebApplication wa
return;
}

rc.getSingletons().add(new CDIComponentProviderFactory(beanManager, rc, wa));
LOGGER.info("CDI support is enabled");
// Captures CDI bean errors on WebSphere Application Server 8.5.5.12 fixpack
// See: APR PI66630 UnsatisfiedResolutionException thrown in non-CDI environment
try{
rc.getSingletons().add(new CDIComponentProviderFactory(beanManager, rc, wa));
LOGGER.info("CDI support is enabled");
}catch(ClassCastException ex)
{
LOGGER.log(Level.CONFIG, "The CDIComponentProviderFactory failed to initialize", ex);
}
}

private static Object lookup(ServletContext sc) {
Expand Down Expand Up @@ -118,7 +125,7 @@ private static Object lookupInJndi(String name) {

LOGGER.config("The CDI BeanManager is at " + name);
return beanManager;

} catch (NamingException ex) {
LOGGER.log(Level.CONFIG, "The CDI BeanManager is not available at " + name, ex);
}
Expand Down