You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Surjit Sen (JIRA)" <ji...@apache.org> on 2007/01/03 17:13:27 UTC

[jira] Created: (BETWIXT-57) Class loader problem in JBoss version 4.0.4GA

Class loader problem in JBoss version 4.0.4GA
---------------------------------------------

                 Key: BETWIXT-57
                 URL: https://issues.apache.org/jira/browse/BETWIXT-57
             Project: Commons Betwixt
          Issue Type: Bug
         Environment: JBoss application server version 4.0.4GA. Probably affects most versions of JBoss
            Reporter: Surjit Sen
            Priority: Critical


When using betwixt in a JBoss application, "Class not found" exceptions get thrown when Class.forName methods are called in classes org.apache.commons.betwixt.digester.ElementRule and org.apache.commons.betwixt.digester.ClassRule. Specifically the Class.forName method uses the system class loader to load classes and in JBoss the classpath normally does not contain the application jar files. The fix is very simple. The Class.forName method calls in both the classes were replaced with the following code lines in ElementRule and similar changes were made in ClassRule as well. This fix ensures that the appropriate class loader is used for loading classes and is similar to the fix made in log4j.

                ClassLoader loader = Thread.currentThread().getContextClassLoader();
                if (loader == null) {
                	loader = Class.forName(implementationClass).getClassLoader();
                    //Class clazz = Class.forName(implementationClass);
                }
                Class clazz = loader.loadClass(implementationClass);
                descriptor.setImplementationClass(clazz);


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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (BETWIXT-57) Class loader problem in JBoss version 4.0.4GA

Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BETWIXT-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12463858 ] 

Simon Kitching commented on BETWIXT-57:
---------------------------------------

Robert, I see that the new useContextClassLoader attribute defaults to false.

In Digester it defaults to false, but that is mainly because this feature was added after Digester was already widely used and at a 1.x release. Changing the existing behaviour would therefore not be acceptable.

Perhaps for Betwixt it should default to true instead? Or is it too late already to change existing behaviour?

Either way, it would be nice if the javadoc indicated what the default behaviour is...

> Class loader problem in JBoss version 4.0.4GA
> ---------------------------------------------
>
>                 Key: BETWIXT-57
>                 URL: https://issues.apache.org/jira/browse/BETWIXT-57
>             Project: Commons Betwixt
>          Issue Type: Bug
>         Environment: JBoss application server version 4.0.4GA. Probably affects most versions of JBoss
>            Reporter: Surjit Sen
>            Priority: Critical
>
> When using betwixt in a JBoss application, "Class not found" exceptions get thrown when Class.forName methods are called in classes org.apache.commons.betwixt.digester.ElementRule and org.apache.commons.betwixt.digester.ClassRule. Specifically the Class.forName method uses the system class loader to load classes and in JBoss the classpath normally does not contain the application jar files. The fix is very simple. The Class.forName method calls in both the classes were replaced with the following code lines in ElementRule and similar changes were made in ClassRule as well. This fix ensures that the appropriate class loader is used for loading classes and is similar to the fix made in log4j.
>                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
>                 if (loader == null) {
>                 	loader = Class.forName(implementationClass).getClassLoader();
>                     //Class clazz = Class.forName(implementationClass);
>                 }
>                 Class clazz = loader.loadClass(implementationClass);
>                 descriptor.setImplementationClass(clazz);

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (BETWIXT-57) Class loader problem in JBoss version 4.0.4GA

Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BETWIXT-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464413 ] 

Simon Kitching commented on BETWIXT-57:
---------------------------------------

Ok, I've made this default to "true". I've also ensured that when set to false, lookup is relative to the classloader that loaded Betwixt, not the one that loaded Digester. See r495842, r495843.

> Class loader problem in JBoss version 4.0.4GA
> ---------------------------------------------
>
>                 Key: BETWIXT-57
>                 URL: https://issues.apache.org/jira/browse/BETWIXT-57
>             Project: Commons Betwixt
>          Issue Type: Bug
>         Environment: JBoss application server version 4.0.4GA. Probably affects most versions of JBoss
>            Reporter: Surjit Sen
>            Priority: Critical
>
> When using betwixt in a JBoss application, "Class not found" exceptions get thrown when Class.forName methods are called in classes org.apache.commons.betwixt.digester.ElementRule and org.apache.commons.betwixt.digester.ClassRule. Specifically the Class.forName method uses the system class loader to load classes and in JBoss the classpath normally does not contain the application jar files. The fix is very simple. The Class.forName method calls in both the classes were replaced with the following code lines in ElementRule and similar changes were made in ClassRule as well. This fix ensures that the appropriate class loader is used for loading classes and is similar to the fix made in log4j.
>                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
>                 if (loader == null) {
>                 	loader = Class.forName(implementationClass).getClassLoader();
>                     //Class clazz = Class.forName(implementationClass);
>                 }
>                 Class clazz = loader.loadClass(implementationClass);
>                 descriptor.setImplementationClass(clazz);

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (BETWIXT-57) Class loader problem in JBoss version 4.0.4GA

Posted by "Robert Burrell Donkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BETWIXT-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464026 ] 

Robert Burrell Donkin commented on BETWIXT-57:
----------------------------------------------

I was a little concerned about the effects on existing installations of using the context classloader but Betwixt is only a 0.x so feel free to break the semantics if it's right thing to do and you documentation it at the bottom of tasks.xml. 

Please feel free to go ahead and add more javadocs (and documentation, if you can find some time)

> Class loader problem in JBoss version 4.0.4GA
> ---------------------------------------------
>
>                 Key: BETWIXT-57
>                 URL: https://issues.apache.org/jira/browse/BETWIXT-57
>             Project: Commons Betwixt
>          Issue Type: Bug
>         Environment: JBoss application server version 4.0.4GA. Probably affects most versions of JBoss
>            Reporter: Surjit Sen
>            Priority: Critical
>
> When using betwixt in a JBoss application, "Class not found" exceptions get thrown when Class.forName methods are called in classes org.apache.commons.betwixt.digester.ElementRule and org.apache.commons.betwixt.digester.ClassRule. Specifically the Class.forName method uses the system class loader to load classes and in JBoss the classpath normally does not contain the application jar files. The fix is very simple. The Class.forName method calls in both the classes were replaced with the following code lines in ElementRule and similar changes were made in ClassRule as well. This fix ensures that the appropriate class loader is used for loading classes and is similar to the fix made in log4j.
>                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
>                 if (loader == null) {
>                 	loader = Class.forName(implementationClass).getClassLoader();
>                     //Class clazz = Class.forName(implementationClass);
>                 }
>                 Class clazz = loader.loadClass(implementationClass);
>                 descriptor.setImplementationClass(clazz);

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Resolved: (BETWIXT-57) Class loader problem in JBoss version 4.0.4GA

Posted by "Robert Burrell Donkin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BETWIXT-57?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Burrell Donkin resolved BETWIXT-57.
------------------------------------------

    Resolution: Fixed

Fix committed.

> Class loader problem in JBoss version 4.0.4GA
> ---------------------------------------------
>
>                 Key: BETWIXT-57
>                 URL: https://issues.apache.org/jira/browse/BETWIXT-57
>             Project: Commons Betwixt
>          Issue Type: Bug
>         Environment: JBoss application server version 4.0.4GA. Probably affects most versions of JBoss
>            Reporter: Surjit Sen
>            Priority: Critical
>
> When using betwixt in a JBoss application, "Class not found" exceptions get thrown when Class.forName methods are called in classes org.apache.commons.betwixt.digester.ElementRule and org.apache.commons.betwixt.digester.ClassRule. Specifically the Class.forName method uses the system class loader to load classes and in JBoss the classpath normally does not contain the application jar files. The fix is very simple. The Class.forName method calls in both the classes were replaced with the following code lines in ElementRule and similar changes were made in ClassRule as well. This fix ensures that the appropriate class loader is used for loading classes and is similar to the fix made in log4j.
>                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
>                 if (loader == null) {
>                 	loader = Class.forName(implementationClass).getClassLoader();
>                     //Class clazz = Class.forName(implementationClass);
>                 }
>                 Class clazz = loader.loadClass(implementationClass);
>                 descriptor.setImplementationClass(clazz);

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (BETWIXT-57) Class loader problem in JBoss version 4.0.4GA

Posted by "Robert Burrell Donkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BETWIXT-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12462843 ] 

Robert Burrell Donkin commented on BETWIXT-57:
----------------------------------------------

There are issues with switching universally to using the context classloader: too many containers do not set this classloader correctly. Digester rules should use the classloader provided by Digester. So, the Betwixt rules should use the Digester classloader. However, the Digester implemetation is not exposed by XmlIntrospector. So, this setting needs to be added into the IntrospectionConfiguration.

I've committed these changes into trunk.

Now, when using Betwixt in a container like JBoss with a well behaved context classloader, setUseContextClassLoader(true) should called on IntrospectionConfiguration for the XMLIntrospector. This should produce the same result as the fix above. Please try the latest code and open this again if this fix doesn't work.

> Class loader problem in JBoss version 4.0.4GA
> ---------------------------------------------
>
>                 Key: BETWIXT-57
>                 URL: https://issues.apache.org/jira/browse/BETWIXT-57
>             Project: Commons Betwixt
>          Issue Type: Bug
>         Environment: JBoss application server version 4.0.4GA. Probably affects most versions of JBoss
>            Reporter: Surjit Sen
>            Priority: Critical
>
> When using betwixt in a JBoss application, "Class not found" exceptions get thrown when Class.forName methods are called in classes org.apache.commons.betwixt.digester.ElementRule and org.apache.commons.betwixt.digester.ClassRule. Specifically the Class.forName method uses the system class loader to load classes and in JBoss the classpath normally does not contain the application jar files. The fix is very simple. The Class.forName method calls in both the classes were replaced with the following code lines in ElementRule and similar changes were made in ClassRule as well. This fix ensures that the appropriate class loader is used for loading classes and is similar to the fix made in log4j.
>                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
>                 if (loader == null) {
>                 	loader = Class.forName(implementationClass).getClassLoader();
>                     //Class clazz = Class.forName(implementationClass);
>                 }
>                 Class clazz = loader.loadClass(implementationClass);
>                 descriptor.setImplementationClass(clazz);

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org