You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2021/05/04 10:47:54 UTC
[myfaces-tobago] branch master updated: fix: avoid
NoClassDefFoundError with Spring
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 95cf00e fix: avoid NoClassDefFoundError with Spring
95cf00e is described below
commit 95cf00e465b571cd98372a741f0c6536db55f16c
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Tue May 4 10:25:42 2021 +0200
fix: avoid NoClassDefFoundError with Spring
---
.../tobago/internal/util/AuthorizationHelper.java | 43 +++++++++++++++-------
1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/AuthorizationHelper.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/AuthorizationHelper.java
index 7d488fc..3c97522 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/AuthorizationHelper.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/AuthorizationHelper.java
@@ -112,7 +112,7 @@ public class AuthorizationHelper {
}
private Annotation getSecurityAnnotation(final FacesContext facesContext, final UIComponent component,
- final String expression) {
+ final String expression) {
Annotation securityAnnotation = null;
if (cache.containsKey(expression)) {
@@ -181,16 +181,26 @@ public class AuthorizationHelper {
}
private Object getBean(final FacesContext facesContext, final String beanName) {
- BeanManager beanManager = (BeanManager) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap()
- .get(BeanManager.class.getName());
Object bean = null;
- for (final Bean<?> entry : beanManager.getBeans(beanName)) {
- if (bean == null) {
- bean = entry;
- } else {
- LOG.warn("Bean name ambiguous: '{}'", beanName);
+
+ try {
+ BeanManager beanManager = (BeanManager) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap()
+ .get(BeanManager.class.getName());
+
+ if (beanManager != null) {
+ for (final Bean<?> entry : beanManager.getBeans(beanName)) {
+ if (bean == null) {
+ bean = entry;
+ } else {
+ LOG.warn("Bean name ambiguous: '{}'", beanName);
+ }
+ }
}
+ } catch (NoClassDefFoundError e) {
+ // ignore - if there is no class BeanManager is in class path
+ } catch (Exception e) {
+ LOG.warn("Problem with getting bean from BeanManager", e);
}
if (bean == null) {
@@ -225,11 +235,18 @@ public class AuthorizationHelper {
}
private List<Method> findMethods(final Object bean, final String name) {
- final Class clazz;
- if (bean instanceof Bean) {
- clazz = ((Bean) bean).getBeanClass();
- } else {
- // XXX check if this works correctly with spring.
+ Class clazz = null;
+ try {
+ if (bean instanceof Bean) {
+ clazz = ((Bean) bean).getBeanClass();
+ }
+ } catch (NoClassDefFoundError e) {
+ // ignore - if there is no class Bean is in class path
+ } catch (Exception e) {
+ LOG.warn("Problem with getting bean from BeanManager", e);
+ }
+ // XXX check if this works correctly with spring.
+ if (clazz == null) {
clazz = bean.getClass();
}
final Method[] methods = clazz.getMethods();