9 Replies Latest reply on Jul 4, 2008 10:00 AM by Marcelo Schneider

    Configuring dependencies in Services

    Marcelo Schneider Newbie

      I am using JBoss 4.2.2GA (Windows XP, Java v.1.6.0_02), trying to figure out how to use Hibernate with JBoss (started following the how-to available in http://www.hibernate.org/66.html).


      The folder structure is as follows:
      - ...\server\default\deploy
      ---------- App.war (application, expanded in a folder)
      ---------- hibernate-ds.xml (Datasource for hibernate)
      ---------- hibernate-service.sar (hibernate service, expanded)
      -------------------- META-INF
      ------------------------------ jboss-service.xml
      ------------------------------ MANIFEST.MF

      My problem is, I need the DataSource available when the hibernate-service is started, but that is not currently happening!! What am I doing wrong?

      The jboss-service.xml is (Lines I *guess* are important are in bold):

      <?xml version="1.0" encoding="UTF-8"?>
      <server>
       <mbean code="org.hibernate.jmx.HibernateService"
       name="jboss.jca:service=HibernateFactory, name=HibernateFactory">
      
       <!-- Supposed to make it deploy ONLY after DataSource had been started -->
       <depends>jboss.jca:service=RARDeployer</depends>
       <depends optional-attribute-name="datasourc">
       jboss.jca:service=LocalTxCM,name=hibernate-ds
       </depends>
       <!--
       <attribute name="MapResources">mappings/Attribute.hbm.xml</attribute>
       -->
      
       <attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
       <attribute name="Datasource">java:/hibernate-ds</attribute>
       <attribute name="Dialect">org.hibernate.dialect.Oracle9iDialect</attribute>
       <attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
       <attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
       <attribute name="UserTransactionName">UserTransaction</attribute>
      
       </mbean>
      </server>
      


      The hibernate-ds.xml...
      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>hibernate-ds</jndi-name>
      
       <connection-url>jdbc:oracle:thin:@vts68:1521:app00</connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>user</user-name>
       <password>pass</password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
      
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
       <metadata>
       <type-mapping>Oracle9i</type-mapping>
       </metadata>
       </local-tx-datasource>
      
      </datasources>
      


      The exception that is thrown:
      11:29:27,656 INFO [ServiceConfigurator] Problem configuring service jboss.jca:s
      ervice=HibernateFactory, name=HibernateFactory
      org.jboss.deployment.DeploymentException: Exception setting attribute datasourc
      = jboss.jca:service=LocalTxCM,name=hibernate-ds on mbean jboss.jca:service=Hibernat
      eFactory, name=HibernateFactory; - nested throwable: (javax.management.Attribute
      NotFoundException: not found: datasourc)
       at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:707)
       at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:382)
       at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:462)
       at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171)
       at org.jboss.system.ServiceController.install(ServiceController.java:226)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy4.install(Unknown Source)
       at org.jboss.deployment.SARDeployer.create(SARDeployer.java:249)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy9.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
       at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:417)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy5.deploy(Unknown Source)
       at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
       at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
       at org.jboss.Main.boot(Main.java:200)
       at org.jboss.Main$1.run(Main.java:508)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.management.AttributeNotFoundException: not found: datasourc
       at org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanInvoker.java:428)
       at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:608)
       at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:703)
       ... 84 more
      


      And finally the result telling me it will not work ):
      11:32:24,578 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
      
      --- Incompletely deployed packages ---
      org.jboss.deployment.DeploymentInfo@e568eb36 { url=file:/D:/jboss/server/default/deploy/App.war/ }
       deployer: MBeanProxyExt[jboss.web:service=WebServer]
       status: Deployment FAILED reason: URL file:/D:/jboss/server/default/deploy/App.war/ deployment failed
       state: FAILED
       watch: file:/D:/jboss/server/default/deploy/App.war/WEB-INF/web.xml
       altDD: null
       lastDeployed: 1215095515343
       lastModified: 1215009631000
       mbeans:
      
      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.jca:service=HibernateFactory, name=HibernateFactory
       State: FAILED
       Reason: org.jboss.deployment.DeploymentException: Exception setting attribute
       datasourc = jboss.jca:service=LocalTxCM,name=hibernate-ds on mbean jboss.jca:servic
       e=HibernateFactory, name=HibernateFactory; - nested throwable: (javax.management
       .AttributeNotFoundException: not found: datasourc)
       I Depend On:
       jboss.jca:service=RARDeployer
       jboss.jca:service=LocalTxCM,name=hibernate-ds
      
      ObjectName: jboss.web.deployment:war=App.war,id=-446108874
       State: FAILED
       Reason: org.jboss.deployment.DeploymentException: URL file:/D:/jboss/server/default/deploy/
      App.war/ deployment failed
      
      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.jca:service=HibernateFactory, name=HibernateFactory
       State: FAILED
       Reason: org.jboss.deployment.DeploymentException: Exception setting attribute
      datasourc = jboss.jca:service=LocalTxCM,name=hibernate-ds on mbean jboss.jca:servic
      e=HibernateFactory, name=HibernateFactory; - nested throwable: (javax.management
      .AttributeNotFoundException: not found: datasourc)
       I Depend On:
       jboss.jca:service=RARDeployer
       jboss.jca:service=LocalTxCM,name=hibernate-ds
      
      ObjectName: jboss.web.deployment:war=App.war,id=-446108874
       State: FAILED
       Reason: org.jboss.deployment.DeploymentException: URL file:/D:/jboss/server/default/deploy/
      App.war/ deployment failed
      



      Any help is greatly appreciated (:

        • 1. Re: Configuring dependencies in Services
          jaikiran pai Master

          Try this, instead of the lines marked in bold, in your jboss-service.xml:

          <depends>jboss.jca:service=RARDeployer</depends>
          <depends>jboss.jca:service=LocalTxCM,name=hibernate-ds</depends>
          


          • 2. Re: Configuring dependencies in Services
            Zithulele Shange Newbie

             

            javax.management.AttributeNotFoundException: not found: datasourc

            Isn't the mispelling of datasourc instead of datasource

            • 3. Re: Configuring dependencies in Services
              Marcelo Schneider Newbie

               

              "zithuba" wrote:
              Isn't the mispelling of datasourc instead of datasource


              Don't think so, the exception is the same, but whit an 'e' at the end ):



              "jaikiran" wrote:
              Try this, instead of the lines marked in bold, in your jboss-service.xml:

              <depends>jboss.jca:service=RARDeployer</depends>
              <depends>jboss.jca:service=LocalTxCM,name=hibernate-ds</depends>
              


              Tried it, and gives the following exception:


              javax.naming.NameNotFoundException: hibernate-ds not bound
               at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
               at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
               at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
               at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
               at javax.naming.InitialContext.lookup(InitialContext.java:392)
               at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
               at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
               at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
               at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
               at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
               at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
               at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
               at org.hibernate.jmx.HibernateService.buildSessionFactory(HibernateService.java:64)
               at org.hibernate.jmx.HibernateService.start(HibernateService.java:40)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:995)
              
              ........ // lots of exception lines here
              
              
              08:29:49,171 INFO [HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: Could not find datasource
              08:29:49,218 INFO [SessionFactoryObjectFactory] Factory name: java:/hibernate/HibernateFactory
              08:29:49,218 INFO [NamingHelper] JNDI InitialContext properties:{}
              08:29:49,218 INFO [NamingHelper] Creating subcontext: hibernate
              08:29:49,218 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/hibernate/HibernateFactory
              08:29:49,218 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
              08:29:49,234 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=hibernate-ds' to JNDI name 'java:hibernate-ds'
              08:29:51,609 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
              08:29:51,718 WARN [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.startupWarning] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.startupWarning] You have chosen to enable multiple last resources in the transaction manager. This is transactionally unsafe and should not be relied upon.
              08:29:52,140 INFO [A] Bound to JNDI name: queue/A
              
              ...
              
              
              


              From what I could understand, it is starting the Datasource right after the service, right?

              • 4. Re: Configuring dependencies in Services
                Zithulele Shange Newbie

                Yes, There is another topic dealing with this deployment problem, where a DS is deployed after the dependent ear or war.
                http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162523#4162523

                • 5. Re: Configuring dependencies in Services
                  jaikiran pai Master

                   

                  "zithuba" wrote:
                  Yes, There is another topic dealing with this deployment problem, where a DS is deployed after the dependent ear or war.
                  http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162523#4162523


                  Probably not :)

                  Marcelo.S_ is using JBoss-4.2.2 GA and not JBoss-5.0 CR1. From what i know, the datasource dependencies work fine in 4.2.2 GA. We just have to figure out the correct "depends" value to use.


                  • 6. Re: Configuring dependencies in Services
                    Marcelo Schneider Newbie

                     

                    "jaikiran" wrote:
                    "zithuba" wrote:
                    Yes, There is another topic dealing with this deployment problem, where a DS is deployed after the dependent ear or war.
                    http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162523#4162523


                    Probably not :)

                    Marcelo.S_ is using JBoss-4.2.2 GA and not JBoss-5.0 CR1. From what i know, the datasource dependencies work fine in 4.2.2 GA. We just have to figure out the correct "depends" value to use.


                    Was just taking a look at those topics:
                    http://www.jboss.com/index.html?module=bb&op=viewtopic&t=138587
                    http://www.jboss.com/index.html?module=bb&op=viewtopic&t=138584

                    It might not be the same cause, however it made me take a look at \server\default\conf\jboss-service.xml:

                    <!-- 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>
                     -->
                    


                    Just renamed hibernate-service.sar to hibernate-service.jar and it worked as a charm. I'm still curious thought, since the dependencies should work and renaming isn't really the best alternative.

                    • 7. Re: Configuring dependencies in Services
                      Marcelo Schneider Newbie

                      Oddly enough, when I try to deploy my App.war (was trying without the "looking up" before) it loads before hibernate-service.jar and does not work since it cannot find the service:

                      10:10:22,468 INFO [Catalina] Server startup in 87 ms
                      10:10:22,625 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=.../deploy/jboss-w
                      eb.deployer/ROOT.war/
                      10:10:23,625 INFO [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=.../deploy/
                      http-invoker.sar/invoker.war/
                      10:10:23,828 INFO [TomcatDeployer] deploy, ctxPath=/jbossws, warUrl=.../deploy/
                      jbossws.sar/jbossws-context.war/
                      10:10:24,515 INFO [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=.../
                      deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/
                      10:10:27,609 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=.../dep
                      loy/management/console-mgr.sar/web-console.war/
                      
                      ...
                      
                      10:10:36,375 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
                      oss.jca:service=DataSourceBinding,name=hibernate-ds' to JNDI name 'java:hibernate-ds'
                      
                      ...
                      
                      10:13:15,000 INFO [TomcatDeployer] deploy, ctxPath=/App, warUrl=.../deploy/App.war/
                      10:13:18,750 ERROR [HibernateUtil] Erro inicializando SessionFactory
                      javax.naming.NameNotFoundException: hibernate not bound
                       at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                       at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                       at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                       at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
                       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
                       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
                       at javax.naming.InitialContext.lookup(InitialContext.java:392)
                       at dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.jav
                      a:31)
                      
                      ... // Lots of exceptions since App cannot load data
                       // Don't know why, but in this case hibernate-service.jar will not load
                      
                      
                      


                      In my HibernateUtils.java I have:

                       static {
                       try {
                       Context ctx = new InitialContext();
                       sessionFactory = (SessionFactory) ctx.lookup("java:/hibernate/HibernateFactory");
                      
                       } catch (Throwable ex) {
                       log.error("Erro inicializando SessionFactory", ex);
                       throw new ExceptionInInitializerError(ex);
                       }
                       }
                      


                      That means, I cannot have hibernate-service.sar since it will fail to load because of the datasource; and cannot have hibernate-service.jar because the application will load first. Guess I'm back to the place I started!

                      So, any hints of how to make this dependencies in the jboss-service.xml work?

                      • 8. Re: Configuring dependencies in Services
                        jaikiran pai Master

                         

                        "Marcelo.S_" wrote:

                        That means, I cannot have hibernate-service.sar since it will fail to load because of the datasource;


                        The sar approach with datasource dependency should work. As i already mentioned, its all about getting the "depends" attribute right. Here's what the dependency in the jboss-service.xml should look like:
                        
                        <depends>jboss.jca:service=RARDeployer</depends>
                        <depends>jboss.jca:service=LocalTxCM,name=hibernate-ds</depends>
                        <depends>jboss.jca:name=hibernate-ds,service=DataSourceBinding</depends>
                        


                        Try it out and see if it works.

                        • 9. Re: Configuring dependencies in Services
                          Marcelo Schneider Newbie

                           

                          "jaikiran" wrote:
                          "Marcelo.S_" wrote:

                          That means, I cannot have hibernate-service.sar since it will fail to load because of the datasource;


                          The sar approach with datasource dependency should work. As i already mentioned, its all about getting the "depends" attribute right. Here's what the dependency in the jboss-service.xml should look like:
                          
                          <depends>jboss.jca:service=RARDeployer</depends>
                          <depends>jboss.jca:service=LocalTxCM,name=hibernate-ds</depends>
                          <depends>jboss.jca:name=hibernate-ds,service=DataSourceBinding</depends>
                          


                          Try it out and see if it works.


                          There we go! I was missing this line:
                          <depends>jboss.jca:name=hibernate-ds,service=DataSourceBinding</depends>


                          So it would simply not work. Thanks for the help!