1. 程式人生 > >websphere8.5部署應用:不支援 userid 為空。 ERRORCODE=-4461, SQLSTATE=42815 DSRA0010E: SQL 狀態:42815,錯誤碼:-4,461

websphere8.5部署應用:不支援 userid 為空。 ERRORCODE=-4461, SQLSTATE=42815 DSRA0010E: SQL 狀態:42815,錯誤碼:-4,461

       配置的db2的資料來源通過控制檯的測試連線能夠連線成功,但是部署應用的時候就報錯了:

[16-1-6 5:45:18:894 CST]     FFDC Exception:javax.resource.spi.ResourceAllocationException SourceId:com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection ProbeId:299 Reporter:com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@a5dd63ab
javax.resource.spi.ResourceAllocationException: DSRA8100E: Unable to get a PooledConnection from the DataSource.
	at com.ibm.ejs.j2c.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:2502)
	at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1838)
	at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3802)
	at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3078)
	at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548)
	at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031)
	at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:644)
	at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:611)
	at org.eclipse.equinox.servletbridge.BridgeServlet.testWebglDS(BridgeServlet.java:120)
	at org.eclipse.equinox.servletbridge.BridgeServlet.init(BridgeServlet.java:95)
	at javax.servlet.GenericServlet.init(GenericServlet.java:161)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:338)
	at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1363)
	at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:606)
	at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:576)
	at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:425)
	at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
	at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
	at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:749)
	at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634)
	at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:426)
	at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
	at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1175)
	at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
	at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
	at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
	at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:774)
	at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2182)
	at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
	at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
	at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
	at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
	at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:994)
	at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:502)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: java.sql.SQLException: [jcc][t4][10205][11234][3.63.123] 不支援 userid 為空。 ERRORCODE=-4461, SQLSTATE=42815 DSRA0010E: SQL 狀態:42815,錯誤碼:-4,461。
	at com.ibm.db2.jcc.am.fd.a(fd.java:679)
	at com.ibm.db2.jcc.am.fd.a(fd.java:60)
	at com.ibm.db2.jcc.am.fd.a(fd.java:103)
	at com.ibm.db2.jcc.t4.b.F(b.java:2249)
	at com.ibm.db2.jcc.t4.b.g(b.java:2256)
	at com.ibm.db2.jcc.t4.b.b(b.java:785)
	at com.ibm.db2.jcc.t4.b.b(b.java:758)
	at com.ibm.db2.jcc.t4.b.a(b.java:419)
	at com.ibm.db2.jcc.t4.b.a(b.java:394)
	at com.ibm.db2.jcc.t4.b.<init>(b.java:332)
	at com.ibm.db2.jcc.DB2PooledConnection.<init>(DB2PooledConnection.java:84)
	at com.ibm.db2.jcc.DB2ConnectionPoolDataSource.getPooledConnectionX(DB2ConnectionPoolDataSource.java:347)
	at com.ibm.db2.jcc.DB2ConnectionPoolDataSource.getPooledConnection(DB2ConnectionPoolDataSource.java:130)
	at com.ibm.ws.rsadapter.spi.InternalGenericDataStoreHelper$1.run(InternalGenericDataStoreHelper.java:1353)
	at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
	at com.ibm.ws.rsadapter.spi.InternalGenericDataStoreHelper.getPooledConnection(InternalGenericDataStoreHelper.java:1372)
	at com.ibm.ws.rsadapter.spi.InternalDB2UniversalDataStoreHelper.getPooledConnection(InternalDB2UniversalDataStoreHelper.java:1821)
	at com.ibm.ws.rsadapter.spi.WSRdbDataSource.getPooledConnection(WSRdbDataSource.java:1998)
	at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.getConnection(WSManagedConnectionFactoryImpl.java:1778)
	at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1547)
	at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1103)
	at com.ibm.ejs.j2c.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:2160)
	... 35 more
	
英文的報錯資訊是這樣的:
Null userid is not supported. ERRORCODE=-4461, SQLSTATE=42815
JNDI獲取連線的程式碼:
Connection conn = null;
String jndiName = "test";
DataSource ds = null;
Object ref = null;
Context ctx = null;
String s="0";
String flag="d";
String errorMsg="";

try {
	try {
		ctx = new InitialContext();
		ref = ctx.lookup(jndiName);
		flag="f";
	} catch (Throwable localThrowable) {
		s="1";
	}
	try {
		if (ref == null)
			ref = ((Context) ctx.lookup("java:comp/env"))
					.lookup(jndiName);
	} catch (Throwable localThrowable1) {
		s="2";
	}
	if (ref == null) {
		ref = ((Context) ctx.lookup("java:comp/env"))
				.lookup("java:comp/env/" + jndiName);
	}
	ds = (DataSource) ref;

} catch (NamingException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	s="3";
} finally {
	if (ctx != null)
		try {
			ctx.close();
		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
}
if (ds != null) {
	try {

		//conn = ds.getConnection("db2admin", "qwe123!");
		conn = ds.getConnection();
		System.out.println(conn);
	} catch (SQLException e) {
		e.printStackTrace();
		flag="gg";
		errorMsg=e.getMessage();
	}
} 
       如果採用下面的方式賦予使用者名稱和密碼獲取連線就沒有問題:
conn = ds.getConnection("db2admin", "qwe123!");
     分析一下,應該是資料來源配置的有問題,就是資料庫使用者名稱和密碼沒有傳到JNDI的資料來源當中,但是為啥控制檯的測試連線能夠成功,不解??

     使用者名稱和密碼相關的:JAAS - J2C 認證資料 配置的沒有問題  後來發現:

   資源-》JDBC-》資料來源  點開配置的資料來源有下面的配置:

  

    只要在這塊元件管理的認證別名中選擇配置的JAAS - J2C 認證資料就行,如下:

   
        再次部署就成功了。

        was的異常除了輸出到logs\server1下面,還會輸出到logs\ffdc下面。