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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:52:04+00:00 2026-05-27T03:52:04+00:00

I have learned a lot about EJB3.1 lately, but apparently not enough. Here’s my

  • 0

I have learned a lot about EJB3.1 lately, but apparently not enough. Here’s my tale of woe…

I have a war with servlet to which batch files can be uploaded. The servlet validates the file, stores the file data in a database and sends a message to queue that a new batch has been received. This all works fine.

I have an ear with an ejb-jar deployed which has an MDB that listens for the new batch received messages.

It also has a stateful EJB (using the no-interface view) that does the actual batch processing. The EJB has references to stateless JPA entity service beans and therefore needs to be container managed to get container injected EntityManagers.

I need to create an instance of the stateful processor bean whenever a message is received by the MDB. I haven’t been able to find any examples/tutorials which cover this scenario.

I have tried injecting the stateful bean into the MDB, but it doesn’t work:

[#|2011-11-24T13:25:45.470-0700|SEVERE|glassfish3.1.1|javax.enterprise.system.container.ejb.mdb.com.sun.ejb.containers|_ThreadID=21;_ThreadName=Thread-2;|MDB00050: Message-driven bean [MyProcessor-ear-1.0:MyMDB]: Exception in creating message-driven ejb : [com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=my.package.MyMDB/myEJB,Remote 3.x interface =my.package.MyEJB,ejb-link=null,lookup=,mappedName=,jndi-name=my.package.MyEJB,refType=Session into class my.package.MyMDB: Lookup failed for 'java:comp/env/my.package.MyMDB/myEJB' 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}]|#]

Apparently this a bad design approach anyway because MDBs are inherently stateless so stateful EJBs shouldn’t be injected. This makes sense.

My question is how else can I instantiate my stateful EJB when the MDB receives a message and ensure that the EJB is container managed?

  • 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-27T03:52:04+00:00Added an answer on May 27, 2026 at 3:52 am

    We redesigned the classes and merged them so that the onMessage method of the MDB does the processing. The state of the individuals batches are being stored in a static map on the MDB.

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

Sidebar

Related Questions

Well I have learned a lot about advantages and disadvantages of Maven. This question
I know there are a lot of questions on here about this, but most
I have read and learned a lot here, got a lot of problems solved
I've learned a lot about JMX over the past couple of years and have
A lot of what I have learned about VB I learned from using Static
Back in the past I learned a lot about CSS but now I can't
I have read a lot about mocking, particularly using Rhino Mocks and have learned
I am Studying PHP, OOP and i have learned a lot, but there is
EDIT: I don't want to delete the post because I have learned a lot
I have learned to use Lua a lot of the time and I also

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.