Announcement Announcement Module
No announcement yet.
Ignoring missing Jndi DataSource within IDE? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ignoring missing Jndi DataSource within IDE?

    Hi all,

    I have been running unit tests through my JBuilder IDE using a DBCP datasource defined in the Spring config. At deployment time, I need the application to use a datasource bound to JNDI. My problem is that when I add the bean definition for the JNDI datasource to the Spring config, I can't run my unit tests since Spring seems to expect the datasource to be in JNDI even though it is not needed at the time.

    Is there a way around this, preferrably asking Spring to ignore the fact that the Jndi datasource is not present? I will have a similar issue when moving from the EJB layer to the Web layer, as I would prefer to use the DBCP datasource there as well.

    If it is not possible for Spring to ignore the missing datasource, is there a better setup I might use?

    Thanks for any suggestions.

  • #2
    I suggest you start using different context files for the two different environments. I usually put all environment-dependant beans in separate context files. And load the one for the unit tests in my tests and the one with the Jndi datasource when on the server. Name them both the same, place them in a different directory and in your and build, depending on what environment you're building for, use one or the other.

    Hope this helps.

    Alef Arendsen


    • #3
      Thanks Alef. I did not notice the constructor to the context taking an array of files. That seems to be the answer I need. Thanks again.