0

My LoginBacking (@ManagedBean, @ViewScoped) has two methods: login(User) and logout(). Both are delegated to the @Stateless UserLogin service methods. From there I "save" the user in my Authorization class (@SessionScope). After successful login following happens:

Every time I change to another view (no matter what page) it calls the logout(). Ill show a log:

18:44:08,266 INFO  [at.mkx.app.service.UserSignup] (default task-47) Sign up: a@a.a
18:44:08,275 INFO  [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (default task-47) HHH000397: Using ASTQueryTranslatorFactory
18:44:08,291 INFO  [at.mkx.app.service.UserSignup] (default task-47) Signed up: id=1, email=a@a.a, password=0423fb1197c3e5ad2b21f59ce5d9c475cf56befdc9e992e4d71e06742a691a76, roles=[id=1, name=user]
18:44:39,424 INFO  [at.mkx.app.service.UserLogin] (default task-51) Log in: a@a.a
18:44:39,454 INFO  [at.mkx.app.service.UserLogin] (default task-51) Logged in: id=1, email=a@a.a, password=0423fb1197c3e5ad2b21f59ce5d9c475cf56befdc9e992e4d71e06742a691a76, roles=[id=1, name=user]
18:44:48,122 INFO  [at.mkx.app.service.UserLogin] (default task-52) Log out!? wtf?
18:44:55,195 INFO  [at.mkx.app.service.UserLogin] (default task-53) Log out!? wtf?
18:45:02,461 INFO  [at.mkx.app.service.UserLogin] (default task-54) Log out!? wtf?

The last 3 lines are simple changes to other views with links. Has anyone an idea what could be wrong here?

Additional info: I removed any link(s) in the views pointing to logout(). Furthermore I added two fake-methods in LoginBacking and UserLogin. As @Korgen mentioned I also log the managed bean too.

public void logout() {
    log.info("LoginBacking: calls userLogin.logout()");
    userLogin.logout();
}

public void foo() {
    log.info("LoginBacking: Fake method");
    userLogin.foo();
}

and

public void logout() {
    log.info("UserLogin: Log out, No existing links in the views");
    // TODO: Implement logout
}

public void foo() {
    log.info("UserLogin: Fake method");
}

Log:

07:57:28,805 INFO  [at.mkx.app.controller.LoginBacking] (default task-21) LoginBacking: calls userLogin.logout()
07:57:28,810 INFO  [at.mkx.app.service.UserLogin] (default task-21) UserLogin: Log out, No existing links in the views
07:57:40,721 INFO  [at.mkx.app.controller.LoginBacking] (default task-22) LoginBacking: calls userLogin.logout()
07:57:40,721 INFO  [at.mkx.app.service.UserLogin] (default task-22) UserLogin: Log out, No existing links in the views
07:57:55,549 INFO  [at.mkx.app.service.UserSignup] (default task-38) Sign up: martin@hell.zz
07:57:55,559 INFO  [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (default task-38) HHH000397: Using ASTQueryTranslatorFactory
07:57:55,559 INFO  [at.mkx.app.service.UserSignup] (default task-38) Signed up: id=1, email=martin@hell.zz, password=b89ae12948261984da6ad7d27e7411cb760f971927ae5e8c8b09d9e6b0554319, roles=[id=1, name=user]
07:58:07,058 INFO  [at.mkx.app.controller.LoginBacking] (default task-34) LoginBacking: calls userLogin.logout()
07:58:07,067 INFO  [at.mkx.app.service.UserLogin] (default task-34) UserLogin: Log out, No existing links in the views
07:58:14,344 INFO  [at.mkx.app.controller.LoginBacking] (default task-43) LoginBacking: calls userLogin.logout()
07:58:14,344 INFO  [at.mkx.app.service.UserLogin] (default task-43) UserLogin: Log out, No existing links in the views
07:58:40,641 INFO  [at.mkx.app.service.UserLogin] (default task-51) Log in: martin@hell.com
07:58:54,600 INFO  [at.mkx.app.service.UserLogin] (default task-50) Log in: martin@hell.zz
07:58:54,616 INFO  [at.mkx.app.service.UserLogin] (default task-50) Logged in: id=1, email=martin@hell.zz, password=b89ae12948261984da6ad7d27e7411cb760f971927ae5e8c8b09d9e6b0554319, roles=[id=1, name=user]
07:59:13,328 INFO  [at.mkx.app.controller.LoginBacking] (default task-52) LoginBacking: calls userLogin.logout()
07:59:13,329 INFO  [at.mkx.app.service.UserLogin] (default task-52) UserLogin: Log out, No existing links in the views

The first logout is simply the start at index.html. The second one the switch to the signup-view, the next two logout's is a switch to any other view and one to the login-view.

Now I am even more confused. Without any link in the views it still calls logout unintentionally. And why doesn't it call the fake-methods too?

Edit: "Solution" Debugging didn't make me much smarter. I still could not recognize, who is calling logout(). Removing the method just resulted in a complain from the start page index.html that he can't find userBacking.logout() (Note: index.html was just one line: <h1>Leck mi am Oarsch!</h1>). Cleaning/ Restarting wildfly10 and the app didn't help either. Finally I kicked the server completely and used a complete new and virgin instance of wildfly. And hey, suddenly it worked! I implemented the logout() again and now it does, what it should. Still much thanks to @BalusC and @Korgen for trying to help!

So I should keep in mind for the future: Just kick the server with an angry face out of the closed window, and buy a new one!

Martin
  • 239
  • 1
  • 15
  • who calls your login/logout methods? – Korgen Apr 15 '16 at 18:42
  • the login is implemented like BalusC describes in his Blog [here](http://balusc.omnifaces.org/2011/01/jsf-20-tutorial-with-eclipse-and.html). ' ' and the logout is a simple '[h:link]' in the header, pointing to the logout method. This header is in the template.xhtml in WEB-INF – Martin Apr 15 '16 at 19:58
  • 1
    does the logout method of your MangedBean also get called? From the logs I conclude that the "Log out!? wtf?" is a log statement in the Stateless EJB. Question is who calls this method. If you place a log statement in your MangedBean you can check if this is also triggered (I doubt it). Does your logout method in the Stateless EJB have any other annotations? – Korgen Apr 15 '16 at 20:15
  • Im not on my notebook with the application anymore. But you are right, so far I just log in the method of the Stateless EJB. There are just the two methods login and logout without any other annotations. Furthermore I just inject the UserRepository (if User exists), and the Authorization for setting the user (all in the login-method). The logout method is empty, except the log. Also in ManagedBean, which just forwards to this method. – Martin Apr 15 '16 at 20:49
  • So you have `` instead of ``? – BalusC Apr 16 '16 at 07:14
  • I used '' . But I removed the link temporarily from all views, and still the logout() is called. – Martin Apr 16 '16 at 07:30
  • @BalusC Well, maybe I used the `` not correct, but the answer in your linked question does not explain, why my `logout()` method is still triggered, when there are no existing links to the method anymore. – Martin Apr 16 '16 at 08:34
  • 1
    Just put a debug breakpoint in `logout()` method to see the origin of the call. – BalusC Apr 16 '16 at 08:36

0 Answers0