Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>System.out.println("Logged User (ID): " + login.get_final_logged_ID()); </code></pre> <p>A <code>NullPointerException</code> on that line has as the only possible cause that <code>login</code> is <code>null</code>. Given the fact that the <code>@ManagedProperty</code> looks fine, this can have only one possible cause: the setter method <code>setLogin()</code> is broken. Make sure that it look exactly like this:</p> <pre><code>public void setLogin(Login login) { this.login = login; } </code></pre> <p>and thus <strong>not</strong> </p> <pre><code>public void setLogin(Login login) { login = login; } </code></pre> <p>or something else.</p> <hr> <p><strong>Update</strong> as per the comments:</p> <blockquote> <p><em>As for the faces-config.xml , here's the thing , the Login and bussiness services beans,for their repective jsf pages , are defined as "backingBean" in the <code>&lt;managed-bean-scope&gt;</code>. In the java beans ,as u saw , I defined them sessionScoped.</em></p> </blockquote> <p>Finally, there is the cause of your problem. Configuration in <code>faces-config.xml</code> <strong>overrides</strong> all JSF2 annotations on the bean in question. You have apparently not configured the <code>&lt;managed-property&gt;</code> in the <code>faces-config.xml</code>. You have 2 options:</p> <ol> <li><p>Remove the whole <code>&lt;managed-bean&gt;</code> configuration in <code>faces-config.xml</code>. The whole point of new JSF 2.x annotations like <code>@ManagedBean</code>, <code>@ManagedProperty</code>, etc is to <em>get rid</em> of verbose JSF 1.x style XML configuration.</p></li> <li><p>Add a <code>&lt;managed-property&gt;</code> value of <code>#{Login}</code> to the <code>&lt;managed-bean&gt;</code> of <code>Buss_Services</code>.</p> <pre><code>&lt;managed-property&gt; &lt;property-name&gt;login&lt;/property-name&gt; &lt;value&gt;#{Login}&lt;/value&gt; &lt;/managed-property&gt; </code></pre></li> </ol> <hr> <p><strong>Unrelated</strong> to the concrete problem. You've several serious flaws in the design and code style.</p> <ul> <li><p>You should <strong>not</strong> reference <code>UIComponent</code>s as properties. Instead, you should reference its values. Keep the model as simple as possible and never use <code>UIComponent</code> unless you have a really valid reason. E.g.</p> <pre><code>private String username; private String password; private Long userID; </code></pre></li> <li><p>Your login validation method is inefficient. It seems to haul the entire users table from DB into Java's memory wherein you test every individual row. You should try to write and finetune the SQL query as much as possible so that it returns <strong>exactly</strong> the information you're looking for. </p> <pre><code>statement = connection.prepareStatement("SELECT id FROM Users WHERE username = ? AND password = MD5(?)"); statement.setString(1, username); statement.setString(2, password); resultSet = statement.executeQuery(); if (resultSet.next()) { userID = resultSet.getLong("id"); } </code></pre></li> <li><p>Your PHP-like code style fully contradicts the <a href="http://www.oracle.com/technetwork/java/codeconventions-135099.html#367" rel="nofollow">Java Naming Conventions</a>. It makes the code harder to read and maintain by all other Java developers, such as the ones from who you expect answers when you post the code on the Internet, like here. Package names should be all lowercase. Underscores are only valid in constants, for all other names CamelCase should be used. Instance names (like managed bean names) should start with lowercase. Etcetera.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload