본문 바로가기
웹/WebSphere

[v6.1] Quartz 사용 시 JNDI 동작 안 하는 문제

by 브래드.권 2013. 4. 30.

 

 

 

Version 1.0

문서 이력

2013-04-05 최초 작성 Ver 1.0

 

 

 

WebSphere 에서 Spring.Quartz 를 이용해 배치를 만들 때 해당 배치가 Java Bean 에서 DB 접속을 할 때 보통 JNDI 를 많이 사용합니다. 아래와 같은 식으로 말이죠.

 

 

DataSource ds = (DataSource)ctx.lookup(“java:comp/env/jdbc/datasource”);

 

 

그런데 WebSphere 에서 Spring.Quartz 를 이용한 배치 Java Bean 에서는 위의 방식은 아래와 같은 오류를 발생시키며 DataSource 를 가져오지 못합니다.

 

 

1/7/11 14:42:12:506 IST 00000025 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:

 

 

이럴 경우 java: 를 쓰지 않고 아래와 같이 사용하면 DataSource 를 가져올 수 있습니다만, 왜 이렇게 하면 되는지 깊게 알아보지 못해서 이유는 알지 못하네요. 아시는 분이 있으시면 알려주시면 감사하겠습니다.

 

 

DataSource ds = (DataSource)ctx.lookup(“jdbc/datasource”);