j2ee, eclipse and classpath.
843833Feb 16 2007 — edited Feb 16 2007Hey. First of all, sorry for another classpath-related question. I know there are many solutions for problems like that, my either my problem is different, or I just can't figure out the solution. This post can look like it's Spring-related, but I think it's because an improper configuration of classpath (of course, I can be wrong, because I have no idea how to fix it).
I'm writing a project in J2EE, using Spring Framework, JSP files, and class files. On the beginning I was using vim and ant to write code, compile and deploy compiled WAR file to tomcat. I had everything configured and running as it should, but as the project grow bigger I decided to switch to Eclipse, because of many features this IDE has to offer.
In the code, I'm using Spring's Dependency Injection mechanism to configure some classes, so I need to have external XML files that will allow me to change the bechaviour of the application without recompiling the code. This XML files were earlier located in the 'classes' directory, and it was the root of all compiled .class files. I could load this XML files from the code by creating the ClassPathResource("file.xml"). It should load the 'file.xml' from the class-path, but instead it throws at me the FileNotFoundException exception. I've tried to copy this file to 'build' directory that is the root dir for .class files that Eclipse is using and it worked, but after a while this file dissapeared, because i presume Eclipse is cleaning this directory when it wants to, so it's not a good place to put configuration files in.
So, the question is, is it possible to configure project-specific classpath to, for example, WEB-INF directory? Then I could just put the XML files into this directory and I should be able to load them using any classpath-aware loader class. I don't want to search for the 'correct' folder by using trial-and-error "technique", because I want the solution to work with any servlet container, not only Tomcat. I've tried to change classpath in runtime, but Tomcat said I have to modify it's configuration files, and this is also not acceptable.
I am sorry if I'm missing something obvious, but ATM my irritation is partly covering my eyes. Thanks for any help.