How to setup p6spy driver in Arquillian tests on jBoss 7.x?
-
05-07-2021 - |
سؤال
Apart from setting up the module in
JBOSS_HOME/modules/com/p6spy/main
adding p6spy.jar
and module.xml
saying:
<module xmlns="urn:jboss:module:1.0" name="com.p6spy">
<resources>
<resource-root path="p6spy.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
editing standalone-full.xml
and adding an entry under datasources/drivers
:
<driver name="p6spy" module="com.p6spy">
<xa-datasource-class>com.p6spy.engine.spy.P6SpyDriver</xa-datasource-class>
</driver>
adding module dependency in jboss-deployment-structure.xml
:
<module name="com.p6spy"/>
replacing the original driver in data source definition with p6spy
I'm still getting this error:
Caused by: java.lang.Exception:
{"JBAS014771: Services with missing/unavailable dependencies" =>
["jboss.data-source.jboss/datasources/MyDsjboss.jdbc-driver.p6spyMissing
[jboss.data-source.jboss/datasources/MyDsjboss.jdbc-driver.p6spy]"
]}
المحلول
This is a rather old question, but I answer for the sake of future readers.
You don't need p6spy, JBoss AS 7 provides spying capabilities out of the box. Two steps are required.
Put the following in logging section of your standalone.xml:
<logger category="jboss.jdbc.spy"> <level name="DEBUG"/> </logger>
Add spy=”true” attribute in your DataSource configuration as follows:
<datasource jndi-name="java:jboss/datasources/testDS" pool-name="test" enabled="true" use-java-context="true" spy="true"> <connection-url>jdbc:postgresql://localhost:5432/postgres</connection-url> <driver>postgresql</driver> <security> <user-name>postgres</user-name> <password>******</password> </security> </datasource>
That is it. You now have all database communication logged in your server.log. Spy log is actually a bit too verbose for my liking, but you do have all the information.
نصائح أخرى
Couple of things,
first, you need to find all the dependencies p6spy uses, what I could see from pom is, it uses gnu-regexp and regexp are used. JBoss doesn't add them automatically, There could be more. Add these in the jboss-deployment-structure.xml and manifest.
Second, the spy.properties file needs to be added to the resources.
Sometime back I tried to hookup JMSBridge from HornetQ with SAR module. But this was just an MBean, now you have dependency jars, and a properties file.
Hope this helps and good luck
First of all , you will need spy.properties file in you JBOSS classpath. Since the default JBoss classpath points to tools.jar and run.jar, you may need to update your jboss classpath. ex:
set JBOSS_CLASSPATH=E:\jboss-1.1.1\server\directoryX
Assuming that spy.properties in this directoryX
P6Spy will be activated for your connection pool if you define it as the way you define other jdbc drivers. For example , Inside your datasrouce definition:
<jndi-name>"your jndi name"</jndi-name>
<connection-url>"conn url"</connection-url>
**<driver-class>com.p6spy.engine.spy.P6SpyDriver</driver-class>**
<user-name>"uid"</user-name>
<password>"pswd"</password>
<!-- pool sizes-->
Good Luck.