连接程序中怎么访问不了WebSphere中DB2的数据源?
不清楚连接程序中怎么访问不了WebSphere中DB2的数据源?WebSphere中配置DB2数据源测试成功了。
可程序中访问不了WebSphere中DB2的数据源。
使用的是IBM的JVM,程序中配置了naming.jar,namingserver.jar,namingclient.jar,
抛出的exception如下,
Unable to read required resource: implfactory.properties
java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java(Inlined Compiled Code))
at java.io.InputStreamReader.<init>(InputStreamReader.java(Inlined Compiled Code))
at java.util.Properties.load(Properties.java(Compiled Code))
at com.ibm.ws.util.ImplFactory$1.run(ImplFactory.java:38)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:111)
at at com.ibm.ws.util.ImplFactory.<clinit>(ImplFactory.java:33).null(Unknown Source)
at com.ibm.ws.Transaction.TransactionManagerFactory$1.run(TransactionManagerFactory.java:141)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:111)
at com.ibm.ws.Transaction.TransactionManagerFactory.loadImplementations(TransactionManagerFactory.java:129)
at com.ibm.ws.Transaction.TransactionManagerFactory.getTransactionManager(TransactionManagerFactory.java:77)
at com.ibm.ws.wlm.client.affinity.TransactionAffinityModule.<init>(TransactionAffinityModule.java:176)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:79)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:43)
at java.lang.reflect.Constructor.newInstance(Constructor.java:313)
at com.ibm.ws.wlm.client.affinity.AffinityManager.<init>(AffinityManager.java:109)
at com.ibm.ws.wlm.client.WLMClientLegacyImpl.init(WLMClientLegacyImpl.java:149)
at com.ibm.ws.wlm.client.WLMClient.init(WLMClient.java:145)
at com.ibm.rmi.corba.PluginRegistry.loadPlugins(PluginRegistry.java:294)
at com.ibm.rmi.corba.ORB.initializePlugins(ORB.java:428)
at com.ibm.CORBA.iiop.ORB.initializePlugins(ORB.java:938)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1328)
at com.ibm.CORBA.iiop.ORB.orbParameters(ORB.java:1213)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1238)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1784)
at org.omg.CORBA.ORB.init(ORB.java:367)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:77)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:174)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:98)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:74)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:386)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:284)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:365)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:102)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:408)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:131)
at javax.naming.InitialContext.lookup(InitialContext.java:360)
at TestDB2DataSource.main(TestDB2DataSource.java:39)
java.lang.ClassCastException: javax.naming.Reference
at TestDB2DataSource.main(TestDB2DataSource.java:39)
连接程序中这样写的:
try{
javax.naming.Context ctx = new javax.naming.InitialContext();
javax.sql.DataSource ds =
(javax.sql.DataSource)ctx.lookup("testdatasource");
java.sql.Connection conn = ds.getConnection();
}catch(Throwable e){
e.printStackTrace();
}
其中testdatasource为数据源的JDNI名称。
--------------------编程问答-------------------- 看看这段:Unable to read required resource: implfactory.properties
java.lang.NullPointerException
这个问题应该是implfactory.properties不存在,与数据源访问没有关系。 --------------------编程问答-------------------- 没遇到过这种情况. --------------------编程问答-------------------- 接分是王道!
补充:企业软件 , WebSphere