Walden,
This was very helpful, but I am am still having problems. I'm
working with a one time installation kind of config file so I don't
really want to mess with a database. I jar'ed up my classes and put
them in WEB-INF/lib. I build a war file and deploy it to jboss (or
Tomcat). I tried putting the config file in my WEB-INF directory and I
can't find it. I try putting it in WEB-INF/lib and still can't find
it. I don't have a WEB-INF/classes directory.
If I try to open a file on the server in Java like this:
new File("config.xml");
It always fails because it can't find the file.
If the File contstructor looks in the classpath for a file, I guess
I don't understand how a deployed application's classpath gets set for
an app that's running in a web container like jboss/tomcat, etc.
I just found this method on GenericServlet
getServletContext().getRealPath("/");
I'm going to try messing with this to see if I can get the real
path to my app.
Thanks,
Mike
> > > You need to put thatfileon the webapp classpath and refer to it by
> > > the correct path name. You could:
>
> > > 1. create a WEB-INF/classes directory and throw it directly in there.
> > > 2. jar it up with the rest of your resources, but in the root folder
> > > of that jar, and then refer to it as just "dataSources.xml" in your
> > > code.
> > > 3. if you jar it up in a subdirectory, just make sure you reference it
> > > properly from code, relative to the actual classpath. So if it's in
> > > your jar as /resources/dataSources.xml, then make sure you refer to it
> > > exactly the same in code. This would apply equally if you were to put
> > > it in WEB-INF/classes/resources.
>
> > > Hope that helps,
>
> > > Walden
>
> > > On Feb 9, 12:37 pm,mikea_59<
mikea...@yahoo.com> wrote:
>
> > > > I'm deploying to Tomcat. I have read other threads about locating
> > > > config files on the server side, like a dataSource.xmlfile. Others
> > > > have suggested putting thefilein WEB-INF/classes directory. My
> > > > deployment does not have a WEB-INF/classes dir. I have jar'ed up all
> > > > my classes and put them in a WEB-INF/lib dir. The app runs ok under
> > > > Tomcat, just can't find the dataSources.xmlfile. I tried putting it