Hi,

Thank you for the exhaustive list of alternatives. I just have one small problem: I meant an .aar archive that is used for Axis2 web service deployments in the services directory (I incorrectly wrote .war in the subject of the original email). Do the same concepts apply (some of them, such as DBMS for example, obviously do, but I was hinting more towards the exploded archive option)?

On 7/10/06, Rodrigo Ruiz <[EMAIL PROTECTED]> wrote:
Depending on the servlet container you are using, war archives may be
considered read-only. In this case you will not be able to write a file
within the application context.

Some alternatives you have are:

- Deploy your application as an "exploded war" (the exact name will vary
from container to container). When deploying in this mode, your classes
can write files at any location within your context.

- Use an absolute path for your file. The path may be configured through
JNDI, or System properties, or you might put it into a subfolder of the
user home (this is very common in *nix environments).


Other options imply to use a different storage type:

- Use the User Preferences API to store the value. This API is available
starting from Java 1.4.

- Store it into the JNDI tree. This only works if the JNDI
implementation is writeable and persistent. For example, AFAIK, it will
not work in Tomcat

- Use a DBMS. It may seem an overkill solution, but there are some very
lightweight databases there. They may be not appropriate for enterprise
solutions, but for a single value they are more than enough. Moreover,
it is possible that you already use one for another service.

- Use a distributed cache. Another overkill solution, but you may be
already using it for another service, or find out other places where it
may be useful ;-)

These options, although more complex to implement, bring you an extra
feature. They make your service "distributable", that is, deployable on
a cluster of redundant servers. With local files, each node in the
cluster would have its own "counter".

Hope this helps,
Rodrigo Ruiz

Michael McIntosh wrote:
> Your problem seems very similar to mine - It would be great if someone
> would point us to the documentation for the rules related to file access
> (read/write, path, etc.)
>
> Thanks,
> Mike
>
> "M S" <[EMAIL PROTECTED]> wrote on 07/10/2006 10:40:47 AM:
>
>> Hi,
>>
>> I have a web service that is supposed to generate prime numbers. I
>> store the latest generated prime number in a file called prime.txt.
>> So for example, if the program is run and generated 3, 3 will be
>> stored in prime.txt and next time it will generate 5. If there is no
>> prime.txt, the program will generate 1 and try to create prime.txt.
>>
>> My problem is that my web service application does not seem to be
>> able to read/write a file. Any ideas on how this should be done?
>> Notice that the prime.txt must be able to saved for the duration of
>> the web service's lifetime.
>>
>> Regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

--
-------------------------------------------------------------------
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol
07120 Palma de Mallorca        mailto:[EMAIL PROTECTED]
Baleares - EspaƱa              Tel:+34-971435085 Fax:+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/383 - Release Date: 07/07/2006


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to