JBoss Community

Re: Exception when testing Oracle datasource connections

created by fibber in Datasource Configuration - View the full discussion

It seems to be a problem with the testConnection() method in org.jboss.resource.connectionmanager.JBossManagedConnectionPool because that's where the stack trace is pointing:

 

@ManagementOperation(description="Test if a connection can be obtained",
          impact=Impact.WriteOnly)


    public boolean  testConnection()
    {
       boolean result = false;
       ConnectionListener cl = null;


       // first try to get connection with Subject
       if (poolingStrategy instanceof BasePool)
       {
          BasePool basePool = (BasePool)poolingStrategy;
          if (basePool.clf instanceof BaseConnectionManager2)
          {
             try {
                BaseConnectionManager2 baseConnectionMgr = (BaseConnectionManager2)basePool.clf;

                // This is the line that is throwing the exception

                Subject subject = baseConnectionMgr.getSubjectFactory().createSubject(baseConnectionMgr.getSecurityDomainJndiName());

 

                result = internalTestConnection(subject);
             }
             catch ( Exception ignored )  // createSubject could throw security exception, ignore it
             {
             }
          }
       }


       // then try to get connection without Subject
       if (!result)
       {
          result = internalTestConnection(null);
       }
       return result;
    } http://grepcode.com/images/1x1.gif

 

 

 

Although I don't know why ignoring a security exception is a good thing, I find it strange that the exception is logged before being thrown - not always the best practice.  In any event, I'd like to know why this exception is occurring and how to get rid of it, if possible.  Of course, it's always possible that the answer is that this is simply a manifestation of some sloppiness or defect in the design, and I'll need to ignore exceptions created when I test my Oracle connection.

 

 

 

The reason that I can't currently accept this explanation is that the DefaultDS does not throw the exception when testing its connection, which leads me to believe that there is either something wrong with my Oracle datasource setup, or that the DefaultDS setup includes additional security configurations that I'm not aware of.

Reply to this message by going to Community

Start a new discussion in Datasource Configuration at Community