Home » Language IDEs » ServerTools (WTP) » Problem locating a file in deployed WTP 2.0 Web app.
Problem locating a file in deployed WTP 2.0 Web app. [message #211451] |
Tue, 01 April 2008 12:27  |
Eclipse User |
|
|
|
Hi,
I'm using Eclipse Europa + WTP 2.0 + Apache Tomcat 5.5 as a deploy server.
My project is a "Dynamic Web Project" with "Dynamic Web Module" version
2.4.
And I have a problem to find a path to one file located in
"MyProject/WebContent/WEB-INF/" directory called users.properties. I'm
trying to locate this file from a class located in "MyProject/Java
Resources/src/somepackage" directory. So, in my com.myapp.package.MyClass
I have following line:
--
PropertiesConfiguration config = new
PropertiesConfiguration("WebContent/WEB-INF/users.properties ");
--
and this works if I run JUnit test of this class, but when I deploy
application to a Apache Tomcat using "Run As->Run on Server..." I got an
FileNotFoundException.
So, to sum up my question, how can I have a unique path to some file from
my source classes, if that file is located in WEB-INF directory ?
I should note that the file users.properties must be located in WEB-INF
directory, because Acegi Security library search for it there.
Thank you in advance.
--
Milan Milanovic
|
|
| | | |
Re: Problem locating a file in deployed WTP 2.0 Web app. [message #211700 is a reply to message #211650] |
Thu, 03 April 2008 09:45   |
Eclipse User |
|
|
|
Hi Wolfgang,
you probably mean on absolute path ? But, how can I know path of this file
when my Web app is deployed somewhere in eclipse\workspace\.metadata\...
folder ? Later, when I deploy my application on some else Tomcat server I
must change this path. Is there any way that I link with relative path ?
__________________________
Thank you, Milan Milanovic
Wolfgang Knauf wrote:
> Probably you should store the path in e.g. some static variable in your DAO
> layer. This path could either be set in the servlet (in its "init" override,
> where the ServletContext is available), or from your Unit test setup method.
> Hope this helps
> Wolfgang
> Milan Milanovic schrieb:
>> Dear Wolfgang,
>>
>> well, I need that path in my DAO class, not in Servlet class. How my DAO
>> class which is actually POJO can know for servletContext ?
>>
>> _____________________________
>> Best regards, Milan Milanovic
>>
|
|
|
Re: Problem locating a file in deployed WTP 2.0 Web app. [message #211709 is a reply to message #211650] |
Thu, 03 April 2008 10:35   |
Eclipse User |
|
|
|
Dear Wolfgang,
I supose that you mean on absolute path ? But how can I know where is that
file when deployed, it somewhere in eclipse\workspace\.metadata\... And
what if I later deploy it on Tomcat which is installed somewhere else, I
will need to chage the path. Is there any way to define a relative path
from DAO class to file in web-inf ?
_____________________________________
Thank you in advance, Milan Milanovic
Wolfgang Knauf wrote:
> Probably you should store the path in e.g. some static variable in your DAO
> layer. This path could either be set in the servlet (in its "init" override,
> where the ServletContext is available), or from your Unit test setup method.
> Hope this helps
> Wolfgang
> Milan Milanovic schrieb:
>> Dear Wolfgang,
>>
>> well, I need that path in my DAO class, not in Servlet class. How my DAO
>> class which is actually POJO can know for servletContext ?
>>
>> _____________________________
>> Best regards, Milan Milanovic
>>
|
|
|
Re: Problem locating a file in deployed WTP 2.0 Web app. [message #211797 is a reply to message #211709] |
Fri, 04 April 2008 11:12   |
Eclipse User |
|
|
|
Nobody has an answer to this question ? My question is actually very
simple, is there any way to have relative path from some DAO class in src
folder to some file in WEB-INF folder ?
I have one another question, in this way by using WTP 2.0 I'm deploying
web app in Eclipse using Tomcat. But if I want to deploy final application
on some other computer that have only Tomcat installed, how can I do it ?
____________________________________
Thank you in advance,Milan Milanovic
Milan Milanovic wrote:
> Dear Wolfgang,
> I supose that you mean on absolute path ? But how can I know where is that
> file when deployed, it somewhere in eclipseworkspace.metadata... And
> what if I later deploy it on Tomcat which is installed somewhere else, I
> will need to chage the path. Is there any way to define a relative path
> from DAO class to file in web-inf ?
> _____________________________________
> Thank you in advance, Milan Milanovic
> Wolfgang Knauf wrote:
>> Probably you should store the path in e.g. some static variable in your DAO
>> layer. This path could either be set in the servlet (in its "init"
override,
>> where the ServletContext is available), or from your Unit test setup method.
>> Hope this helps
>> Wolfgang
>> Milan Milanovic schrieb:
>>> Dear Wolfgang,
>>>
>>> well, I need that path in my DAO class, not in Servlet class. How my DAO
>>> class which is actually POJO can know for servletContext ?
>>>
>>> _____________________________
>>> Best regards, Milan Milanovic
>>>
|
|
|
Re: Problem locating a file in deployed WTP 2.0 Web app. [message #211805 is a reply to message #211700] |
Fri, 04 April 2008 11:23  |
Eclipse User |
|
|
|
Originally posted by: wknauf_NO_._INSIDE_hg-online.de
Hi Milan,
you can find the absolute path through the ServletContext while your servlet is
initialized (override the "init()" method). In this moment, you have set the
absolute path to the model classes where it is required.
This way, you don't have to care about the installation location.
Hope this helps
Wolfgang
Milan Milanovic schrieb:
> Hi Wolfgang,
>
> you probably mean on absolute path ? But, how can I know path of this
> file when my Web app is deployed somewhere in
> eclipse\workspace\.metadata\... folder ? Later, when I deploy my
> application on some else Tomcat server I must change this path. Is there
> any way that I link with relative path ?
>
> __________________________
> Thank you, Milan Milanovic
>
|
|
|
Goto Forum:
Current Time: Mon Jul 14 19:24:12 EDT 2025
Powered by FUDForum. Page generated in 0.05545 seconds
|