把工程部署到websphere下遇到了两个问题,1、定时器在websphere中取不到jndi的连接,2、log4j的日志不能输出到文件中
第一个问题:
一个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")。
如果不行,就用在工程内配置数据源的方式。
第二个问题:
是因为was日志与log4j的日志冲突。
解决方法:在目录:
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/properties
增加一个文件名:
commons-logging.properties
内容为
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
或是在 META-INF/services/org.apache.commons.logging.LogFactory 中指名 org.apache.commons.logging.impl.Log4jFactory
因为我喜欢更多的是更改自己工程内的信息 而尽量少更改服务器的配置信息 所以 采用的是第二种
分享到:
相关推荐
在websphere下,log4j打印的内容会被was接管,导致在tomcat下可以正常使用的log4j配置方法,在websphere下不打印任何日志到目标路径,本方法可以解决此问题并且是几乎所有开源jar包在websphere上碰上冲突时的标准...
WebSphere V5 配置log4j的方法说明和log4j修改后的jar包以及iBATIS输出SQL的log4j.properties
在websphere7.0中配置mysql数据源,每一步的描述及截图,很具体的,自己整理的,操作成功了的
WebSphere 6.1 db2 数据源
详细的WebSphere数据源配置,一步步解析和分析。
websphere配置数据源
描述websphere后台如何进行数据源配置的操作,自带详细截图说明,新手一看就懂
websphere7.0下配置10g数据源
websphere数据源间接映射,有图形文档和连接代码。希望能给你带来帮助。如果有问题可以发mail给我。
websphere安装配置(jvm,数据源还有集群)
该文档详细介绍了websphere7.0配置oracle数据源以及部署war包的具体步骤,有图有真相!
sphere中数据源配置说明详细图解
websphere8.5 配置数据源mysql,描述较少,但截图很详细,一步一步来就没问题,最后也有测试成功截图
关于WebSphere建立jdbc数据源
WebSphere7.0数据源配置与应用程序发布之应用程序发布
关于WebSphere建立jdbc数据源及项目部署
websphere安装配置(jvm,数据源还有集群) websphere安装配置(jvm,数据源还有集群) websphere安装配置(jvm,数据源还有集群)
Websphere Application Server 6.1配置JDBC数据源 本文旨在于说明在 webSphere中发布项目和配置数据源。以图文的形式给出明确的配置指导。以配置oracle数据库数据源为实例,所有操作步骤都为实践后的操作步骤。
2、Websphere6.1配置数据源实践.doc 3、WebSphere中流行数据库连接池的配置(Oracle、SQL Server、Sybase、MySQL).doc 4、在myEclipse6中配置websphere6及部署工程实践.doc 5、WAS ND安装手册.pdf 6、WAS+6[1].1安装...
websphere8.5配置数据源。。。。。。。。。。。。。。