JDBC and Alfresco

492 views
Skip to first unread message

Nick Nagels

unread,
Sep 22, 2011, 2:32:30 AM9/22/11
to javam...@googlegroups.com
Hi,

I was trying to set up javamelody within Alfresco in a tomcat environment and cannot seem to get JDBC monitoring working.

The datasource bean below is used and the connection settings are in a properties file.

<bean id="defaultDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName">
            <value>${db.driver}</value>
        </property>
        <property name="url">
            <value>${db.url}</value>
        </property>
        <property name="username">
            <value>${db.username}</value>
        </property>
        <property name="password">
            <value>${db.password}</value>
        </property>


I get this error: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

So it does not seem to pick up the properties,  it can however find the datasource reference and the application works as it should

Jdbc DataSource: java:comp/env/jdbc/dataSource which is the correct database reference name

Any ideas? It might be related to Alfresco, but I am hoping someone here got this working.

Thanks in advance

Emeric Vernat

unread,
Sep 24, 2011, 11:45:15 AM9/24/11
to javam...@googlegroups.com
Hi,

It is quite strange that you speak about a dataSource from jndi (java:comp/env/jdbc/dataSource), given that you give a datasource configuration from a Spring context file which uses org.apache.commons.dbcp.BasicDataSource directly and which does not use your jndi datasource.

But anyway, we can probably ignore the jndi dataSource and use Spring to monitor the "defaultDataSource".
For that, you don't have to change the jdbc driver: you do not have to use net.bull.javamelody.JdbcDriver.

You can simply add "classpath:net/bull/javamelody/monitoring-spring.xml" in the web.xml file: open the web.xml file and find the contextConfigLocation, then add the monitoring-spring.xml like this :
        <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>
                classpath:net/bull/javamelody/monitoring-spring.xml
		...
It should be enough to monitor the "defaultDataSource" from your spring context and so the sql requests (because monitoring-spring.xml contains a post-processor for DataSources).
Note that I have not tested it myself with Alfresco.

Reference:
http://code.google.com/p/javamelody/wiki/UserGuide#7._JDBC


By the way, you could also probably monitor various beans of Alfresco from your Spring context, see the following chapter:
http://code.google.com/p/javamelody/wiki/UserGuide#9._Business_facades_%28if_Spring%29
You will have to define a pointcut based on an Alfresco interface or based on a jdk regexp for example. And it's up to you to find the beans which can and should be monitored.

bye,
Emeric
Reply all
Reply to author
Forward
0 new messages