1 Reply Latest reply on Dec 1, 2004 9:12 AM by michael.maurer

    Database drivers can't be found by MBean

    muhr

      On JBoss 4.0.0 I have an MBean that I want to manually create and manage database connections through a custom pooling object (I know JBoss has facilities to handle this, but I need to be doing things this way). This MBean is meant to broker activity between ejbs and the database.

      I have created the MBean and contained it within a jar (mbeans.jar).

      I have created a SAR theat contains this jar and its dependancies (mbeans.sar)

      This deploye properly, and the MBean start() method does what it is supposed to... it creates a pool of connections for the specified data source (postgreSQL database). The problem I am having is that after startup, whether through an EJB or manually using the jmx-console to invoke a query method on the MBean, it chokes finding the database driver JAR file. I get a wonderful javax.management.MBeanException caused by a java.sql.SQLException that complains about there being no suitable driver.

      Now, I have tried everything I can think of to help this MBean find the database driver, with absolutely no luck. I have included the driver JAR in:

      mbeans.jar, where the MBean objects are kept
      mbeans.sar, where the MBean objects are deployed
      in the web application WAR
      in the web application EAR
      in the JBoss lib directory
      in the jboss/server/all/lib directory (running from all)

      I have tried these individually, all together, and each permutation of some and not others that are possible, and the MBean still can't find the driver. What am I doing wrong?

      On a side note, the MBean seems unable to find custom Exception classes (inheriting from org.apache.commons.lang.exception.NestableException) that are thrown by its helper classes on failure, regardless of their inclusion in the mbean JAR, SAR, or any of the application archives listed above. ClassDefNotFoundException every time.

      hHere is the stack trace from the query attempt through the MBean:

      2004-11-18 18:14:11,781 ERROR [org.jboss.web.localhost.Engine] StandardWrapperValve[HtmlAdaptor]: Servlet.service() for servlet HtmlAdaptor threw exception
      javax.management.MBeanException
      at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:166)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:149)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:236)
      at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:202)
      at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:241)
      at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:79)
      at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:61)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
      at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.Exception: Couldn't retrieve data source: No suitable driver
      at com.mine.common.mbean.DataManager.query(DataManager.java:134)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      ... 42 more
      Caused by: java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:46)
      at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
      at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:771)
      at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
      at com.mine.common.mbean.DataManager.query(DataManager.java:123)
      ... 47 more

      this is driving me nuts... anyone have an idea?

        • 1. Re: Database drivers can't be found by MBean
          michael.maurer

          The jboss-service.xml file in the MbeanSar sould look like this :

          <server>
           <mbean code="at.tugraz.genome.marsservice.ServerSettings"
           name="at.tugraz.genome.marsservice:service=ServerSettings">
           <attribute name="JNDIName">java:/MARSServerSettings</attribute>
           <depends>jboss.jca:service=DataSourceBinding,name=jdbc/DefaultDS</depends>
           </mbean>
          </server>
          

          Then it worked for me