Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding to classpath

 
joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get my war to load up in tomcat but keep getting a listenerStart error. This is because my app uses Spring + Hibernate, and tomcat isn't finding my Hibernate mapping files - I am seeing FileNotFoundException in the tomcat.log. Do I have to add these config files to my classpath? I thought that everything under WEB-INF was added, or is that just classes?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything under WEB-INF/classes is added to the classpath. Where in this hierarchy are you placing the property files?
[ November 11, 2006: Message edited by: Bear Bibeault ]
 
joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for that correction Bear. It is now working. I previously had the configuration files in /WEB-INF, not /WEB-INF/classes.

Is it common practice to put everything, such as configuration files, other resources, etc.. under /WEB-INF/classes, or do a lot of people modify the classpath? For example, lets say I wanted my configuration files to be in a folder under / instead of /WEB-INF/classes, or even in a folder outside of the war.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was a question just like this earlier today.

If the property files (or any other resources) need to be in the classpath (this is not always the case), it is customary to put them into the WEB-INF/classes hierarchy, or to jar them up and put the jar in WEB-INF/lib.

Doing weird class-loader things is not recommended.
[ November 11, 2006: Message edited by: Bear Bibeault ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it common practice to put everything, such as configuration files, other resources, etc.. under /WEB-INF/classes,

One very good reason is that servlet containers are not allowed to directly serve anything under /WEB-INF/ - imagine the security holes that would open up if your configuration files could be downloaded by anybody.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic