hi rudy, @ #2: those parts are still on the todo-list for a 2nd refactoring (with the first refactoring we just merged the code of two code-bases). i would prefer [1] since it isn't a workaround.
regards, gerhard [1] https://github.com/os890/DS_Discuss/commit/8c625c8e72524d657aeb77e9913287c60af6b62f 2012/8/6 Rudy De Busscher <[email protected]> > Hi All, > > The integration tests on WebLogic 12C fails at the Security Impl Module. > There are 2 problems (see also DELTASPIKE-261 - Integration tests of > security impl module fails on Weblogic > 12c<https://issues.apache.org/jira/browse/DELTASPIKE-261>) : > > 1. ClassLoader issue > within the method > > *org.apache.deltaspike.security.impl.extension.SecurityExtension#getMetaDataStorage > *, the call *ClassUtils.getClassLoader(null);* doesn't results in the same > classLoader depending on the 'part' of the test. During deployment, you get > another one then during testing itself. This results in an empty > SecurityMetaDataStorage and the exception "*No matching authorizer found > for security binding type [@ ... *" > > <https://issues.apache.org/jira/browse/DELTASPIKE-261>2. beanManager issue > The *beanManager *supplied as parameter to the call > > *org.apache.deltaspike.security.impl.extension.SecurityExtension#processAnnotatedType > * doesn't have the registered beans. Since that beanManager is passed to > the *Authorizer*, the managed bean could not be retrieved in the method * > > org.apache.deltaspike.security.impl.extension.Authorizer#lazyInitTargetBean*. > It throws the exception *"Exception looking up authorizer method bean - no > beans found for method [ ..."* > > > I found solutions for both problems, but it requires some code specific for > wls12C (not dependent on wls12C dependencies but code that is only needed > and executed within wls12c) I know that is isn't very good but I can't see > any other solution to keep the integration tests running on WebLogic 12C. > > I no one raises a veto (-1) against the code, I'll commit it by the end of > the week. > > Any comments also appreciated of course. > > Regards > Rudy > > *1. Class Loader issue -> Try also the parent class loader to see If we > have an entry for that value.* > > --- > > a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/SecurityExtension.java > +++ > > b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/SecurityExtension.java > @@ -62,6 +55,12 @@ public class SecurityExtension implements Extension, > Deactivatable > > if (securityMetaDataStorage == null) > { > + securityMetaDataStorage = > tryParentClassLoaderOnWeblogic(classLoader, securityMetaDataStorage); > + > + } > + > + if (securityMetaDataStorage == null) > + { > securityMetaDataStorage = new SecurityMetaDataStorage(); > SECURITY_METADATA_STORAGE_MAPPING.put(classLoader, > securityMetaDataStorage); > } > @@ -69,6 +68,19 @@ public class SecurityExtension implements Extension, > Deactivatable > return securityMetaDataStorage; > } > > + private static SecurityMetaDataStorage > tryParentClassLoaderOnWeblogic(ClassLoader someClassLoader, > + SecurityMetaDataStorage > someSecurityMetaDataStorage) > + { > + // Within Oracle WebLogic 12C, during deployment, we get another > classloader then during the execution > + // of the application. > + if (someClassLoader.getClass().getName().startsWith("weblogic.")) > + { > + > + someSecurityMetaDataStorage = > SECURITY_METADATA_STORAGE_MAPPING.get(someClassLoader.getParent()); > + } > + return someSecurityMetaDataStorage; > + } > + > public static void removeMetaDataStorage() > { > ClassLoader classLoader = ClassUtils.getClassLoader(null); > > *2. beanManager issue -> A solution is looking in the beanManager retrieved > from the JNDI. * > > --- > > a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/Authorizer.java > +++ > > b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/Authorizer.java > @@ -133,9 +131,22 @@ class Authorizer > } > else if (beans.isEmpty()) > { > - throw new IllegalStateException("Exception looking up > authorizer method bean - " + > + // Try the BeanManager from JNDI. On WebLogic we have more > luck with that one > + beans = > > BeanManagerProvider.getInstance().getBeanManager().getBeans(method.getDeclaringClass()); > + if (beans.size() == 1) > + { > + boundAuthorizerBean = beans.iterator().next(); > + // Keep the reference to the other BeanManager here > for further lookups. > + beanManager = > BeanManagerProvider.getInstance().getBeanManager(); > + } > + else > + { > + > + throw new IllegalStateException("Exception looking up > authorizer method bean - " + > "no beans found for method [" + > method.getDeclaringClass() + "." + > method.getName() + "]"); > + } > + > } > else if (beans.size() > 1) > { >
