Connection MetaData Sensor not working with WAS
The connection metadata sensor apparently does not work with the websphere application server 8.0. It seems like the access to the metadata is done in the initialization of the connection rather upon the execution and usage of it.
The exception upon the execution of the getMetaData method is:
My guess is that some state is then set wrong on the connection and thus afterwards a nullpointerexception is thrown.
We need to take a look if we can access this information later on.
: as discussed, please rewrite to access the metadata not in the constructor but while executing the sql statement
, I agree with Patrice.. We need to go away from the constructor.. I would opt in doing it but only problem I see is executing the getConnection -> getMetaData every time.. Though the data should be in the cache, so also acceptable.. So I say yes.. Stefan?
Still not working:
And after looking at the code, I'm questioning the whole approach. Why are we going for the get meta data the moment a connection is created? I don't think that it is a must that the real connection is already established. Why not go for the standard connection hook with the prepare statement method extract the meta data? Because the javadoc states that at this point isClosed is false and thus we should get the information.
The same stands true for a Statement. There is a getConnection method which can be called to get the connection and then execute getmetadata on it. For sure, we can check if we really need to execute the methods as it would suffice to do it one time.
If we have a look on the stack trace:
it's obvious that instance being created is T4XAConnection but there are 2 more super constructors being called.. As we are having the following configuration:
my impression is that all three constructors will be instrumented. As we are trying to get the metadata already on the super-super one, it seams like the object is not yet created and then it fails due to the SqlException that the connection is closed. My impression is that connection is maybe set as open after the other two constructors are done as well.
Note that you can not call getMetaData on closed connection:
The easiest proposal would imo be to add a check for
on the connection before getting the meta data.. As all constructors should be instrumented, then the connection would be added to the storage when the last one is done. This must work imo..