3 Replies Latest reply on Mar 14, 2002 10:15 AM by Steve Maring

    servlet to MySQL DataSource problems

    Steve Maring Newbie

      I have an ear containing a war with a servlet that needs access to a DataSource defined in jboss.jcml. I've tried two different methods to config the DS and niether seem to work:

      1) XADataSourceLoader method:


      org.gjt.mm.mysql.Driver



      GnuAC_DS
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

      jdbc:mysql://localhost/gnuac
      1200000
      GnuACUser
      10
      password
      false
      false
      false
      true
      120000
      1800000
      false
      false
      1.0
      0


      this hangs on startup at:
      ...
      [INFO,JdbcProvider] Starting
      [INFO,JdbcProvider] Started
      [INFO,GnuAC_DS] Starting
      [INFO,GnuAC_DS] XA Connection pool GnuAC_DS bound to java:/GnuAC_DS


      2) ConnectionFactoryLoader method:

      JBOSS-SYSTEM:service=Naming
      JBOSS-SYSTEM:service=TransactionManager
      JCA:service=ConnectionManagerFactoryLoader,name=MinervaSharedLocalCMFactory
      JCA:service=RARDeployer

      #
      XADataSourceClass=org.gjt.mm.mysql.jdbc2.optional.MysqlXADataSource
      XADataSourceProperties=serverName=localhost;databaseName=gnuac;port=3306
      ConnectionURL=jdbc:mysql://localhost:3306/gnuac
      UserName=GnuACUser
      Password=password

      GnuAC_DS
      java:/TransactionManager
      Minerva JDBC LocalTransaction ResourceAdapter
      JCA:service=RARDeployer
      MinervaSharedLocalCMFactory
      #
      InvalidateOnError=false
      BlockingTimeoutMillis=500000
      IdleTimeoutMillis=1800000
      MaxSize=10
      TimestampUsed=false
      IdleTimeoutEnabled=false
      CleanupIntervalMillis=120000
      MinSize=0
      GCMinIdleMillis=1200000
      GCEnabled=false
      MaxIdleTimeoutPercent=1.0


      org.jboss.resource.security.ManyToOnePrincipalMapping




      Complaints during startup include:

      [INFO,RARDeployer] Attempting to deploy RAR at 'file:/usr/local/JBoss-2.4.4_Tomcat-4.0.1/jboss/deploy/lib/jbosspool-jdbc.rar'
      [INFO,RARMetaData] Loading Minerva Resource Adapter for JDBC 1/2 drivers
      [INFO,RARMetaData] Required license terms present. See deployment descriptor.
      [WARN,MinervaDS] Not setting config property 'Driver'
      [WARN,MinervaDS] Not setting config property 'Password'
      [WARN,MinervaDS] Not setting config property 'UserName'
      [INFO,MinervaDS] Bound connection factory for resource adapter 'Minerva JDBC LocalTransaction ResourceAdapter' to JNDI name 'java:/MinervaDS'
      [WARN,null] Not setting config property 'Driver'
      [WARN,null] Not setting config property 'ConnectionURL'
      [WARN,null] Not setting config property 'Password'
      [WARN,null] Not setting config property 'UserName'
      [INFO,null] Bound connection factory for resource adapter 'Minerva JDBC LocalTransaction ResourceAdapter' to JNDI name 'java:/null'


      and the servlet lookup throws a [ERROR,Default] javax.naming.NameNotFoundException: GnuAC_DS not bound


      from servlet:
      dataSource = (DataSource) context.lookup( "java:comp/env/jdbc/GnuAC_DS" );


      <web-app>
      <display-name>Gnu A/C Web App</display-name>

      <servlet-name>AccountManager</servlet-name>
      <servlet-class>org.gnuac.account.AccountManager</servlet-class>

      <resource-ref>
      Gnu A/C DataSource
      <res-ref-name>jdbc/GnuAC_DS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      </web-app>

      <jboss-web>
      <resource-ref>
      <res-ref-name>jdbc/GnuAC_DS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <jndi-name>java:/GnuAC_DS</jndi-name>
      </resource-ref>
      </jboss-web>


      Any help getting either one of these senarios to work would be greatly appriciated.

      Thanks.
      -Steve Maring

        • 1. Re: servlet to MySQL DataSource problems
          David Jencks Master

          Next time start by clearly stating which jboss version you are using. As indicated in the online manual, the jboss 3 configuration is rather different from the jboss 2.4 configuration. You have a bizarre mixture of the two styles, and I can't really guess which version you are trying to use.

          Also, you are running your servlet container in the same vm as jboss, aren't you?

          Have you checked the mbeans to see what state they are in and jndiview to see if anything got bound?

          • 2. Re: servlet to MySQL DataSource problems
            Steve Maring Newbie

            Sorry 'bout that. I guess the JBoss-2.4.4_Tomcat-4.0.1 dirctory reference was buried kind of deep.

            And yes, apparently I overlooked the reference at the beginning of the chapter that I was reading on JDBC configuration with JCA that read "this primarily applies to JBoss 3.0". Second oops.

            I'm starting to wonder if the driver version I'm using, mm.mysql-2.0.11-bin.jar, is buggy.

            The DefaultDS XADataSource starts fine.

            • 3. Re: servlet to MySQL DataSource problems
              Steve Maring Newbie

              I trimmed it down a bit and got past where it hangs. I think the properties weren't timing out the connection soon enough to see connection problems.


              GnuAC_DS
              org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
              jdbc:mysql://localhost:3306/gnuac
              GnuACUser
              password


              Now I know that their are connection problems. I just don't find this exception too informative:


              [INFO,GnuAC_DS] XA Connection pool GnuAC_DS bound to java:/GnuAC_DS
              [ERROR,GnuAC_DS] Stopped
              java.lang.NullPointerException
              at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(Unknown Source)
              at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:412)
              at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
              at java.lang.reflect.Method.invoke(Native Method)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
              at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.java:967)
              at $Proxy0.start(Unknown Source)
              at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
              at java.lang.reflect.Method.invoke(Native Method)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
              at org.jboss.Main.(Main.java:208)
              at org.jboss.Main$1.run(Main.java:110)
              at java.security.AccessController.doPrivileged(Native Method)
              at org.jboss.Main.main(Main.java:106)