Issues When Starting a Job with an MDB
commondialog Nov 17, 2010 1:43 PMI have a bean: CXLGLBean that I can lookup via JNDI in Seam and execute the method. However, when the same code is triggered via a MessageDriven bean and Quartz, it fails.
First, here is the MDB:
@MessageDriven(activationConfig= {
@ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "0 41 11 * * ? *")})
@ResourceAdapter("quartz-ra.rar") public class CXLGLScheduler implements Job {
public class CXLGLScheduler implements Job {
public void execute(JobExecutionContext arg0) throws JobExecutionException {
try {
CXLGLBean cxlgl = new CXLGLBean();
cxlgl.getGLEvents();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Because the Bean and the Scheduler are in the same EAR, I could just load it locally and be done with it. getGLEvents does several things, but the most revelant is that it makes a SOAP call like this:
SOAPMessage message = null;
try {
MessageFactory msgFactory = MessageFactory.newInstance();
message = msgFactory.createMessage();
SOAPPart part = message.getSOAPPart();
SOAPEnvelope envelope = part.getEnvelope();
envelope.addNamespaceDeclaration("xsi", "http://www.w3.org/1999/XMLSchema-instance");
envelope.addNamespaceDeclaration("xsd", "http://www.w3.org/1999/XMLSchema");
envelope.addNamespaceDeclaration("soap-env", "http://schemas.xmlsoap.org/soap/envelope/");
SOAPBody body = envelope.getBody();
SOAPElement element = body.addChildElement(envelope.createName("ns1:" + this.method + (asResponse ? "Response" : "")));
element.addAttribute(envelope.createName("xmlns:ns1"), "urn:" + this.service);
element.addAttribute(envelope.createName("soap-env:encodingStyle"), "http://schemas.xmlsoap.org/soap/encoding/");
SOAPElement ele2 = element.addChildElement(envelope.createName(nodeName));
ele2.addAttribute(envelope.createName("xsi:type"), "xsd:string");
ele2.addTextNode(xmlStr);
if (!asResponse) message.saveChanges();
} catch (Exception e) {
throw new CXLSOAPException("Error making message: " + e.getMessage(), service, method, request.toString(), response.toString(), e);
}
Getting that to work in JBoss/Seam required that I put the JBoss-native-saaj.jar file into server/lib/endorsed and also adding the following runtime option in to run.conf.bat:
-Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.MessageFactoryImpl
But now the Action works, the bean is called and everything is fine.
However, when I run it schedued, I got an error: com.sun.xml.messaging.saaj.client.p2p.httpsoapconnection not found. So I added saaj-api.jar and saaj-ri.jar to server/lib/endorsed and then schedule the job to run. When it executed, I got the following error:
12:40:00,321 ERROR [STDERR] javax.xml.soap.SOAPException: Unable to create SOAP connection factory: com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory cannot be cast to javax.xml.soap.SOAPConnectionFactory
12:40:00,321 ERROR [STDERR] at javax.xml.soap.SOAPConnectionFactory.newInstance(Unknown Source)
12:40:00,321 ERROR [STDERR] at com.client.cxli.base.SOAPBase.sendRequest(SOAPBase.java:257)
12:40:00,321 ERROR [STDERR] at com.client.cxli.base.SOAPBase.authenticate(SOAPBase.java:131)
12:40:00,321 ERROR [STDERR] at com.client.cxli.base.SOAPBase.handleCXLConversation(SOAPBase.java:531)
12:40:00,337 ERROR [STDERR] at com.client.cxli.calls.GetGLEventsCall.call(GetGLEventsCall.java:99)
12:40:00,337 ERROR [STDERR] at com.client.cxli.session.CXLGLBean.getGLEvents(CXLGLBean.java:80)
12:40:00,337 ERROR [STDERR] at com.client.cxli.mdb.CXLGLScheduler.execute(CXLGLScheduler.java:28)
12:40:00,337 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:40:00,337 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
12:40:00,337 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
12:40:00,337 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
12:40:00,337 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
12:40:00,337 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
12:40:00,353 ERROR [STDERR] at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
12:40:00,353 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
12:40:00,353 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
12:40:00,353 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:40:00,353 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
12:40:00,353 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
12:40:00,353 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
12:40:00,353 ERROR [STDERR] at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
12:40:00,353 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,368 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
12:40:00,368 ERROR [STDERR] at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_1195290222.invoke(InvocationContextInterceptor_z_fillMethod_1195290222.java)
12:40:00,368 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,368 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
12:40:00,368 ERROR [STDERR] at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_1195290222.invoke(InvocationContextInterceptor_z_setup_1195290222.java)
12:40:00,368 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,368 ERROR [STDERR] at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
12:40:00,368 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,384 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke
(TransactionScopedEntityManagerInterceptor.java:56)
12:40:00,384 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,384 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
12:40:00,384 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,384 ERROR [STDERR] at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
12:40:00,384 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,384 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
12:40:00,384 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,384 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
12:40:00,399 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
12:40:00,399 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,399 ERROR [STDERR] at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
12:40:00,399 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,399 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:80)
12:40:00,399 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,399 ERROR [STDERR] at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
12:40:00,399 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,399 ERROR [STDERR] at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
12:40:00,415 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:40:00,415 ERROR [STDERR] at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:282)
12:40:00,415 ERROR [STDERR] at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:270)
12:40:00,415 ERROR [STDERR] at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:140)
12:40:00,415 ERROR [STDERR] at $Proxy349.execute(Unknown Source)
12:40:00,415 ERROR [STDERR] at org.jboss.resource.adapter.quartz.inflow.QuartzJob.execute(QuartzJob.java:57)
12:40:00,415 ERROR [STDERR] at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
12:40:00,415 ERROR [STDERR] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
Why is code that will run everywhere else breaking under Quartz? Is there something I can do or set so that the code will function properly?
For reference, here is the stack trace that caused me to add saaj-ri.jar and saaj-api.jar to server/lib/endorsed:
12:17:00,231 ERROR [STDERR] javax.xml.soap.SOAPException: Unable to create SOAP connection factory: Provider com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory not found
12:17:00,231 ERROR [STDERR] at javax.xml.soap.SOAPConnectionFactory.newInstance(Unknown Source)
12:17:00,231 ERROR [STDERR] at com.client.cxli.base.SOAPBase.sendRequest(SOAPBase.java:257)
12:17:00,231 ERROR [STDERR] at com.client.cxli.base.SOAPBase.authenticate(SOAPBase.java:131)
12:17:00,246 ERROR [STDERR] at com.client.cxli.base.SOAPBase.handleCXLConversation(SOAPBase.java:531)
12:17:00,246 ERROR [STDERR] at com.client.cxli.calls.GetGLEventsCall.call(GetGLEventsCall.java:99)
12:17:00,246 ERROR [STDERR] at com.client.cxli.session.CXLGLBean.getGLEvents(CXLGLBean.java:80)
12:17:00,246 ERROR [STDERR] at com.client.cxli.mdb.CXLGLScheduler.execute(CXLGLScheduler.java:28)
12:17:00,246 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:17:00,246 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
12:17:00,246 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
12:17:00,246 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
12:17:00,246 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
12:17:00,246 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
12:17:00,262 ERROR [STDERR] at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
12:17:00,262 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
12:17:00,262 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
12:17:00,262 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:17:00,262 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
12:17:00,262 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
12:17:00,262 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
12:17:00,262 ERROR [STDERR] at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
12:17:00,262 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,262 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
12:17:00,277 ERROR [STDERR] at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_920168739.invoke(InvocationContextInterceptor_z_fillMethod_920168739.java)
12:17:00,277 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,277 ERROR [STDERR] at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
12:17:00,277 ERROR [STDERR] at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_920168739.invoke(InvocationContextInterceptor_z_setup_920168739.java)
12:17:00,277 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,277 ERROR [STDERR] at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
12:17:00,277 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,277 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
12:17:00,293 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,293 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
12:17:00,293 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,293 ERROR [STDERR] at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
12:17:00,293 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,293 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
12:17:00,293 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,293 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
12:17:00,293 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
12:17:00,293 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,309 ERROR [STDERR] at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
12:17:00,309 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,309 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:80)
12:17:00,309 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,324 ERROR [STDERR] at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
12:17:00,324 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,324 ERROR [STDERR] at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
12:17:00,324 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
12:17:00,324 ERROR [STDERR] at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:282)
12:17:00,324 ERROR [STDERR] at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:270)
12:17:00,324 ERROR [STDERR] at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:140)
12:17:00,324 ERROR [STDERR] at $Proxy396.execute(Unknown Source)
12:17:00,324 ERROR [STDERR] at org.jboss.resource.adapter.quartz.inflow.QuartzJob.execute(QuartzJob.java:57)
12:17:00,340 ERROR [STDERR] at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
12:17:00,340 ERROR [STDERR] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
EDIT: Updated formatting. Added second stack trace.