Stefan created WICKET-4663:
------------------------------

             Summary: LazyInitProxyFactory uses wrong ClassLoader in OSGi 
environment
                 Key: WICKET-4663
                 URL: https://issues.apache.org/jira/browse/WICKET-4663
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5.7
            Reporter: Stefan


The method LazyInitProxyFactory#createProxy use 
Thread.currentThread().getContextClassLoader() to create a new proxy instance. 
It seems that this is not correct in an OSGi environment.

Preferred is to use the ClassLoader provided by the AbstractClassResolver class 
(getClassResolver is not part of IClassResolver). 

Then it will be something like:

                        ClassLoader classLoader;
                        if (Application.exists())
                        {
                                AbstractClassResolver classResolver = 
(AbstractClassResolver) Application.get()
                                        .getApplicationSettings()
                                        .getClassResolver();                    

                                classLoader = classResolver.getClassLoader();
                        }
                        else
                        {
                                classLoader = 
Thread.currentThread().getContextClassLoader();
                        }
                        
                        try
                        {
                                return Proxy.newProxyInstance(classLoader, new 
Class[] { type, Serializable.class,
                                                ILazyInitProxy.class, 
IWriteReplace.class }, handler);
                        }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to