File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Supressing "Failed to import bean definitions"

Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 83
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

Joined: Mar 07, 2010
Posts: 1682

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.

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

Joined: Oct 22, 2002
Posts: 83
Thanks, the first solution seems to work ok.
I agree. Here's the link:
subject: Supressing "Failed to import bean definitions"
It's not a secret anymore!