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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:54:54+00:00 2026-05-22T14:54:54+00:00

I have a Singleton EJB (javax.ejb.Singleton version. sigh.) which has a CDI observer method

  • 0

I have a Singleton EJB (javax.ejb.Singleton version. sigh.) which has a CDI observer method on it. When I try to deploy this to glassfish 3.1 the server fails to deploy the EAR file without any real explanation – simply saying there was an exception during deployment without any more details.

SEVERE: Exception while loading the app
SEVERE: Exception while shutting down application container
....
SEVERE: Exception while shutting down application container : java.lang.NullPointerException

This is the CDI event listener :

public void updateFromGranule(@Observes @CloudMask GranuleAvailableEvent granuleEvent) {
    LOG.info("updating cloud map");
    update(granuleEvent.getGranule(), CloudMask.class);
    fireUpdate();
}

If I change the Singleton bean to just be an @ApplicationScoped bean the app deploys fine. Similarly, if I remove the CDI event observer method the application deploys fine.
I actually need the class to be an EJB singleton because I want the transaction, thread safety etc. of EJBs, so just leaving this as a @ApplicationScoped POJO isn’t much use to me. The problem doesn’t seem to be limited to Singleton beans though – I’ve experimented by changing the annotation to @Stateless and @Stateful and I get the same issue.

It seems to me that this might be a bug in Weld, perhaps Weld and EJB are fighting about how they proxy that method – presumably EJB needs to add an interceptor class and wrap that method to ensure thread safety, and Weld is trying to do something else to make the event listener work?

Am I misunderstanding something here, and should CDI event handlers simply not be used on EJBs (in which case there should be better error messages from glassfish) – or is this actually just a bug in the CDI or EJB implementation?

  • 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-22T14:54:55+00:00Added an answer on May 22, 2026 at 2:54 pm

    I think this is the answer :

    CDI observer methods must apparently either be static or declared in the local interface of an EJB if the EJB declares a local interface. Normally if you try to declare an observer method that isn’t in the local interface you get an exception from Weld like this :

    org.jboss.weld.exceptions.DefinitionException: WELD-000088 Observer method must be static or local business method:  [method] public org.stain.ObserverBean.testMethod(EventClass) on public@Singleton class org.stain.ObserverBean
    

    For some reason glassfish does not report this exception properly when loading my EAR file and simply says Exception while loading the app.

    Adding the method to the local interface (or removing the interface declaration on the class) fixes the problem and allows the application to load normally.

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

Sidebar

Related Questions

I have a singleton ejb which is getting initialised twice. I have no idea
I have an asynchronous method in my EJB singleton that's called from another method
I have a singleton class for global access to config information. This singleton class
Okay, newbie multi-threading question: I have a Singleton class. The class has a Static
Scenario: I have @Singleton UserFactory ( @Stateless could be) , its method createSession() generating
I have created simple example with @Singleton, @Schedule and @Timeout annotations to try if
I have a singleton delayed-transaction manager class, which is responsible for enqueueing and dequeueing
I have a singleton instance that is referenced throughout the project which works like
I have a ConfigParameter SLSB that reads configuration values from the ejb-jar.xml file. This
I have 2 POJOs, in which one of them is an EJB and the

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.