Question

I'm developing a web service in Java EE using Apache Tomcat and so far I have written some basic server side methods and a test client. I can successfully invoke methods and get results but every time I invoke a method, the server constructor gets called again, and I also can't modify the instance variables of the server using the set methods. Is there a particular way to make my server stateful without using JAX-WS or EJB @Stateful tags?

Was it helpful?

Solution

This is a little bit of misconception here. The stateful EJB would maintain session between one client and server, so still the EJB state wouldn't be shared between various clients.

You can expose only stateless and singleton EJBs as a JAX-WS web service.

The best option is to use database for storing all bids and when the auction is finished choose the winning one.

If you want to use a file it is fine, as long as you like to play with issues like:

  1. synchronizing access to that file from many clients
  2. handling transactional reads and writes
  3. resolve file corruption problems
  4. a bunch of other problems that might happen if you are sufficiently unlucky

Sounds like a lot of work, which can be done by any sane database engine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top