aspose file tools*
The moose likes Tomcat and the fly likes adding to classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "adding to classpath" Watch "adding to classpath" New topic
Author

adding to classpath

joe black
Ranch Hand

Joined: Dec 03, 2003
Posts: 103
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

Joined: Jan 10, 2002
Posts: 61611
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
joe black
Ranch Hand

Joined: Dec 03, 2003
Posts: 103
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

Joined: Jan 10, 2002
Posts: 61611
    
  67

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

Joined: Mar 22, 2000
Posts: 12823
    
    5
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: adding to classpath