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 7409931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:09:22+00:00 2026-05-29T06:09:22+00:00

I have this managed bean: package com.DX_57.SR_57; /** include default packages for Beans */

  • 0

I have this managed bean:

package com.DX_57.SR_57;
/** include default packages for Beans */
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
   // or import javax.faces.bean.SessionScoped;
import javax.inject.Named;
/** include package for SHA-256 encryption */
import java.security.NoSuchAlgorithmException;
/** include SQL Packages */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import javax.annotation.Resource;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
   // or import javax.faces.bean.ManagedBean;   
import org.DX_57.osgi.CL_27.api.CryptoSHA;
import org.glassfish.osgicdi.OSGiService;
import org.DX_57.osgi.SH_27.api.SessionHandle;


@Named("loginController")

@SessionScoped

public class userCheck implements Serializable {
    private String user = null;
    private String password = null;  
    private String error_Message = null;
    private String error_Database = null;

       public userCheck(){
       }

       /** Call the Oracle JDBC Connection driver */
       @Resource(name="jdbc/Oracle")
       private DataSource ds;

       /** Call OSGI Bundle SH_27 SessionHandle Library */
       /** Use transient in order to disable serialization when calling OSGI Bundle */
       @Inject @OSGiService(dynamic=true) transient SessionHandle SH;

       public String OSGISHCheckUserDB(String CheckUser) throws SQLException{        
            return SH.CheckUserDB(CheckUser);
       }

       public String OSGISHSessionRegister(String User) throws SQLException{        
            return SH.SessionRegister(User);
       }

       /** Call OSGI Bundle CL_27 Crypto Library */
       /** Use transient in order to disable serialization when calling OSGI Bundle */
       @Inject @OSGiService(dynamic=true) transient CryptoSHA CL;

       public String OSGICLShaEncryptHash(String CString) throws NoSuchAlgorithmException{        
            return CL.ShaEncryptHash(CString);
       }      

       /** get the content of the variables from the JSF Login page */
       public void setUser(String newValue) { 
           user = newValue; 
       }

       public String getUser(){
           return user;       
       }

       public void setPassword(String newValue) { 
           password = newValue; 
       } 

       public String getPassword(){
           return password;
       }

       public String geterror_Database(){
           return error_Database;
       }

       public String geterror_Message(){
           return error_Message;
       }


       /** get user session id */
       FacesContext fCtx = FacesContext.getCurrentInstance();
       HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(false);
       String sessionId = session.getId();             

       /** get user IP address */           
       FacesContext context = FacesContext.getCurrentInstance();
       HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
       String remoteHost = request.getRemoteAddr();



       /** compare the user and the password */
       public String userCompare() throws NoSuchAlgorithmException, SQLException { 
            String hash_passwd = null;           
            String passwdQuery = null;

            /** check the password into Oracle using the username */
            passwdQuery = OSGISHCheckUserDB(user);

            /** convert the plain password in SHA-256 hash */
//          hash_passwd = string_hash(password); 

            /** compare the encrypted passwords */
            if (password.equals(passwdQuery)){     
                /** insert into users session table the time when the user login */
//                SessionRegister(user);
                /* success */                                 
                return "0";       
            } else {  
                /* failer */ 
                return "1";              
            }            
       }   

}

I can successfully compile it with Netbeans. When I deploy it on Glassfish and I open it I get this error stack:

[#|2012-02-04T18:29:36.554+0200|INFO|glassfish3.1.1|org.glassfish.osgijavaeebase|_ThreadID=64;_ThreadName=Thread-2;|deployed bundle com.DX_57.SR_57 [296] at file:/tmp/osgiapp4499752333201324876/|#]

[#|2012-02-04T18:29:48.047+0200|SEVERE|glassfish3.1.1|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=143;_ThreadName=Thread-2;|Error Rendering View[/home.xhtml]
com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: com.DX_57.SR_57.userCheck.
    at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:193)
    at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
    at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
    at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
    at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
    at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:99)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:158)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
    at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
    at com.DX_57.SR_57.userCheck.<init>(userCheck.java:103)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
    ... 54 more
|#]

The problem is in these lines:

 /** get user session id */
       FacesContext fCtx = FacesContext.getCurrentInstance();
       HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(false);
       String sessionId = session.getId();

Can you give me some advice how to fix them?

  • 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-29T06:09:22+00:00Added an answer on May 29, 2026 at 6:09 am

    The culprit is here:

    ...getExternalContext().getSession(false);
    

    Read the javadoc what the boolean argument does.

    If the create parameter is true, create (if necessary) and return a session instance associated with the current request. If the create parameter is false return any existing session instance associated with the current request, or return null if there is no such session.

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

Sidebar

Related Questions

I have a session bean <managed-bean> <managed-bean-name>vdcAddBean</managed-bean-name> <managed-bean-class>com.cloud.appsportfolio.jsf.vdc.beans.VDCAddBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> Now, I am injecting
I have a bunch of java custom tags that use spring managed beans.. since
Let's say I have this action in a JSF Managed Bean: public String doSomething()
I have a managed bean called: @ManagedBean(name=configBean) @SessionScoped public class configBean implements Serializable {
I have this line in a useful Bash script that I haven't managed to
Is it possible to define a spring-managed EJB3 hibernate listener? I have this definition
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a managed dll that calls into a native library. This native library
I have a Controller bean (SearchController) that has two managed bean as managed properties
I have a session scoped managed bean, with a property current . If I

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.