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

  • Home
  • SEARCH
  • 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 6995859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:05:01+00:00 2026-05-27T20:05:01+00:00

I have a servlet code which calls a ejb stateful session bean code as

  • 0

I have a servlet code which calls a ejb stateful session bean code as follows,

public class UsesBeansSF extends HttpServlet {   
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
          // do something
       }

    finally {}
 } 

private SessionBeanSFRemote lookupSessionBeanSFRemote() {
    try {
        Context c = new InitialContext();
        return (SessionBeanSFRemote) c.lookup("java:global/MyEJBSF/SessionBeanSF!ejbSF.SessionBeanSFRemote");
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}

}

This code works well without the line between * marks. However, when I am adding SessionBeanSFRemote sessionBeanSF = lookupSessionBeanSFRemote() this line (means calling a Stateful Session Bean), the code is giving error. Actually, I have to call the stateless session bean in order to perform some job. Can anybody help me why it is happening ? Thanks in advance.

Error message is following:

type Exception report message

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

exception

javax.servlet.ServletException: PWC1392: Error instantiating servlet class websSF.comsSF.UsesBeansSF

root cause

com.sun.enterprise.container.common.spi.util.InjectionException: 
         Error creating managed object for class websSF.comsSF.UsesBeansSF

root cause

java.lang.reflect.InvocationTargetException

root cause

java.lang.RuntimeException: javax.naming.NamingException: 
Lookup failed for 'java:global/MyEJBSF/SessionBeanSF!ejbSF.SessionBeanSFRemote' in SerialContext  
[Root exception is javax.naming.NamingException: 
ejb ref resolution error for remote business interfaceejbSF.SessionBeanSFRemote [Root exception is java.lang.NullPointerException]]

root cause

javax.naming.NamingException: 
Lookup failed for 'java:global/MyEJBSF/SessionBeanSF!ejbSF.SessionBeanSFRemote' in SerialContext  
[Root exception is javax.naming.NamingException: 
ejb ref resolution error for remote business interfaceejbSF.SessionBeanSFRemote
[Root exception is java.lang.NullPointerException]]

root cause

javax.naming.NamingException: ejb ref resolution error for remote business 
interfaceejbSF.SessionBeanSFRemote [Root exception is 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.0.1 logs.

Server: GlassFish Server Open Source Edition 3.0.1

  • 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-27T20:05:02+00:00Added an answer on May 27, 2026 at 8:05 pm

    I’m not sure if you have properly set up your Stateful bean. You can try this:

    @Stateful(mappedName = "ejb/myStatefulBean")
    public class MyStatefulBean implements MyStatefulRemoteInterface {
       // Your implementation
    }
    

    then you can look it up with:

    InitialContext context = new InitialContext();
    MyStatefulRemoteInterface myStatefulBean = (MyStatefulRemoteInterface) context.lookup("ejb/myStatefulBean");
    

    Besides, this stateful bean should be saved into each client’s session for re-using:

    HttpSession clientSession = request.getSession(false);
    clientSession.setAttribute("myStatefulBean", myStatefulBean);
    

    In future requests, you can try to get the bean from the client’ session first before creating a new one for him.

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

Sidebar

Related Questions

I have a servlet code which invokes a stateful session bean code and increment
I have code called from a servlet that calls out to an external service.
I have DTO which contains itself (it is nested). public class MyDTO { private
I have written code which should call MSSQL 2005 procedure from my servlet. The
I have a servlet S which handles callbacks from a 3rd party site. The
We have a servlet which occupies more virtual memory on the server due to
We have a servlet which occupies more virtual memory on the server as it
I have a servlet which takes us to an existing jsp, say home.jsp. This
Under JBoss 4.0.1SP1, I have a servlet that makes multiple, concurrent calls to web
I have a Java class which uses Apache POI to generate reports in Excel.

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.