On Wed, Apr 18, 2018 at 11:53 AM, tomask79 <tomas.klou...@embedit.cz> wrote:

> Hi Martin,
>
> "Here it is not very clear what exactly is the change. One has to diff it
> agaisnt the original code to see what you have added/removed. "
>
> I added following:
>
> clazz = Class.forName(type, false, this.getClass().getClassLoader());
> if (clazz == null) {
> throw Exception...
>
> I need to force the framework to use the application
> classloader...different
> to currentThread's classloader...
>
> "You can use custom IClassResolver, no ?
> One that does whatever WebLogic needs to resolve the class and don't break
> or return null. "
>
> Unfortunatelly Wicket's classResolver won't help you, because we've got a
> problem during HTTP session serialization which isn't Wicket's application
> thread....
>
> if (Application.exists())
>                          {
>                                  resolved = (Class<T>)Application.get()
>                                          .getApplicationSettings()
>                                          .getClassResolver()
>                                          .resolveClass(className);
>                          }
>
> This is skipped...and Wicket goes here...
>
>  if (resolved == null)
>                          {
>                                  resolved =
> (Class<T>)Class.forName(className, false,
>  Thread.currentThread() .getContextClassLoader());
>                          }
>
>
> which ends with ClassNotFoundException when having @SpringBean in
> WebSession
> and If WLS doesn't have ChangeAware classloader bindided to thread.
>
> Suggested changes:
>
> 1) Either to change:
>
> static class ProxyReplacement implements IClusterable {
>          private static final long serialVersionUID = 1L;
>          private final IProxyTargetLocator locator;
>          private final String type;
>
>          public ProxyReplacement(String type, IProxyTargetLocator locator)
> {
>              this.type = type;
>              this.locator = locator;
>          }
>
>          private Object readResolve() throws ObjectStreamException {
>              Class<?> clazz = WicketObjects.resolveClass(this.type);
>              if (clazz == null) {
>                  clazz = Class.forName(type, false,
>  this.getClass().getClassLoader());
>                  if (clazz == null) {
>                       ClassNotFoundException cause = new
>  ClassNotFoundException("Could not resolve type ["
>                       + this.type + "] with the currently configured
>                        org.apache.wicket.application.IClassResolver");
>                         throw new WicketRuntimeException(cause);
>                 }
>              } else {
>                  return LazyInitProxyFactory.createProxy(clazz,
>  this.locator);
>              }
>          }
>      }
>
> 2) Another possible fix (WicketObjects):
>
> public static <T> Class<T> resolveClass(final String className)
>         {
>                 Class<T> resolved = null;
>                 try
>                 {
>                         if (Application.exists())
>                         {
>                                 resolved = (Class<T>)Application.get()
>                                         .getApplicationSettings()
>                                         .getClassResolver()
>                                         .resolveClass(className);
>                         }
>
>                         if (resolved == null)
>                         {
>                                 resolved = (Class<T>)Class.forName(className,
> false,
> WicketObjects.class.getClassLoader());
>                         }
>                 }
>                 catch (ClassNotFoundException cnfx)
>                 {
>                         log.warn("Could not resolve class [" + className +
> "]", cnfx);
>                 }
>                 return resolved;
>         }
>
> Both changes have the same effect...Please would you be willing to
> propagate
> this into the patch?
>

The Thread context classloader and the one that loaded the class is not
always the same.
I'd rather add yet another "if (class == null)
{tryWithWicketObjectsClassClassLoader}" after trying with the thread
context loader.

WebLogic (like WebSphere) are rather exotic application servers and they
are known for not following the standards.
I don't want to break any other application that works fine on *normal*
servers.

Please test my suggestion and send a PR, or at least open a ticket in JIRA.


>
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-
> f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to