You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Seumas Soltysik (JIRA)" <ji...@apache.org> on 2009/03/02 18:16:56 UTC

[jira] Commented: (CXF-2075) Error in spring config file reported as a missing config file during initialization of BusApplicationContext

    [ https://issues.apache.org/jira/browse/CXF-2075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678040#action_12678040 ] 

Seumas Soltysik commented on CXF-2075:
--------------------------------------

Sergey
you suggested holding onto the original expception and then rethrowing if 2nd attempt failed.

this seems to create another problem whereby you may mislead the user because you throw the first exception when it turns out that the 2nd exception is really the one the user needs to know about.

Perhaps simply logging the first exception is the way to go. Also I am curious why the BAC does not throw an exception if the configuration passed into the BAC is not found.



> Error in spring config file reported as a missing config file during initialization of BusApplicationContext
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2075
>                 URL: https://issues.apache.org/jira/browse/CXF-2075
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.4
>            Reporter: Seumas Soltysik
>
> The current code to create a Bus in SpringBusFactory masks any problem in processing the spring config file passed in to SpringBusFactory. Currently if a config file is corrupt, the exception thrown trying to process this file is eaten and an attempt to create a Bus is tried again with a different thread context classloader. This completely hides the source of the error and results in a message which indicates that the config file could not be found which is completely misleading for the user.
> The solution is to not perform the 2nd attempt to create a BusApplicationContext and let the original exception propagate upwards.
>      private BusApplicationContext createApplicationContext(String cfgFiles[], boolean includeDefaults) {
>         try {      
>             return new BusApplicationContext(cfgFiles, includeDefaults, context);
>         } catch (BeansException ex) {
>             ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
>             if (contextLoader != BusApplicationContext.class.getClassLoader()) {
>                 Thread.currentThread().setContextClassLoader(
>                     BusApplicationContext.class.getClassLoader());
>                 try {
>                     return new BusApplicationContext(cfgFiles, includeDefaults, context);        
>                 } finally {
>                     Thread.currentThread().setContextClassLoader(contextLoader);
>                 }
>             } else {
>                 throw ex;
>             }
>         }
>      }

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