my dog learned polymorphism*
The moose likes Spring and the fly likes Supressing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Supressing "Failed to import bean definitions"" Watch "Supressing "Failed to import bean definitions"" New topic
Author

Supressing "Failed to import bean definitions"

Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 81
Hi. We tried to change authentication/authorization in our web aplication. We ended with with overriding a few beans and it works OK. We would like to have this feature optional - the xml configuration with overriden beans file will (or won't) exist outside application. Application context points to this config file this way:

<import resource="file:${CATALINA_HOME}/conf/externalAuthentication.xml"/>

Buf one imperfection still remains - the file is required to exist. When it doesn't, the loading of application context generates "Failed to import bean definitions..."
Can this error be somehow supressed? Thanks.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Try use wild card matching instead I am not sure if it follows the same rules as far as generating an error if its not found

<import resource="classpath:com/company/**/dao.xml"/>

Your other option if you are using 3.1 is to use bean profiles. Assuming the file will only be present in certain environments you can just define those beans within a bean profile.

http://blog.springsource.org/2011/02/14/spring-3-1-m1-introducing-profile/
http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/


[How To Ask Questions][Read before you PM me]
Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 81
Thanks, the first solution seems to work ok.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Supressing "Failed to import bean definitions"