In my project we have created a separate scheduler web application (single WAR) to execute asynchronous jobs. It is based on Spring+Quartz integration. We are using org.springframework.scheduling.quartz.SchedulerFac toryBean with CommonJ TaskExecutor. The relevant configuration is listed below:
The environment is WebSphere Application Server 6.1. One of the scheduled jobs makes use of JNDI WebService resource defined in the deployment descriptor:Code:<bean id="adssSchedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="dataSource"> <ref bean="(data source bean)"/> </property> <property name="configLocation"> (...) </property> <property name="triggers"> <list> (list of triggers) </list> </property> <property name="taskExecutor" ref="commonJTaskExecutor"></property> </bean> <bean id="commonJTaskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor"> <property name="workManagerName" value="wm/default"/> <property name="resourceRef" value="false"/> </bean>
When the job gets executed, a javax.naming.ConfigurationException occurs. Below the relevant part of stack trace:Code:<service-ref> <description>WSDL Service DETValidAddQuoteAutoGFB</description> <service-ref-name>service/DETValidAddQuoteAutoGFBService</service-ref-name> <service-interface>hu.ahbrt.hws.services.DETValidAddQuoteAutoGFBService</service-interface> <wsdl-file>WEB-INF/wsdl/DETValidAddQuoteAutoGFB.wsdl</wsdl-file> <jaxrpc-mapping-file>WEB-INF/DETValidAddQuoteAutoGFB_mapping.xml</jaxrpc-mapping-file> <service-qname xmlns:pfx=...">pfx:DETValidAddQuoteAutoGFBService</service-qname> <port-component-ref> <service-endpoint-interface>hu.ahbrt.hws.services.DETValidAddQuoteAutoGFB</service-endpoint-interface> </port-component-ref> </service-ref>
Obviously (root of the stack) the job is run within a managed thread from WAS default thread pool. Now, what I don't understand is why a JNDI resource cannot be accessed from within a managed thread (the documentation says that the context should be propagated to the executing thread from pool). My vague suspicion is that it is somehow caused by the fact that the scheduling thread is Quartz's own thread (I see it when debugging the server instance) and because of that the J2EE context is not properly propagated to the executing thread...? But then, is it not possible at all to access the JNDI context resources in this kind of scenario?Code:[10/9/08 14:31:36:189 CEST] 0000054c javaURLContex E NMSV0310E: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. Exception stack trace: javax.naming.ConfigurationException [Root exception is javax.naming.NameNotFoundException: Name comp/env/service not found in context "java:".] at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:411) at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:388) at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:204) at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:144) at javax.naming.InitialContext.lookup(InitialContext.java:363) at (our code using the JNDI handle...) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:104) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:203) at $Proxy405.sendPolicyToOPUS(Unknown Source) at com.adss.hu.scheduler.jobs.OPUSPutPolicyJobHU.doExecuteInternal(OPUSPutPolicyJobHU.java:53) at com.adss.scheduler.jobs.AbstractAdssJob.processJobExecution(AbstractAdssJob.java) at com.adss.scheduler.jobs.AbstractAdssJob.execute(AbstractAdssJob.java) at org.quartz.core.JobRunShell.run(JobRunShell.java:203) at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61) at com.ibm.ws.asynchbeans.J2EEContext$RunProxy.run(J2EEContext.java:255) at java.security.AccessController.doPrivileged(AccessController.java:214) at javax.security.auth.Subject.doAs(Subject.java:495) at com.ibm.websphere.security.auth.WSSubject.doAs(WSSubject.java:118) at com.ibm.ws.asynchbeans.J2EEContext$DoAsProxy.run(J2EEContext.java:326) at java.security.AccessController.doPrivileged(AccessController.java:241) at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1109) at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:195) at com.ibm.ws.asynchbeans.CJWorkItemImpl.run(CJWorkItemImpl.java:187) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469) Caused by: javax.naming.NameNotFoundException: Name comp/env/service not found in context "java:". at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1767) at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1083) at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:991) at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263) at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:384) ... 36 more


Reply With Quote
