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-》数据源  点开配置的数据源有下面的配置:

  websphere8.5部署应用:不支持 userid 为空。 ERRORCODE=-4461, SQLSTATE=42815 DSRA0010E: SQL 状态:42815,错误码:-4,461_第1张图片

    只要在这块组件管理的认证别名中选择配置的JAAS - J2C 认证数据就行,如下:

   websphere8.5部署应用:不支持 userid 为空。 ERRORCODE=-4461, SQLSTATE=42815 DSRA0010E: SQL 状态:42815,错误码:-4,461_第2张图片
        再次部署就成功了。

        was的异常除了输出到logs\server1下面,还会输出到logs\ffdc下面。

        参考资料:https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014674820

       

你可能感兴趣的:(db2,websphere,数据源,为空,不支持,userid)