7 Replies Latest reply on Nov 27, 2001 10:39 PM by Mark Desrosier

    JDBC RAR Format

    James Cook Newbie

      I have seen the XML descriptor used to configure a JDBC connection for the new 3.0 version, however I haven't actually seen the format of the RAR file.

      Do I put my JDBC jar file and this XML file info a RAR archive and deploy it? I wish I could find the RAR file that seems to deploy HSQL.


        • 1. Re: JDBC RAR Format
          David Jencks Master

          Ok, lets step back a second.

          If you have a complete jca connector (the jca name for a driver), it will be packaged in a rar file by the connector provider. You don't need to mess with this file at all, ever. It contains a ra.xml file describing the classes implementing the interfaces to the outside world (app server), the properties you can set on a driver instance, and some info about security. The rar file also contains a jar file (yes, nested jars, since the rar is a jar-compressed file too) with the classes needed for the connector.

          When you deploy a rar, you get the ability to set up ConnectionFactories from that rar, in jboss by deploying ConnectionFactoryLoader mbeans. These contain the info such as which db instance you are connecting to, pool configuration, etc.

          Now lets look at how this works with jdbc drivers. Typically db vendors have not yet provided a jca connector (the only one I know of is the one I wrote much of for firebird). However (imitating sun's example connectors), Aaron Mulder has written two jca-jdbc wrapper connectors, for jdbc 1 and xa-capable jdbc drivers. So what you do to use a jdbc driver is, in the ConnectionFactoryLoader mbean config, use one of these wrapper rars as your resource adapter, and include the info about which driver you want, the connection url, etc, as part of the ManagedConnectionFactoryConfiguration.

          So, you still have to get your jdbc driver on the classpath. You have basically 2 choices: put it in lib/ext and include it in a classpath element of your mydb-service.xml file that contains the ConnectionFactoryLoader mbean, or, if you are pretty sure you will only have one db pool using this driver (or know all of them now), package the jdbc driver and the (now renamed to) jboss-service.xml with the mbean config into a .sar, so you only have one thing to deploy. HSQL uses the first choice.

          If you want to look at the wrapper connectors, they are in connector/..../adaptors/jdbc...

          (Just when you get used to the current configuration, I'm about to change it again to make the dependencies a little more explicit.)

          • 2. Re: JDBC RAR Format
            James Cook Newbie

            Where can I find your Firebird rar. Does it exist in pre-compiled form for the Win32 platform? Couldn't find it on any of the firebird/interbase websites.

            • 3. Re: JDBC RAR Format
              David Jencks Master

              Right now the firebird jca-jdbc driver is only in cvs at firebird.sourceforge.net under client-java. You have to compile it yourself, using the build.xml in the src/build directory.
              Some people have complained about the binary downloads from the lib directories (ant, junit, etc) not working under windows. If this happens it's probably easiest to get equivalents from a jboss download.

              I've only tried this driver under linux. For my personal copy of jboss 3, including several things I'm working on not in cvs, about 1/2 the testsuite passes.

              • 4. Re: JDBC RAR Format
                Mark Desrosier Newbie

                I'm confused.

                Your post implies that I need to create a SAR to JDBC resource. However, http://www.jboss.org/online-manual/HTML/ch03s12.html, and modified it to match my db (changed URL, userid, and password)

                • 5. Re: JDBC RAR Format
                  Mark Desrosier Newbie

                  > I'm confused.
                  > Your post implies that I need to create a SAR to use a JDBC
                  > resource. However,
                  > http://www.jboss.org/online-manual/HTML/ch03s12.html has an example that I
                  > modified to match my db (changed URL, userid,
                  > and password)

                  <<< oops! posted before I was finished>>>>

                  I'm using the Oracle example and I'm using the Jboss-3.0.0alpha.

                  The example sez to put the jdbc driver in the lib/ext and to put the file (oracledb-service.xml) in the deploy directory.

                  No sar needed?

                  This works as expected with one exception, Oracle's driver is packaged in a zip, classes12.zip, and I get the following error on start-up:

                  [14:53:39,000,AutoDeployer] Auto-deploying file:/C:/jboss-3.0.0alpha/deploy/test1-service.xml
                  [14:53:39,000,AutoDeployer] Auto deploy of file:/C:/jboss-3.0.0alpha/deploy/test1-service.xml
                  [14:53:39,031,ServiceCreator] About to create the beanJBOSS-SYSTEM:service=ConnectionFactoryLoader,name=OracleDB
                  [14:53:39,031,ServiceCreator] Created the beanJBOSS-SYSTEM:service=ConnectionFactoryLoader,name=OracleDB
                  [14:53:39,046,ConnectionFactoryLoader] Starting
                  [14:53:39,046,OracleDB] Not setting config property 'TransactionIsolation'
                  [14:53:39,046,OracleDB] Not setting config property 'Password'
                  [14:53:39,078,JDBCManagedConnectionFactory] Unable to load JDBC driver 'oracle.jdbc.driver.OracleDriver'
                  java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
                  at org.jboss.system.ServiceLibraries.loadClass(ServiceLibraries.java:372)
                  at org.jboss.system.URLClassLoader.loadClass(URLClassLoader.java:111)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
                  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
                  at java.lang.Class.forName0(Native Method)
                  at java.lang.Class.forName(Class.java:120)
                  at org.jboss.resource.adapter.jdbc.local.JDBCManagedConnectionFactory.setDriverClass(JDBCManagedConnectionFactory.java:134)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at org.jboss.resource.ConnectionFactoryLoader.loadConnectionFactory(ConnectionFactoryLoader.java:590)
                  at org.jboss.resource.ConnectionFactoryLoader.startService(ConnectionFactoryLoader.java:406)
                  at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:117)

                  I tried adding classes12.zip to the "classpath archives" in conf/default/jboss-service.xml but that did not help.

                  Any idea's on why the class can not be found?

                  • 6. Re: JDBC RAR Format
                    David Jencks Master

                    No sar is needed. There was a problem with the ServiceDeployer which made it only deploy jars, not zips, when referenced in the classpath element. David Maplesden fixed this in cvs yesterday, so updating and recompiling should help. Alternatively renaming the zip to a jar should work.

                    If you could confirm that this does (or doesn't) work I would appreciate it -- Oracle drivers seem to be tricky, more info in the manual would be better.

                    david jencks

                    • 7. Re: JDBC RAR Format
                      Mark Desrosier Newbie

                      I renamed classes12.zip to classes12.jar and the OracleDriver class is found!

                      I'm currently just trying to run our applications that are deployed on JBoss-2.4.3 using ejb 1.1. I'm running simple tests as we have not yet created a JUnit suite. The test case is failing and I'm tracking down why.