title: Wicket: There is no application attached to the current thread
body: <p>I want to login from a Desktop application to a wicket webpage. Because of this I want to check periodically that some specific parameters are present.</p>
  
  <p>But when I run my code the following exception is thrown.</p>
  
  <pre><code>Exception in thread "Thread-13" org.apache.wicket.WicketRuntimeException: There is no application attached to current thread Thread-13
  </code></pre>
  
  <p>This is my code: </p>
  
  <pre><code>public class SignIn extends WebPage {
  public SignIn()
  {
  
      // Create feedback panel and add to page
      add(new FeedbackPanel("feedback"));
  
      // Add sign-in form to page
      add(new SignInForm("signInForm"));
      startLoginChecker(new LoginRunnable());
  
  }
  
  /**
   * Sign in form
   */
  public final class SignInForm extends Form&lt;Void&gt;
  {
      private static final String USERNAME = "username";
      private static final String PASSWORD = "password";
  
      // El-cheapo model for form
      private final ValueMap properties = new ValueMap();
  
      /**
       * Constructor
       *
       * @param id
       *            id of the form component
       */
      public SignInForm(final String id)
      {
          super(id);
  
          // Attach textfield components that edit properties map model
          add(new TextField&lt;String&gt;(USERNAME, new PropertyModel&lt;String&gt;(properties, USERNAME)));
          add(new PasswordTextField(PASSWORD, new PropertyModel&lt;String&gt;(properties, PASSWORD)));
      }
  
      /**
       * @see org.apache.wicket.markup.html.form.Form#onSubmit()
       */
      @Override
      public final void onSubmit()
      {
          // Get session info
          SignInSession session = getMySession();
  
          // Sign the user in
          if (session.signIn(getUsername(), getPassword()))
          {
  
                  setResponsePage(getApplication().getHomePage());
  
          }
          else
          {
              // Get the error message from the properties file associated with the Component
              String errmsg = getString("loginError", null, "Unable to sign you in");
  
              // Register the error message with the feedback panel
              error(errmsg);
          }
      }
  
      /**
       * @return
       */
      private String getPassword()
      {
          return properties.getString(PASSWORD);
      }
  
      /**
       * @return
       */
      private String getUsername()
      {
          return properties.getString(USERNAME);
      }
  
      /**
       * @return
       */
      private SignInSession getMySession()
      {
          return (SignInSession)getSession();
      }
  }
  
  public void startLoginChecker(Runnable runnable) {
      Thread loginThread = new Thread(runnable);
      loginThread.start();
  }
  
  private class LoginRunnable implements Runnable {
      private int checkLoginPeriod = 1000; //1sec in milliseconds
      @Override
      public void run() {
          try {
              Thread.sleep(checkLoginPeriod);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          final SignInSession session = (SignInSession)getSession();
  
          while(!session.isSignedIn()) {
              if (session.signIn("wicket", "wicket"))
  
              {
  
                  setResponsePage(getApplication().getHomePage());
  
              } else
  
              {
                  // Get the error message from the properties file associated with the Component
                  String errmsg = getString("loginError", null, "Unable to sign you in");
  
                  // Register the error message with the feedback panel
                  error(errmsg);
              }
          }
  
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>How can I avoid this problem and check periodically from a thread multiple parameters.</p>
  
  <p>Gracias in advance.</p>