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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:46:00+00:00 2026-05-14T19:46:00+00:00

I trying to call some ejb bean method from tread. and getting error :

  • 0

I trying to call some ejb bean method from tread. and getting error :

(as is glassfish v3)

Log Level

SEVERE Logger
javax.enterprise.system.std.com.sun.enterprise.v3.services.impl
Name-Value Pairs
{_ThreadName=Thread-1, _ThreadID=42}
Record Number 928 Message ID
java.lang.NullPointerException at
ua.co.rufous.server.broker.TempLicService.run(TempLicService.java
Complete Message 35) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at
java.lang.Thread.run(Thread.java:637)

here is tread

public class TempLicService implements Runnable {
  
    String hash;
//it`s Stateful bean
    @EJB
    private LicActivatorLocal lActivator;


    public TempLicService(String hash) {
        this.hash= hash;
    }


    @Override
    public void run() {
        

       lActivator.proccessActivation(hash);
    }

}

my ThreadPoolExecutor

public class RequestThreadPoolExecutor extends ThreadPoolExecutor {

    private boolean isPaused;
    private ReentrantLock pauseLock = new ReentrantLock();
    private Condition unpaused = pauseLock.newCondition();


    private static RequestThreadPoolExecutor threadPool;

    private RequestThreadPoolExecutor() {
        super(1, Integer.MAX_VALUE, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
        System.out.println("RequestThreadPoolExecutor created");
    }

    public static RequestThreadPoolExecutor getInstance() {
        if (threadPool == null)
            threadPool = new RequestThreadPoolExecutor();
        return threadPool;
    }
    public void runService(Runnable task) {

        threadPool.execute(task);


    }


    protected void beforeExecute(Thread t, Runnable r) {
        super.beforeExecute(t, r);
        pauseLock.lock();
        try {
            while (isPaused) unpaused.await();
        } catch (InterruptedException ie) {
            t.interrupt();
        } finally {
            pauseLock.unlock();
        }
    }

    public void pause() {
        pauseLock.lock();
        try {
            isPaused = true;
        } finally {
            pauseLock.unlock();
        }
    }

    public void resume() {
        pauseLock.lock();
        try {
            isPaused = false;
            unpaused.signalAll();
        } finally {
            pauseLock.unlock();
        }
    }


    public void shutDown() {
        threadPool.shutdown();
    }
//<<<<<< creating thread here
    public void runByHash(String hash) {
        Runnable service = new TempLicService(hash);
        threadPool.runService(service);
    }
}

and method where i call it (it is gwt servlet, but there is no proble to call thread that not contain ejb) :

 @Override
    public Boolean submitHash(String hash) {
        System.out.println("submiting hash");
        try {
           
            if (tBoxService.getTempLicStatus(hash) == 1) {
//<<< here is the call
                    RequestThreadPoolExecutor.getInstance().runByHash(hash);
                    return true;
                }
            } catch (NoResultException e) {
                e.printStackTrace();
            }
            return false;
        }

I need to organize some pool of submitting hash to server (calls of LicActivator bean), is ThreadPoolExecutor design good idea and why it is not working in my case? (as I know we can`t create thread inside bean, but could we call bean from different threads? ).
If No, what is the bast practice for organize such request pool?

Thanks.


  1. <<
    Answer: I am using DI (EJB 3.1) soo i do not need any look up here. (application packed in ear and both modules in it (web module and ejb), it works perfect for me). But I can use it only in managed classes.

So..

2.Can I use manual look up in Tread ? —- Yes

3.Could I use Bean that extends ThreadPoolExecutor and calling another bean that implements Runnable? Or it is not allowed ?

  • 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-14T19:46:00+00:00Added an answer on May 14, 2026 at 7:46 pm

    I can use it only in managed classes for EJB injection.

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

Sidebar

Ask A Question

Stats

  • Questions 450k
  • Answers 450k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Did you check the value of the current directory? The… May 15, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer You can make your object Countable so that it works… May 15, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer I would probably go through all line segments, calculate the… May 15, 2026 at 8:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.