5 Replies Latest reply on Mar 26, 2004 6:00 PM by Scott Stark

    Transparently getting a DataSource Connection Using JAAS

    Adam Maliborski Newbie

      Hi,

      JBoss: 3.2.3
      DB: SQL Server 2000
      JDBC Driver MS SQL Server JDBC Driver SP2


      I am using a J2EE application client to talk to an EJB Tier.
      The JAAS authentication and authorization in the application is working fine but I am unable to get DataSource Connections transparently.

      I want to be able to call getConnection() on the DataSource and have the username and password used in the JAAS Realm authenticate the database connection. Reason being that the client requires each user to not only log into the application with there own user/pass but also the database.

      I am attempting to use the following datasource configuration:

      <xa-datasource>
      <jndi-name>jdbc/DS</jndi-name>
      <xa-datasource-class>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</xa-datasource-class>
      <xa-datasource-property name="ServerName">Servername</xa-datasource-property>
      <xa-datasource-property name="DatabaseName">DatabaseName</xa-datasource-property>
      <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
      <user-name></user-name>

      <security-domain>jaasRealm</security-domain>
      </xa-datasource>

      When trying to call getConnection()
      I am currently getting the following Exception:

      Can anyone assist me with a resolution or an alternative solution?


      11:12:31,902 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection:
      org.jboss.resource.JBossResourceException: No matching credentials in Subject!
      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.getConnectionProperties(BaseWrapperManagedConnectionFactory.java:389)
      at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:131)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:477)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:213)
      at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:496)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:425)
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:318)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:477)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:814)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
      at au.com.company.util.dao.AbstractDAO.getConnection(AbstractDAO.java:126)
      at au.com.company.myApplication.server.administration.AdminDAO.getUserID(AdminDAO.java:405)
      at au.com.company.myApplication.server.administration.AdminController.getUserID(AdminController.java:122)
      at au.com.company.myApplication.common.command.administration.RetrieveUserIDCommand.execute(RetrieveUserIDCommand.java:66)
      at au.com.company.myApplication.common.translator.NoteTOTranslator.translateToServerForm(NoteTOTranslator.java:98)
      at au.com.company.myApplication.common.command.note.CreateNoteCommand.execute(CreateNoteCommand.java:85)
      at au.com.company.myApplication.common.FrontControllerBean.createNote(FrontControllerBean.java:438)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:534)
      11:12:31,902 ERROR [STDERR] org.jboss.util.NestedSQLException: No matching credentials in Subject!; - nested throwable: (org.jboss.resource.JBossResou
      rceException: No matching credentials in Subject!)
      11:12:31,902 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:106)
      11:12:31,902 ERROR [STDERR] at au.com.company.util.dao.AbstractDAO.getConnection(AbstractDAO.java:126)
      11:12:31,902 ERROR [STDERR] at au.com.company.myApplication.server.administration.AdminDAO.getUserID(AdminDAO.java:405)
      11:12:31,902 ERROR [STDERR] at au.com.company.myApplication.server.administration.AdminController.getUserID(AdminController.java:122)
      11:12:31,902 ERROR [STDERR] at au.com.company.myApplication.common.command.administration.RetrieveUserIDCommand.execute(RetrieveUserIDCommand.java:66)
      11:12:31,902 ERROR [STDERR] at au.com.company.myApplication.common.translator.NoteTOTranslator.translateToServerForm(NoteTOTranslator.java:98)
      11:12:31,902 ERROR [STDERR] at au.com.company.myApplication.common.command.note.CreateNoteCommand.execute(CreateNoteCommand.java:85)
      11:12:31,902 ERROR [STDERR] at au.com.company.myApplication.common.FrontControllerBean.createNote(FrontControllerBean.java:438)
      11:12:31,902 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      11:12:31,902 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      11:12:31,902 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:12:31,902 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      11:12:31,902 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      11:12:31,902 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      11:12:31,902 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      11:12:31,918 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:700)
      11:12:31,918 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      11:12:31,918 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      11:12:31,918 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:12:31,918 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      11:12:31,918 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      11:12:31,918 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      11:12:31,918 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
      11:12:31,918 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      11:12:31,918 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      11:12:31,918 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:12:31,918 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      11:12:31,918 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      11:12:31,918 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:148)
      11:12:31,918 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
      11:12:31,918 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      11:12:31,918 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      11:12:31,918 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      11:12:31,918 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)
      11:12:31,918 ERROR [STDERR] Caused by: org.jboss.resource.JBossResourceException: No matching credentials in Subject!
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.getConnectionProperties(BaseWrapperManagedConne
      ctionFactory.java:389)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.ja
      va:131)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedCon
      nectionPool.java:477)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java
      :213)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.j
      ava:496)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:425)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:318)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:477)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectio
      nManager2.java:814)
      11:12:31,918 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
      11:12:31,918 ERROR [STDERR] ... 40 more