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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:01:04+00:00 2026-06-15T06:01:04+00:00

I created an EJB application for a Online DVD Store. I use Netbeans 7.2.1

  • 0

I created an EJB application for a Online DVD Store.
I use Netbeans 7.2.1 and Glassfish 3.1.2
When I run index.jsp, the interface it is launched successfully, if I click on a form submit button I receive this error:

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
root cause

java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the  GlassFish Server Open Source Edition 3.1.2.2 logs.

In Netbeans I get this error:

INFO: Couldn't create the bean Lookup failed for 'businessSessionBeans.UserSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:76)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    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 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    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)

I created a Java EE Enterprise Application. I have project-ejb and project-war. Because I couldn’t create a SessionBean from ejb dirrectly, I createa a new project/Java Library Class and I’ve created there the Entities. I introduced the library to the ejb and war and they recognized the entities so I was able to create session beans.
But I got this error and I don’t know the problem, See some of the sources:

index.jsp

    <%@page import="businessSessionBeans.* , java.math.*, javax.naming.*" %>

<%!
    private UserSessionBeanRemote userB=null;
    public void jspInit()
    {
        try{
            InitialContext ic=new InitialContext();
            userB=(UserSessionBeanRemote)ic.lookup(UserSessionBeanRemote.class.getName());
        }catch(Exception e)
                {System.out.println("Couldn't create the bean "+e.getMessage());}

     }
   public void jspDestroy()
   {
       userB=null;
   }
%>

        <%  String username=(String)request.getParameter("username");
            String password=(String)request.getParameter("password");
            if((username!=null)&(password!=null)){
                String userType=userB.userLogin(username,password);
                if (userType!=null){
                    session.setAttribute("username",username);
                    session.setAttribute("password",password);
                    session.setAttribute("userId", userB.getUserId(username, password));
                    if (userType.equals("Admin"))
                       response.sendRedirect("admin.jsp");
                    else if (userType.equals("User"))
                         response.sendRedirect("user.jsp");
                }
                else{
        %> <script type="text/javascript">
                window.alert("User not registered");
        </script>
            <%}}%>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Login</title>
        </head>
        <body>
            <h1>Welcome to our DVD Store!</h1>
        <form method="post" action="index.jsp">
            <pre>
            Username: <input type="text" name="username"/><br/>
            Password: <input type="password" name="password"/><br/>
            <input type="submit" value="Submit"/>  <input type="reset" value="Reset"/><br/>
        <h3>Don't have an account? <a href="register.jsp">Sign up</a></h3>
            </pre>
        </form>
    </body>
</html>

UserSessionBeanRemote.java

public interface UserSessionBeanRemote {

public void create(java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String type);

public void edit(Entities.UserEntityBean userBean);

public void destroy(java.lang.Integer id);

public Entities.UserEntityBean find(java.lang.Object pk);

public java.util.List findAll();

public java.lang.String userLogin(java.lang.String username, java.lang.String password);

public java.lang.Integer getUserId(java.lang.String username, java.lang.String password);

}

UserSessionBean.java

public class UserSessionBean implements UserSessionBeanRemote {

// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
@PersistenceContext
EntityManager em;

@Override
public void create(String username,String password,String name, String type)
{
    UserEntityBean userBean=new UserEntityBean();
    userBean.setName(username);
    userBean.setPassword(password);
    userBean.setName(name);
    userBean.setUserType(type);
    em.persist(userBean);
}

@Override
public void edit(UserEntityBean userBean)
{
    em.merge(userBean);
}

@Override
public void destroy(Integer id)
{
    UserEntityBean userBean=(UserEntityBean)em.find(UserEntityBean.class, id);
    em.remove(userBean);
}

@Override
public UserEntityBean find(Object pk)
{
    return (UserEntityBean)em.find(UserEntityBean.class, pk);
}

@Override
public List findAll()
{
    return em.createQuery("select OBJECT(o) from UserEntityBean o").getResultList();
}

@Override
public String userLogin(String username,String password)
{

    String fusername,fpassword;
    UserEntityBean userBean;
    List userList=findAll();
    Iterator it=userList.iterator();
    while(it.hasNext())
    {
        userBean=(UserEntityBean)it.next();
        fusername=userBean.getName();
        fpassword=userBean.getPassword();
        if(fusername.equals(username)&fpassword.equals(password))
        {
            return userBean.getUserType();
        }   
    }
    return null;
}

@Override
public Integer getUserId(String username,String password)
{

    String fusername,fpassword;
    UserEntityBean userBean;
    List userList=findAll();
    Iterator it=userList.iterator();
    while(it.hasNext())
    {
        userBean=(UserEntityBean)it.next();
        fusername=userBean.getName();
        fpassword=userBean.getPassword();
        if(fusername.equals(username)&fpassword.equals(password))
        {
            return userBean.getId();
        }
    }
    return null;
}

}

and finally, UserEntityBean.java

public class UserEntityBean implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
private String password;
private String userType;

public Integer getId() {
    return id;
}

public void setId(Integer id) {
    this.id = id;
}

/**
 * @return the name
 */
public String getName() {
    return name;
}

/**
 * @param name the name to set
 */
public void setName(String name) {
    this.name = name;
}

/**
 * @return the password
 */
public String getPassword() {
    return password;
}

/**
 * @param password the password to set
 */
public void setPassword(String password) {
    this.password = password;
}

/**
 * @return the userType
 */
public String getUserType() {
    return userType;
}

/**
 * @param userType the userType to set
 */
public void setUserType(String userType) {
    this.userType = userType;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (id != null ? id.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof UserEntityBean)) {
        return false;
    }
    UserEntityBean other = (UserEntityBean) object;
    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "Entities.UserEntityBean[ id=" + id + " ]";
}

}

any idea?

  • 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-06-15T06:01:05+00:00Added an answer on June 15, 2026 at 6:01 am

    You should lookup your EJB like:

    userB=(UserSessionBeanRemote)ic.lookup("UserSessionBean");
    

    And your code lacks @Stateless:

    @Stateless(name="UserSessionBean") 
    public class UserSessionBean implements UserSessionBeanRemote {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Netbeans 6.8 and Glassfish v3.0. I created an ejb module and
Has anyone got this configuration working? Latest Netbeans, latest Glassfish, I created an EJB
I created a java enterprise application in Netbeans 6.8. It has ejb module and
I have a web application code which uses jsp, servlet and ejb. I created
I created java enterprise application and it consists of ejb module and web application.
i have created a demo application Using JSF & EJB 3.0 (Stateless session bean
I've used the maven-ear-plugin with the maven-war-plugin and maven-ejb-plugin to successfully deploy and run
i want to use ejb and jpa controller, in netbeans the controller is generated
I have created a simple EAR the contains a EJB module and a Application
How do I use a deployed EJB app from a separate JSF application? I'm

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.