aarrsseni commented on issue #383: Cgen - Avoid class loader issues causing 
missing classes
URL: https://github.com/apache/cayenne/pull/383#issuecomment-491518058
 
 
   You can add implementation of ClassLoaderManager to cayenne-ant module.
   For example 
   ```
   public class AntClassLoaderManager implements ClassLoaderManager {
   
       @Override
       public ClassLoader getClassLoader(String resourceName) {
           ClassLoader parentLoader = 
Thread.currentThread().getContextClassLoader();
   
           if (parentLoader == null) {
               parentLoader = AntClassLoaderManager.class.getClassLoader();
           }
   
           ClassLoader classLoader = parentLoader;
           return new ClassLoader() {
               @Override
               public Class<?> loadClass(String name) throws 
ClassNotFoundException {
                   try {
                       return classLoader.loadClass(name);
                   } catch (Exception ex) {
                       return 
AntClassLoaderManager.class.getClassLoader().loadClass(name);
                   }
               }
           };
       }
   }
   ```
   
   And then add 
   `
   binder -> 
binder.bind(ClassLoaderManager.class).to(AntClassLoaderManager.class)
   ` 
   to cgen task.
   I tested it in your project and in mine project too. It worked.
   But there are some doubts about second classLoader. 
   Is it the same for all cases?
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to