Setting up a quartz job to call EJb using EJBInvokerJob

I need to call the ejb method from a quartz job, and I am having trouble finding an ejb job. I defined a local interface and a stateless implementation. When deploying to websphere 7, EjbInvokerJob cannot find my component in my jndi tree. This is the definition of my quartz job (this is loaded via the init quartz servlet)

JobDetail jd = JobBuilder// .newJob(EJBInvokerJob.class)// .withIdentity("job", "group")// .usingJobData(EJBInvokerJob.EJB_JNDI_NAME_KEY, "ejb/myBean")// .usingJobData(EJBInvokerJob.EJB_METHOD_KEY, "update")// .build(); String cronExpr = getInitParameter("cronExpr"); Trigger cronTrigger = TriggerBuilder// .newTrigger() // .forJob(jd) // .startNow() // .withSchedule(CronScheduleBuilder.cronSchedule(cronExpr))// .build(); Scheduler sched = StdSchedulerFactory.getDefaultScheduler(); sched.scheduleJob(jd, cronTrigger); sched.start(); 

And my bean has this annotation on top of it

 @Stateless(name = "myBean") 

How do I bind EJB_JNDI_NAME_KEY? in websphere or should I do this with this configuration. I think the problem is related to a lack of knowledge about jinjis. Since the servlet that runs the job runs in the same jvm, so the local interface should be enough

+6
source share
1 answer

Since JNDI portable global names ( java:global namespace) are not available until Java EE 6, you must bind the EJB to the component namespace (in this case, the servlet). You can then search using the java:comp/env/ejb/myBean name java:comp/env/ejb/myBean .

The following entry is required in web.xml:

 <ejb-local-ref> <ejb-ref-name>ejb/myBean</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local>LOCAL_EJB_INTERFACE</local> </ejb-local-ref> 
0
source

Source: https://habr.com/ru/post/948143/


All Articles