3 Replies Latest reply on May 5, 2011 11:31 AM by Emily Brand

    packaging ear with datasource and jdbc driver

    J Yang Newbie

      Hello,

      I am having problem properly packaging my ear that includes datasource and jdbc driver.

      Here is my current packaging:

      META-INF/
      META-INF/MANIFEST.MF
      mysar.sar
      mywar.war
      lib/
      lib/classes12.jar
      META-INF/jboss-app.xml
      my-oracle-ds.xml
      META-INF/application.xml
      


      jboss-app.xml
      <jboss-app>
       <loader-repository>my.app:loader=myear.ear</loader-repository>
       <module>
       <service>mysar.sar</service>
       </module>
       <module>
       <service>my-oracle-ds.xml</service>
       </module>
      ...
      


      Server starts up ok. I see datasource created. However, when I run my app which gets the DB connectino via mywar.war --> mysar.sar, I get ClassNotFoundException of the Oracle driver.
       ... 76 more
      Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
       at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
       at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:242)
       at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.getDriver(LocalManagedConnectionFactory.java:256)
      


      If I add the Oracle driver in the sar, I get a "java.lang.IllegalArgumentException: interface javax.sql.DataSource is not visible from class loader" during startup.

      I don't have this issue if I add the driver to <JBOSS_HOME>//lib, but I want all the dependent items packaged in an ear.

      Thanks,
      Jennifer

        • 1. Re: packaging ear with datasource and jdbc driver
          Alex Newbie

          I think .sar files are first to be deployed. In your case mysar.sar executes something before the rest of the files get to be deployed. That's why you get the Exception. Read more about the jboss-service.xml...


          C:\jboss-4.0.2\server\default\conf\jboss-service.xml
          ...
           <!-- ==================================================================== -->
           <!-- Deployment Scanning -->
           <!-- ==================================================================== -->
          
           <!-- An mbean for hot deployment/undeployment of archives.
           -->
           <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
           name="jboss.deployment:type=DeploymentScanner,flavor=URL">
          
           <!-- Uncomment (and comment/remove version below) to enable usage of the
           DeploymentCache
           <depends optional-attribute-name="Deployer">jboss.deployment:type=DeploymentCache</depends>
           -->
           <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>
          
           <!-- The URLComparator can be used to specify a deployment ordering
           for deployments found in a scanned directory. The class specified
           must be an implementation of java.util.Comparator, it must be able
           to compare two URL objects, and it must have a no-arg constructor.
           Two deployment comparators are shipped with JBoss:
           - org.jboss.deployment.DeploymentSorter
           Sorts by file extension, as follows:
           "sar", "service.xml", "rar", "jar", "war", "wsr", "ear", "zip",
           "*"
           - org.jboss.deployment.scanner.PrefixDeploymentSorter
           If the name portion of the url begins with 1 or more digits, those
           digits are converted to an int (ignoring leading zeroes), and
           files are deployed in that order. Files that do not start with
           any digits will be deployed first, and they will be sorted by
           extension as above with DeploymentSorter.
           -->
           <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>
           <!--
           <attribute name="URLComparator">org.jboss.deployment.scanner.PrefixDeploymentSorter</attribute>
           -->
          


          My EAR file contains META-INF/application.xml which looks like this

          <application>
           <display-name>My App</display-name>
           <module>
           <ejb>core.jar</ejb>
           </module>
           <module>
           <ejb>session.jar</ejb>
           </module>
           <module>
           <connector>services.sar</connector>
           </module>
          </application>
          



          The services.sar archive is deployed last.

          I had to configure the stuff below in my META-INF/jboss-service.xml in the services.sar file. I execute some methods right after my applications has been successfully deployed.

          <?xml version="1.0" encoding="UTF-8"?>
          <server>
          
           <mbean code="myservices.MyServiceNumberOne"
           name=":name=MyServiceNumberOne">
           </mbean>
          
           <mbean code="org.jboss.varia.scheduler.Scheduler"
           name=":service=Scheduler,name=MyServiceNumberOne">
           <attribute name="StartAtStartup">true</attribute>
           <attribute name="SchedulableMBean">:name=MyServiceNumberOne</attribute>
           <attribute name="SchedulableMBeanMethod">create()</attribute>
           <attribute name="InitialStartDate">NOW</attribute>
           <attribute name="SchedulePeriod">1</attribute>
           <attribute name="InitialRepetitions">1</attribute>
           <depends>jboss.j2ee:module=session.jar,service=EjbModule</depends>
           </mbean>
          
           <mbean code="myservices.MyServiceNumberTwo"
           name=":name=MyServiceNumberTwo">
           </mbean>
          
           <mbean code="org.jboss.varia.scheduler.Scheduler"
           name=":service=Scheduler,name=MyServiceNumberTwo">
           <attribute name="StartAtStartup">true</attribute>
           <attribute name="SchedulableMBean">:name=MyServiceNumberTwo</attribute>
           <attribute name="SchedulableMBeanMethod">create()</attribute>
           <attribute name="InitialStartDate">NOW</attribute>
           <attribute name="SchedulePeriod">1</attribute>
           <attribute name="InitialRepetitions">1</attribute>
           <depends>jboss.j2ee:module=session.jar,service=EjbModule</depends>
           </mbean>
          
          </server>
          
          


          Regards,
          Alex

          • 2. Re: packaging ear with datasource and jdbc driver
            Emily Brand Newbie

            You'll need to put your ojdbc<version>.jar in server/<profile>/lib.

            • 3. packaging ear with datasource and jdbc driver
              Emily Brand Newbie

              Try changing

               

              <connection-definition>javax.jms.ConnectionFactory</connection-definition>

               

              To

               

              <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>