EJB3 Injection - Null in Wicket AuthenticateWebSession

I use Wicket + EJB3 in the application and I am facing a problem, but I can not find any topic, so here it is:

I use Wicket validation and you need to use methods from EJB in overridden authentication methods (...).

I can use this EJB on any wicket page, but when it comes to WebSession, it remains Null, the injection does not work in any way.

My WicketSession class looks something like this:

public class WicketSession extends AuthenticatedWebSession {

   @EJB(name = "UserService")
   private UserService userService;

   private User user = null;

   public WicketSession(Request request) {
    super(request);
   }

   @Override
   public boolean authenticate(final String login, final String password) {

      user = userService.findByLoginPwd(login, password);

      return user != null;;
   }

   public User getUser() {
      return user;
   }

   public void setUser(User user) {
      this.user = user;
   }
}

And my EJB3:

@Remote
public interface UserService {
    public User findByLoginPwd(final String login, final String pwd);
}

@Stateless
public class UserServiceImpl implements UserService {

   public User findByLoginPwd(final String login, final String pwd) {
       [...]
   }
}

The Wicket web part is packaged in a war, the EJB business part is packaged in a jar, and then I make an ear to deploy it to a JOnAS server.

Any help would be much appreciated =)

Nicholas

+3
source share
2 answers

, , , Wicket, .

    InjectorHolder.getInjector().inject(this);

.

WicketSession, , .

JavaEEComponentInjector JNDI, JNDI- , , , (, JavaEEComponentInjector), , .

+2

, IComponentInstantiationListener ( , Spring). :, . .

Sessions , . , Session Application.newSession()? JavaEEComponentInjector , .

+3

Source: https://habr.com/ru/post/1794386/


All Articles