2 Replies Latest reply on Aug 6, 2004 2:35 PM by joeee

    possible to include jdbc driver in ear?

    joeee

      Hi All,

      I am developing an application that will be deployed in a shared instance of JBoss at the client site, and they have asked me whether or not I could include the JDBC driver that I will need as part of the ear file I deliver to them.

      I have done a lot of search and reading documentation but have not found any information on this yet. Every doc says you need to put your driver jar in /server/lib. But my client does not want to change their configuration in this way (to avoid problems with other deployed ears I guess).

      So - the question is: is this even possible to include the driver in my ear file? This is the possibilities I could think of:

      1. Include a custom SAR file in the ear and somehow define my datasource there, with the driver included in the SAR file.

      2. Maybe use a RAR file instead, again with the driver included in the RAR.

      3. Create some kind of custom classloader to find the driver somewhere within my ear file. I have never written a classloader yet, and this would be a nonstandard thing to say the least, so I would like to avoid this if possible (unless someone can convince me that I shouldn't be scared of this!).

      So are any of these possible? I don't mind doing the work, but if anybody could give me at least a hint or a pointer to good information I would be *most* appreciative :)

      Thanks/Merci,
      Joe

        • 1. Re: possible to include jdbc driver in ear?
          genman


          If you can get a xxxx-ds.xml to deploy from within the .ear, like a .sar which can include a class path, you can probably load your driver okay.

           <jar jarfile="${ear.dir}/${project.name}.sar">
           <manifest>
           <attribute name="Class-Path"
           value="lib/dbdriver.jar"/>
           </manifest>
           <metainf dir="build" includes="jboss-service.xml"/>
           </jar>
          


          • 2. Re: possible to include jdbc driver in ear?
            joeee

            Thank you for your comment - I actually ended up doing something similar to what you have here, but rather than include a classpath attribute in the manifest, I put the driver jar in the root of the sar itself.

            This indeed works so it seems that I do not have to explicitly set a classpath to point to the driver jar, just having it in the root of the sar is enough.

            In ANTspeak:

            <target name="project-ds.sar">
             <jar jarfile="${build.dir}/${proj.name}-ds.sar">
             <metainf dir="${etc.dir}" includes="jboss-service.xml"/>
             <fileset dir="${lib.dir}/jdbc-drivers" includes="mysql*.jar"/>
             </jar>
            </target>