3 Replies Latest reply on Dec 13, 2011 7:08 AM by ortolanph

    Problems with JBoss Initialization

    ortolanph Newbie

      Hi, all


           I'm facing a problem with my JBoss Initialization. I have an application that must access database when JBoss is started to perform a task, but it uses a datasource reference to start Hibernate and it fails de deploy my application. After this process my datasource is registered normally.

           What I am looking for is to find a way to register my datasource before my application is deployed. Is there a way to do that? Which XML files do I have to modify to register my datasource first and the deploy my applications? Is this possible?


           I am using JBOSS 4.2.3 (yeah, that old!).


      Thanks in advance.



        • 1. Re: Problems with JBoss Initialization
          Wolf-Dieter Fink Master

          I think I did not understand your issue.


          Normally you define a datasource with a *-ds.xml file.

          Such files are picked up before any RAR/JAR/EAR/WAR will be deployed.


          Is it that simple or am I completly wrong

          I yes please describe a bit more and attach example or log.

          • 2. Re: Problems with JBoss Initialization
            ortolanph Newbie

            Ok! Let me explain it better.


            The problem is that I am deploying my application as a SAR file and JBOSS is deploying it before instantiating the datasouce. It contains some JMX processes inside and that was the only way to deploy this kind of process.


            I've already defined a *-ds.xml file with datasource information and it's working fine.


            If it's not clear yet, I can provide the log information.



            • 3. Re: Problems with JBoss Initialization
              ortolanph Newbie

              Here's a summary of my logs and some output of it.


              1. Firstly it tries to deploy my sar project contents:



              09:36:53,708 INFO  [Version] Hibernate Annotations 3.2.1.GA

              09:36:53,718 INFO  [Environment] Hibernate 3.2.4.sp1

              09:36:53,720 INFO  [Environment] loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false}

              09:36:53,720 INFO  [Environment] Bytecode provider name : javassist

              09:36:53,724 INFO  [Environment] using JDK 1.4 java.sql.Timestamp handling

              09:36:53,785 INFO  [Configuration] configuring from resource: /hibernate.cfg.xml

              09:36:53,785 INFO  [Configuration] Configuration resource: /hibernate.cfg.xml

              09:36:53,907 INFO  [Configuration] Configured SessionFactory: null


              It's configuring my ehcache and my hibernate.


              2. It reads the Hibernate Entities


              09:36:53,972 INFO  [AnnotationBinder] Binding entity from annotated class: org.myproject.entities.MyEntityClass1

              09:36:53,998 INFO  [EntityBinder] Bind entity org.myproject.entities.MyEntityClass1 on table MYENTITYCLASS1

              09:36:54,058 INFO  [AnnotationBinder] Binding entity from annotated class: org.myproject.entities.MyEntityClass2

              09:36:54,058 INFO  [EntityBinder] Bind entity org.myproject.entities.MyEntityClass2 on table MYENTITYCLASS2


              3. Now it's the crash time


              09:36:55,013 INFO  [NamingHelper] JNDI InitialContext properties:{}

              09:36:55,015 FATAL [DatasourceConnectionProvider] Could not find datasource: java:MyDS

              javax.naming.NameNotFoundException: MyDS not bound


              09:36:55,023 ERROR [MainDeployer] Could not create deployment: file:/home/user/server/jboss-4.2.3.GA/server/default/deploy/my-project-1.0.0-RC2-SNAPSHOT.sar

              org.jboss.deployment.DeploymentException: - nested throwable: (java.lang.reflect.UndeclaredThrowableException)


              This is when a Singleton will try to instantiate some objects. In this process it'll access the database, but the datasource is not instantiated.


              4. And finally, the datasource is instantiated


              09:36:58,386 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MyDS' to JNDI name 'java:MyDS'


              5. JBOSS warns me about incomplete deploys...


              --- Incompletely deployed packages ---

              org.jboss.deployment.DeploymentInfo@aa687af9 { url=file:/home/user/server/jboss-4.2.3.GA/server/default/deploy/my-project-1.0.0-RC2-SNAPSHOT.sar }

                deployer: org.jboss.deployment.SARDeployer@17494c8

                status: Deployment FAILED reason: - nested throwable: (java.lang.reflect.UndeclaredThrowableException)

                state: FAILED

                watch: file:/home/user/server/jboss-4.2.3.GA/server/default/deploy/my-project-1.0.0-RC2-SNAPSHOT.sar

                altDD: null

                lastDeployed: 1323776213279

                lastModified: 1323776205000



              ... and then starts:


              09:36:59,077 INFO  [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)] Started in 16s:191ms


              This is what's happening. Any ideas? Suggestions? Comments?


              Thanks in advance.