You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "solprovider (JIRA)" <ji...@apache.org> on 2007/05/24 15:59:17 UTC

[jira] Created: (COCOON-2068) Add failover for loading classes.

Add failover for loading classes.
---------------------------------

                 Key: COCOON-2068
                 URL: https://issues.apache.org/jira/browse/COCOON-2068
             Project: Cocoon
          Issue Type: Improvement
          Components: * Cocoon Core
    Affects Versions: 2.1.10
            Reporter: solprovider
            Priority: Minor


The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.

NOTE: The two "set" lines work in either order.  I prefer trying standard methods before using custom code, but Cocoon may be reasons for using custom code.

public class ClassUtils{
   public static Class loadClass(String className) throws ClassNotFoundException{
      Class ret;
      try{
         ret= Class.forName(className);
      }catch(ClassNotFoundException e){
         ret= ClassUtils.getClassLoader().loadClass(className);
      }
      return ret;
   }
}

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


[jira] Commented: (COCOON-2068) Add failover for loading classes.

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498650 ] 

Carsten Ziegeler commented on COCOON-2068:
------------------------------------------

In some scenarios Cocoon uses its own class loader, that's why the context class loader is used. And for exactly this reason it must be used first.

Now usually the class loader set as the context class loader has the default class loader (or the webapp class loader) as parent.
So if your class in on the usual class path, it should be found anyway.

Can you give more information about your problem/environment etc.?


> Add failover for loading classes.
> ---------------------------------
>
>                 Key: COCOON-2068
>                 URL: https://issues.apache.org/jira/browse/COCOON-2068
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: solprovider
>            Priority: Minor
>
> The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.
> NOTE: The two "set" lines work in either order.  I prefer trying standard methods before using custom code, but Cocoon may be reasons for using custom code.
> public class ClassUtils{
>    public static Class loadClass(String className) throws ClassNotFoundException{
>       Class ret;
>       try{
>          ret= Class.forName(className);
>       }catch(ClassNotFoundException e){
>          ret= ClassUtils.getClassLoader().loadClass(className);
>       }
>       return ret;
>    }
> }

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


[jira] Commented: (COCOON-2068) Add failover for loading classes.

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498683 ] 

Carsten Ziegeler commented on COCOON-2068:
------------------------------------------

I'm not quiet sure, but you could perhaps set the thread context class loader to the class loader you need. Cocoon itself uses the thread context class loader in all places, so if you set this before you call Cocoon, it should work i think.

> Add failover for loading classes.
> ---------------------------------
>
>                 Key: COCOON-2068
>                 URL: https://issues.apache.org/jira/browse/COCOON-2068
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: solprovider
>            Priority: Minor
>
> The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.
> NOTE: The two "set" lines would work in either order.  I believe Cocoon is using a custom ClassLoader to dynamically load changes so the custom method must be tried first.  (The auto-reload ability will be lost for environments using the fallback, but at least they will be able to use Cocoon.)
> public class ClassUtils{
>    public static Class loadClass(String className) throws ClassNotFoundException{
>       Class ret;
>       try{
>          ret= ClassUtils.getClassLoader().loadClass(className);
>       }catch(ClassNotFoundException e){
>           ret= Class.forName(className);
>      }
>       return ret;
>    }
> }

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


[jira] Commented: (COCOON-2068) Add failover for loading classes.

Posted by "solprovider (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499904 ] 

solprovider commented on COCOON-2068:
-------------------------------------

I found many other issues trying to create a Cocoon PAR for SAP Portal.  I am currently trying to make a Cocoon EAR. (ant is not being nice.)  The expected political issues about deploying an EAR did not happen.  Using an EAR will require more work to integrate security, but that seems easier than creating a PAR.  I will close this issue if the EAR solves our needs.

> Add failover for loading classes.
> ---------------------------------
>
>                 Key: COCOON-2068
>                 URL: https://issues.apache.org/jira/browse/COCOON-2068
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: solprovider
>            Priority: Minor
>
> The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.
> NOTE: The two "set" lines would work in either order.  I believe Cocoon is using a custom ClassLoader to dynamically load changes so the custom method must be tried first.  (The auto-reload ability will be lost for environments using the fallback, but at least they will be able to use Cocoon.)
> public class ClassUtils{
>    public static Class loadClass(String className) throws ClassNotFoundException{
>       Class ret;
>       try{
>          ret= ClassUtils.getClassLoader().loadClass(className);
>       }catch(ClassNotFoundException e){
>           ret= Class.forName(className);
>      }
>       return ret;
>    }
> }

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


[jira] Commented: (COCOON-2068) Add failover for loading classes.

Posted by "solprovider (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12502099 ] 

solprovider commented on COCOON-2068:
-------------------------------------

Changing this would cause more problems that fixing the environment.  My aplogies for wasting time.  Closing the issue.

> Add failover for loading classes.
> ---------------------------------
>
>                 Key: COCOON-2068
>                 URL: https://issues.apache.org/jira/browse/COCOON-2068
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: solprovider
>            Priority: Minor
>
> The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.
> NOTE: The two "set" lines would work in either order.  I believe Cocoon is using a custom ClassLoader to dynamically load changes so the custom method must be tried first.  (The auto-reload ability will be lost for environments using the fallback, but at least they will be able to use Cocoon.)
> public class ClassUtils{
>    public static Class loadClass(String className) throws ClassNotFoundException{
>       Class ret;
>       try{
>          ret= ClassUtils.getClassLoader().loadClass(className);
>       }catch(ClassNotFoundException e){
>           ret= Class.forName(className);
>      }
>       return ret;
>    }
> }

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


[jira] Commented: (COCOON-2068) Add failover for loading classes.

Posted by "solprovider (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498669 ] 

solprovider commented on COCOON-2068:
-------------------------------------

Hi Carlsten,

I changed the code and comment for this entry after thinking for a moment.  Thanks for the quick response.

My environment is SAP Portal.  The best method to install Cocoon would be as a servlet in the WAS, but that is politically improbable so I am converting Cocoon to a PAR. ("Portal Archive" PAR = SAP Portal's corruption of the EAR standard.  I have not investigated Sun's "Provider Archive" PAR.)  A PAR may be more flexible than a servlet.  SAP does not worry about standards so this will be fun.   My effort should also discover issues typically unnoticed by people using the Jetty or Tomcat environments (as in yesterday's report.)

Adding the correct directories to the ClassLoader would be good, but I have yet to find a method to create the directory paths to where the files are located.  The files in a PAR are distributed to several directories.  The SAP method is to use "ResourceBundles", but that is more customization than should be necessary.

Next is architecting how to call getResource from ClassUtils using the ServletContext rather than the ClassLoader because the ClassLoader cannot find files in the JAR calling it.  Creating a generic solution is difficult because Cocoon isolates the servlet class.  I may void the warranty with that patch.

> Add failover for loading classes.
> ---------------------------------
>
>                 Key: COCOON-2068
>                 URL: https://issues.apache.org/jira/browse/COCOON-2068
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: solprovider
>            Priority: Minor
>
> The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.
> NOTE: The two "set" lines would work in either order.  I believe Cocoon is using a custom ClassLoader to dynamically load changes so the custom method must be tried first.  (The auto-reload ability will be lost for environments using the fallback, but at least they will be able to use Cocoon.)
> public class ClassUtils{
>    public static Class loadClass(String className) throws ClassNotFoundException{
>       Class ret;
>       try{
>          ret= ClassUtils.getClassLoader().loadClass(className);
>       }catch(ClassNotFoundException e){
>           ret= Class.forName(className);
>      }
>       return ret;
>    }
> }

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


[jira] Updated: (COCOON-2068) Add failover for loading classes.

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

solprovider updated COCOON-2068:
--------------------------------

    Description: 
The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.

NOTE: The two "set" lines would work in either order.  I believe Cocoon is using a custom ClassLoader to dynamically load changes so the custom method must be tried first.  (The auto-reload ability will be lost for environments using the fallback, but at least they will be able to use Cocoon.)

public class ClassUtils{
   public static Class loadClass(String className) throws ClassNotFoundException{
      Class ret;
      try{
         ret= ClassUtils.getClassLoader().loadClass(className);
      }catch(ClassNotFoundException e){
          ret= Class.forName(className);
     }
      return ret;
   }
}

  was:
The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.

NOTE: The two "set" lines work in either order.  I prefer trying standard methods before using custom code, but Cocoon may be reasons for using custom code.

public class ClassUtils{
   public static Class loadClass(String className) throws ClassNotFoundException{
      Class ret;
      try{
         ret= Class.forName(className);
      }catch(ClassNotFoundException e){
         ret= ClassUtils.getClassLoader().loadClass(className);
      }
      return ret;
   }
}


Realized why custom class loader is needed.

> Add failover for loading classes.
> ---------------------------------
>
>                 Key: COCOON-2068
>                 URL: https://issues.apache.org/jira/browse/COCOON-2068
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: solprovider
>            Priority: Minor
>
> The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.
> NOTE: The two "set" lines would work in either order.  I believe Cocoon is using a custom ClassLoader to dynamically load changes so the custom method must be tried first.  (The auto-reload ability will be lost for environments using the fallback, but at least they will be able to use Cocoon.)
> public class ClassUtils{
>    public static Class loadClass(String className) throws ClassNotFoundException{
>       Class ret;
>       try{
>          ret= ClassUtils.getClassLoader().loadClass(className);
>       }catch(ClassNotFoundException e){
>           ret= Class.forName(className);
>      }
>       return ret;
>    }
> }

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


[jira] Closed: (COCOON-2068) Add failover for loading classes.

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

solprovider closed COCOON-2068.
-------------------------------

    Resolution: Invalid

This would cause more problems than it might solve.

> Add failover for loading classes.
> ---------------------------------
>
>                 Key: COCOON-2068
>                 URL: https://issues.apache.org/jira/browse/COCOON-2068
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: solprovider
>            Priority: Minor
>
> The ClassLoader from currentThread.getContextClassLoader() was unable to retrieve classes in my environment.  Add fallback to standard Java class loading.
> NOTE: The two "set" lines would work in either order.  I believe Cocoon is using a custom ClassLoader to dynamically load changes so the custom method must be tried first.  (The auto-reload ability will be lost for environments using the fallback, but at least they will be able to use Cocoon.)
> public class ClassUtils{
>    public static Class loadClass(String className) throws ClassNotFoundException{
>       Class ret;
>       try{
>          ret= ClassUtils.getClassLoader().loadClass(className);
>       }catch(ClassNotFoundException e){
>           ret= Class.forName(className);
>      }
>       return ret;
>    }
> }

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