一个web应用程序,里面加了一个定时任务,任务中有取数据库连接的语句,是采用数据源的方式。在tomcat下是完全可以用的。但是在was上发布后,手动操作的可以正常连接数据库执行操作。定时任务使用的是同样的代码,就是报
javax.naming.ConfigurationException:
A JNDI operation on a "java:" name cannot be completed because the serverruntime 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.
[Root exception is javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".]
查资料才了解到
那个定时的程序,在was上执行的时候用ctx.lookup("java:comp/env/DSsystem")取不到数据源.用ctx.lookup("jdbc/DSsystem")这个可以。
定时任务不能取到数据源是因为定时任务是单独起了一个线程,在was中,这个单独的线程不受系统jndi的管理,多以在这个单独起的线程里不能从jndi取。但是可以直接用ctx.lookup("jdbc/DSsystem")。
下面拷贝一段网上的问题描述和回复
Problem
A JNDI operation on a "java:" name must be performed on the thread of a server application request
User response
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.
分享到:
- 2009-08-15 17:37
- 浏览 5083
- 评论(2)
- 论坛回复 / 浏览 (2 / 2932)
- 查看更多
相关推荐
WebSphere7.0数据源配置与应用程序发布之应用程序发布
详细的WebSphere数据源配置,一步步解析和分析。
websphere配置数据源
WebSphere 6.1 db2 数据源
描述websphere后台如何进行数据源配置的操作,自带详细截图说明,新手一看就懂
websphere安装配置(jvm,数据源还有集群)
websphere7.0下配置10g数据源
该文档详细介绍了websphere7.0配置oracle数据源以及部署war包的具体步骤,有图有真相!
websphere数据源间接映射,有图形文档和连接代码。希望能给你带来帮助。如果有问题可以发mail给我。
Websphere Application Server 6.1配置JDBC数据源 本文旨在于说明在 webSphere中发布项目和配置数据源。以图文的形式给出明确的配置指导。以配置oracle数据库数据源为实例,所有操作步骤都为实践后的操作步骤。
在websphere7.0中配置mysql数据源,每一步的描述及截图,很具体的,自己整理的,操作成功了的
sphere中数据源配置说明详细图解
websphere发布应用程序。介绍了如何用websphere发布一个应用程序。初学者可以看下。
websphere安装配置(jvm,数据源还有集群) websphere安装配置(jvm,数据源还有集群) websphere安装配置(jvm,数据源还有集群)
websphere8.5 配置数据源mysql,描述较少,但截图很详细,一步一步来就没问题,最后也有测试成功截图
关于WebSphere建立jdbc数据源
WebSphere下应用程序更新
Websphere 下 发布webservice
websphere 6.1中配置DM7数据源
关于WebSphere建立jdbc数据源及项目部署