You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Gurkan Erdogdu (JIRA)" <ji...@apache.org> on 2011/01/06 09:55:45 UTC

[jira] Commented: (OWB-496) Don't replace the ProxyFactory classloaderProvider without the intention to do so

    [ https://issues.apache.org/jira/browse/OWB-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978230#action_12978230 ] 

Gurkan Erdogdu commented on OWB-496:
------------------------------------

Problem is that, 

In  JavasisstProxyFactory # public  ProxyFactory createProxyFactory(Bean<?> bean) throws Exception method, we add Serializable interface to the interface list. When Javassist would get ClassLoader, it executes the following statements in ProxyFactory

    protected ClassLoader getClassLoader0() {
        ClassLoader loader = null;
        if (superClass != null && !superClass.getName().equals("java.lang.Object"))
            loader = superClass.getClassLoader();
        else if (interfaces != null && interfaces.length > 0)
            loader = interfaces[0].getClassLoader();
 
        if (loader == null) {
            loader = getClass().getClassLoader();
            // In case javassist is in the endorsed dir
            if (loader == null) {
                loader = Thread.currentThread().getContextClassLoader();
                if (loader == null)
                    loader = ClassLoader.getSystemClassLoader();
            }
        }

        return loader;
    }

Here it looks interfaces[0] and it will be Serializable. Its classloader will be null. Therefore it gets classloader via getclass().getClassLoader(). It will be the server class loader if javassist.jar is located in server lib.

In Tomcat, we are getting ClassNotFoundException because, javassist.jar is located in tomcat/lib directory. That is the problem that I was trying to explain. 

I will add flag or SPI for this.

> Don't replace the ProxyFactory classloaderProvider without the intention to do so
> ---------------------------------------------------------------------------------
>
>                 Key: OWB-496
>                 URL: https://issues.apache.org/jira/browse/OWB-496
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Context and Scopes
>    Affects Versions: 1.1.0
>            Reporter: David Jencks
>            Assignee: Gurkan Erdogdu
>             Fix For: 1.1.0
>
>
> Currently JavassistProxyFactory.getProxyClass() replaces the ProxyFactory.classloaderProvider on any exception with a classloaderProvider that is very unlikely to work better than the default.  Setting the classLoaderProvider should be a matter of intentional configuration, not flailing around after an unexpected exception.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.