Hello 

I have a problem when I want to lookup my session beans. 
I have declared @EJB on the session bean in which a POJO class will be
created using reflection and will be executed in a separate thread. I did
this before without reflection and it works fine but if my class is
instantiated at runtime using class.forName() the lookup won't work. However
I'm not sure whether this is because of instantiation or invoking method
with reflection.

The class that is instantiating with reflection is actually a batch job and
we can't change the way it will be created and also we need to use local
interfaces in that job. Furthermore a method of that job which is
responsible to lookup the SBs is invoked in the same way.

to clarify the problem check out the following code:

@EJB(name = "ejb/MyEjbRef", beanInterface=MyEjB.class)
@Stateless
public class ASessionBean implements SessionBean {


     public void someMethod() {

               MyJob job = MyJobImpl.class.newInstance();
               .....
     }
}

MyJobImpl implements MyJob {

    @BeforeExecute
    public void init() {
           //NameNotFoundException occurs here!!!!
           // Please note that this method is called using
method.invoke(...) rather than normal calling 
          MyEjb ejb = initialContext.lookup("java:comp/env/ejb/MyEjbRef");
    }

    public void execute() {

          //code
    }
}


Is there any workaround to evade this problem or did I missed something? 

thanks 

-----
--
Regards

Mohammad Norouzi

Help each other to reach the future faster

http://pixelshot.wordpress.com Pixelshot Photoblog 

http://brainable.blogspot.com Brainable Blog 


-- 
View this message in context: 
http://www.nabble.com/problem-in-looking-up-local-interfaces-and-reflection-tp22413263p22413263.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to