Skip to content

Commit

Permalink
Improve #4933: CDI#getBeanManager() should be last thing after JNDI as
Browse files Browse the repository at this point in the history
JNDI can be configured app-wide while CDI#current() is server-wide
  • Loading branch information
BalusC committed May 23, 2021
1 parent 47c87ce commit 98189be
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions impl/src/main/java/com/sun/faces/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -1559,20 +1559,20 @@ public static BeanManager getCdiBeanManager(FacesContext facesContext) {
result = (BeanManager) facesContext.getExternalContext().getApplicationMap().get(RIConstants.CDI_BEAN_MANAGER);
} else {
try {
CDI<Object> cdi = CDI.current();
result = cdi.getBeanManager();
InitialContext initialContext = new InitialContext();
result = (BeanManager) initialContext.lookup("java:comp/BeanManager");
}
catch (Exception | LinkageError e) {
catch (NamingException ne) {
try {
InitialContext initialContext = new InitialContext();
result = (BeanManager) initialContext.lookup("java:comp/BeanManager");
result = (BeanManager) initialContext.lookup("java:comp/env/BeanManager");
}
catch (NamingException ne) {
catch (NamingException ne2) {
try {
InitialContext initialContext = new InitialContext();
result = (BeanManager) initialContext.lookup("java:comp/env/BeanManager");
CDI<Object> cdi = CDI.current();
result = cdi.getBeanManager();
}
catch (NamingException ne2) {
catch (Exception | LinkageError e) {
}
}
}
Expand Down

0 comments on commit 98189be

Please sign in to comment.