Welcome to the Ranch.
Tom Zschockelt wrote:
My question : how could we solve a real user session tracking within a j2ee Environment for application Clients (what is best practice?)
To handle user session in different tiers: you can use HTTP session in the presentation/web tier, stateful EJB in the business/EJB tier
Now what's the best practice? .... Hmm just know stateful EJB is not very used much. Each method call from web to business to integration tiers and back "can" go like this, say fetch an order:
order.jsp --click button--> front controller (web tier) -> OrderController#getOrder (web tier) -> OrderManager#getOrder (business tier aka EJB) -> OrderDAO#findOrder (integration tier) that uses Order POJO/entity
The OrderManager EJB is most likely stateless EJB. Why? Each transaction (getting an order) is one time thing.
The situations that do require stateful EJB is something like shopping cart or multiple page form input. Yet depending on how you design your app, the so-called stateful EJB can be represented as transfer object.
You should check out the JEE tutorial on EJB
http://docs.oracle.com/javaee/6/tutorial/doc/gipjg.html
Apart from the classes/code, the session tracking issue also apply if you use multiple web containers. As you may know a user's transaction first go to web container A then the same user 2nd transaction "may" go the web container B, which does not know that user's session! In such scenarios, the web container can enable sticky session allowing the same web container to server all transactions for that logged in user. Beside web container, sticky session feature also in load balancers.
Tom Zschockelt wrote:
How could we replace a static 2-tier call to get a user related database Connection like "MyStaticClass.getDbConnection()" within our existing Framework?
If your existing app is 2-tier, is it on separate machine? If so the server app is where the DB connection is. All the client needs is the POJOs or transfer objects for the display.
Under the 3-tier design, DB stuff is in the data access object (DAO) which goes in the integration tier.
Hope this helps. Other Ranchers' views may differ.