It is the problem, this is the test EJB im using:

@Singleton
@Startup
public class ServiceTestEJB implements Runnable{
    public Object getContextObject(String name){
        InitialContext ctx;
        try{
            ctx= new InitialContext();
            return ctx.lookup(name);
        }catch(NamingException e){
            return(null);
        }
    }
    @PostConstruct
    public void start(){
        Thread t;
        //
        if(getContextObject("java:global/jdbc/MSIM")!=null){
Logger.getLogger(getClass().getName()).log(Level.INFO, "Object found in context!!");
        }else{
Logger.getLogger(getClass().getName()).log(Level.INFO, "Object NOT FOUND in context!!");
        }
        // test from a thread
        t=new Thread(this);
        t.start();
    }
    @PreDestroy
    public void stop(){
    }
    //
    @Override
    public void run() {
        if(getContextObject("java:global/jdbc/MSIM")!=null){
Logger.getLogger(getClass().getName()).log(Level.INFO, "Object found in context (inside thread)!!");
        }else{
Logger.getLogger(getClass().getName()).log(Level.INFO, "Object NOT FOUND in context (inside thread)!!");
        }
    }
}

Result in tomee:

INFO: Created Ejb(deployment-id=ServiceTestEJB, ejb-name=ServiceTestEJB, container=Default Singleton Container)
May 24, 2013 10:14:25 AM com.spectron.service.ServiceTestEJB start
INFO: Object found in context!!
May 24, 2013 10:14:25 AM com.spectron.service.ServiceTestEJB run
INFO: Object NOT FOUND in context (inside thread)!!

So all I need now is some documentation on Work Manager Api in tomee to do things correctly.

On 5/24/2013 9:57 AM, Romain Manni-Bucau wrote:
i understood, it is available but your bug is not totally linked to it i
think (if you use java:global it should be ok)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*





Reply via email to