Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:07:06+00:00 2026-05-27T10:07:06+00:00

I’ve two backing beans: Login : a bean that validates the user login info

  • 0

I’ve two backing beans:

  • Login: a bean that validates the user login info (username and password) with database table.
  • Buss_Services: another bean that performs some business services.

I need to get the user ID from the Login bean and use it inside the Buss_Services. It’s stored in a String property of Login and the Buss_Services needs this value to track the currently logged-in user and update the DB.

Here’s the Login backing bean:

@ManagedBean(name="Login")
@SessionScoped
public class Login {
    private String loggedUserID;

    public Object logCB_action() {
        try {
            // ...
            rs = stmt.executeQuery(SQL);
            while (rs.next()) {
                if (rs.getString("USER_NAME").equals(uname)) {
                    if (rs.getString("USER_PW").equals(pword)) {

                     // Here, the user ID is set.
                    loggedUserID=rs.getString("USER_ID");// This line ...


                    System.out.println("Logged User (ID): "+ userID);

                        return ("displayApp");
                    }
                }
            }
        }

        // ...
    }        

    public String getLoggedID() {
        // Here, the user ID is returned.
        String id = loggedUserID;
        return (id);
    }

}

Here’s the Buss_Services backing bean which calls the getLoggedID() method:

@ManagedBean(name="Buss_Services")
@SessionScoped
public class Buss_Services {



    @ManagedProperty("#{Login}")
    private Login login;

    public void newEst_action() {
        // The following line throws NullPointerException.
        System.out.println("Logged User (ID): " + login.getLoggedID());       
    }

    // Getters/setters.
}

This is the stack trace which I get when I try to access the bussiness services page:

javax.faces.el.EvaluationException:
//C:/Users/Sultan09/AppData/Roaming/JDeveloper/system11.1.2.0.38.60.17/o.j2ee/drs/TheOCES/OCES.ViewControllerWebApp.war/App_Business_SerivesPG.jsf @68,140 action="#{backingBeanScope.App_BServPG_Bean.newEst_action}": java.lang.NullPointerException

at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:965)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:346)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:204)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:121)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178

 Caused by: java.lang.NullPointerException
    at JavaView.backing.Buss_Services.newEst_action(Buss_Services.java:172)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(Unknown Source)
    at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
    ... 44 more

How is this caused and how can I solve it?


UPDATE :
As per comments here and personal search on similar issues to the one stated here, the Problem is Finally solved ,thank god.
The solution was that I had to:

  1. add the <managed-property> of login to the adfc-config.xml file .
  2. more importantly , obtain the loggedUserID inside a @PostConstruct anotated method init() . Thanx everyone.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:07:07+00:00Added an answer on May 27, 2026 at 10:07 am
    System.out.println("Logged User (ID): " + login.get_final_logged_ID());       
    

    A NullPointerException on that line has as the only possible cause that login is null. Given the fact that the @ManagedProperty looks fine, this can have only one possible cause: the setter method setLogin() is broken. Make sure that it look exactly like this:

    public void setLogin(Login login) {
        this.login = login;
    }
    

    and thus not

    public void setLogin(Login login) {
        login = login;
    }
    

    or something else.


    Update as per the comments:

    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 <managed-bean-scope>. In the java beans ,as u saw , I defined them sessionScoped.

    Finally, there is the cause of your problem. Configuration in faces-config.xml overrides all JSF2 annotations on the bean in question. You have apparently not configured the <managed-property> in the faces-config.xml. You have 2 options:

    1. Remove the whole <managed-bean> configuration in faces-config.xml. The whole point of new JSF 2.x annotations like @ManagedBean, @ManagedProperty, etc is to get rid of verbose JSF 1.x style XML configuration.

    2. Add a <managed-property> value of #{Login} to the <managed-bean> of Buss_Services.

      <managed-property>
          <property-name>login</property-name>
          <value>#{Login}</value>
      </managed-property>
      

    Unrelated to the concrete problem. You’ve several serious flaws in the design and code style.

    • You should not reference UIComponents as properties. Instead, you should reference its values. Keep the model as simple as possible and never use UIComponent unless you have a really valid reason. E.g.

      private String username;
      private String password;
      private Long userID;
      
    • 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 exactly the information you’re looking for.

      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");
      }
      
    • Your PHP-like code style fully contradicts the Java Naming Conventions. 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.