7 Replies Latest reply on Mar 28, 2006 3:32 AM by Trevor Harris

    Embended beans not persisting

    Trevor Harris Newbie

      I have been trying to get Simple Deployment example in the tutorial to work. Running in 'create-drop' mode works fine but I am unable to get it working in update mode so that data persists between executions. The localDB.lck, localDB.log, localDB.properties and localDB.script are created.

      persisence.xml is:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence>
       <persistence-unit name="custdb">
       <jta-data-source>java:/DefaultDS</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       <property name="jboss.entity.manager.jndi.name" value="java:/custdb"/>
       </properties>
       </persistence-unit>
      </persistence>
      


      The embedded-jboss-bean.xml is:

       <bean name="DefaultDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
       <property name="driverClass">org.hsqldb.jdbcDriver</property>
       <property name="connectionURL">jdbc:hsqldb:file:/d:/data/hypersonic/localDB</property>
       <property name="userName">sa</property>
       <property name="jndiName">java:/DefaultDS</property>
       <property name="minSize">0</property>
       <property name="maxSize">10</property>
       <property name="blockingTimeout">1000</property>
       <property name="idleTimeout">100000</property>
       <property name="transactionManager"><inject bean="TransactionManager"/></property>
       <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
       <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
       </bean>
      
       <bean name="DefaultDS" class="java.lang.Object">
       <constructor factoryMethod="getDatasource">
       <factory bean="DefaultDSBootstrap"/>
       </constructor>
       </bean>
      


      Please can anyone help?


        • 1. Re: Embended beans not persisting
          Bill Burke Master

          try adding this to your beans file:

          
          <bean name="jboss:service=Hypersonic,database=localDB" class="org.jboss.jdbc.Hypersonic">
           <property name="database">localDB</property>
           <property name="inProcessMode">true</property>
          </bean>
          
          


          Make sure this is declared before the DefaultDSBootstrap.

          You'll need to pull in hsql-plugin.jar from the JBoss AS distribution. I don't know if this will work or not. I don't have time to test ATM, so it would be cool if you could do some of the legwork for me.

          Thanks!

          • 2. Re: Embended beans not persisting
            Trevor Harris Newbie

            I assume you mean HypersonicDatabse but I got the following error

            DEBUG 17-03 16:33:02,369 (KernelFactory.java:assembleNewKernel:86) -Starting JBoss Kernel construction...
            DEBUG 17-03 16:33:02,509 (KernelFactory.java:assembleNewKernel:112) -Completed JBoss Kernel construction. Duration: 140 milliseconds
            WARN 17-03 16:33:03,369 (BeanSchemaBinding.java:init:227) -You should use the 2.0 version of the Microcontainer xml. xmlns='urn:jboss:bean-deployer:2.0'
            DEBUG 17-03 16:33:03,463 (BeanXMLDeployer.java:deploy:91) -Parsing file:/D:/workspacewtp/simple_embeded/bin/embedded-jboss-beans.xml took 907 milliseconds
            DEBUG 17-03 16:33:03,728 (UserTransactionImpl.java:start:61) -new UserTx: org.jboss.ejb3.embedded.UserTransactionImpl@1d6f122
            DEBUG 17-03 16:33:03,822 (ServiceMBeanSupport.java:jbossInternalCreate:256) -Creating HypersonicDatabase
            DEBUG 17-03 16:33:03,822 (ServiceMBeanSupport.java:jbossInternalCreate:269) -Created HypersonicDatabase
            Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalStateException: Incompletely deployed:
            
            *** DEPLOYMENTS IN ERROR:
            jboss:service=Hypersonic,database=localDB -> java.lang.IllegalStateException: No 'jboss' MBeanServer found!
            
             at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:342)
             at org.jboss.tutorial.simple.Main.main(Main.java:41)
            Caused by: java.lang.IllegalStateException: Incompletely deployed:
            
            *** DEPLOYMENTS IN ERROR:
            jboss:service=Hypersonic,database=localDB -> java.lang.IllegalStateException: No 'jboss' MBeanServer found!
            
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:241)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:161)
             at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:332)
             ... 1 more
            DEBUG 17-03 16:33:03,822 (ServiceMBeanSupport.java:jbossInternalStart:285) -Starting HypersonicDatabase
            DEBUG 17-03 16:33:03,900 (ServiceMBeanSupport.java:jbossInternalStart:295) -Starting failed HypersonicDatabase
            java.lang.IllegalStateException: No 'jboss' MBeanServer found!
             at org.jboss.mx.util.MBeanServerLocator.locateJBoss(MBeanServerLocator.java:122)
             at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:308)
             at org.jboss.system.server.ServerConfigLocator.locate(ServerConfigLocator.java:40)
             at org.jboss.jdbc.HypersonicDatabase.startStandaloneDatabase(HypersonicDatabase.java:586)
             at org.jboss.jdbc.HypersonicDatabase.startService(HypersonicDatabase.java:552)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
             at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:196)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.joinpoint.plugins.reflect.ReflectMethodJoinPoint.dispatch(ReflectMethodJoinPoint.java:72)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextActions.dispatchJoinPoint(KernelControllerContextActions.java:96)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$LifecycleAction.installAction(KernelControllerContextActions.java:476)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$KernelControllerContextAction.install(KernelControllerContextActions.java:171)
             at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
             at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:593)
             at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:346)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:438)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:379)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:225)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:151)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:291)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:261)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:117)
             at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:95)
             at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:331)
             at org.jboss.tutorial.simple.Main.main(Main.java:41)
            ERROR 17-03 16:33:03,916 (AbstractController.java:incrementState:350) -Error installing to Start: name=jboss:service=Hypersonic,database=localDB state=Create
            java.lang.IllegalStateException: No 'jboss' MBeanServer found!
             at org.jboss.mx.util.MBeanServerLocator.locateJBoss(MBeanServerLocator.java:122)
             at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:308)
             at org.jboss.system.server.ServerConfigLocator.locate(ServerConfigLocator.java:40)
             at org.jboss.jdbc.HypersonicDatabase.startStandaloneDatabase(HypersonicDatabase.java:586)
             at org.jboss.jdbc.HypersonicDatabase.startService(HypersonicDatabase.java:552)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
             at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:196)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.joinpoint.plugins.reflect.ReflectMethodJoinPoint.dispatch(ReflectMethodJoinPoint.java:72)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextActions.dispatchJoinPoint(KernelControllerContextActions.java:96)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$LifecycleAction.installAction(KernelControllerContextActions.java:476)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$KernelControllerContextAction.install(KernelControllerContextActions.java:171)
             at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
             at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:593)
             at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:346)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:438)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:379)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:225)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:151)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:291)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:261)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:117)
             at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:95)
             at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:331)
             at org.jboss.tutorial.simple.Main.main(Main.java:41)
            DEBUG 17-03 16:33:03,916 (ServiceMBeanSupport.java:jbossInternalDestroy:341) -Destroying HypersonicDatabase
            DEBUG 17-03 16:33:03,916 (ServiceMBeanSupport.java:jbossInternalDestroy:352) -Destroyed HypersonicDatabase
            INFO 17-03 16:33:03,994 (LocalTxDataSource.java:bindConnectionFactory:117) -Bound datasource to JNDI name 'java:/DefaultDS'
            DEBUG 17-03 16:33:03,994 (BeanXMLDeployer.java:deploy:98) -Deploying file:/D:/workspacewtp/simple_embeded/bin/embedded-jboss-beans.xml took 1438 milliseconds
            

            regards trevor


            • 3. Re: Embended beans not persisting
              Bill Burke Master

              Ok, fixed in CVS. You should be able to use this in your distro by following these direcitons:

              http://jira.jboss.com/jira/browse/EJBTHREE-482

              • 4. Re: Embended beans not persisting
                Matt Lewis Newbie

                I have tried the new jar and followed the instructions.It no longer throws an exception but it still does not persist.

                embedded-jboss-heans.xml:

                 <bean class="org.jboss.jdbc.HypersonicDatabase"
                 name="jboss:service=Hypersonic,database=localDB">
                 <property name="database">localDB</property>
                 <property name="inProcessMode">true</property>
                 <property name="dbDataDir">.</property>
                 </bean>
                
                
                 <bean name="DefaultDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
                 <property name="driverClass">org.hsqldb.jdbcDriver</property>
                 <property name="connectionURL">jdbc:hsqldb:file:./hypersonic/localDB</property>
                 <property name="userName">sa</property>
                 <property name="jndiName">java:/DefaultDS</property>
                 <property name="minSize">0</property>
                 <property name="maxSize">10</property>
                 <property name="blockingTimeout">1000</property>
                 <property name="idleTimeout">100000</property>
                 <property name="transactionManager"><inject bean="TransactionManager"/></property>
                 <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
                 <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
                 </bean>
                
                 <bean name="DefaultDS" class="java.lang.Object">
                 <constructor factoryMethod="getDatasource">
                 <factory bean="DefaultDSBootstrap"/>
                 </constructor>
                 </bean>
                


                persitence.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <persistence>
                 <persistence-unit name="custdb">
                 <jta-data-source>java:/DefaultDS</jta-data-source>
                 <properties>
                 <property name="hibernate.hbm2ddl.auto" value="update"/>
                 <property name="jboss.entity.manager.jndi.name" value="java:/custdb"/>
                 </properties>
                 </persistence-unit>
                </persistence>
                


                default.persistence.properties
                hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
                hibernate.connection.release_mode=after_statement
                hibernate.transaction.flush_before_completion=true
                hibernate.transaction.auto_close_session=false
                hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
                #hibernate.hbm2ddl.auto=create-drop
                hibernate.hbm2ddl.auto=update
                hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
                # Clustered cache with TreeCache
                #hibernate.cache.provider_class=org.jboss.ejb3.entity.TreeCacheProviderHook
                #hibernate.treecache.mbean.object_name=jboss.cache:service=EJB3EntityTreeCache
                #hibernate.dialect=org.hibernate.dialect.HSQLDialect
                hibernate.jndi.java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                hibernate.jndi.java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                hibernate.cglib.use_reflection_optimizer=false
                


                Regards trevor


                • 5. Re: Embended beans not persisting
                  Trevor Harris Newbie

                  I have just tried this with an Oracle database and it works fine. I still cannet get it to save to a hypersonic file.

                  • 6. Re: Embended beans not persisting
                    Trevor Harris Newbie

                    The new jar works in remote mode ie commented out inProcessMode but
                    still fails in inProcessMode.

                    Regards Trevor

                    • 7. Re: Embended beans not persisting
                      Trevor Harris Newbie

                      I have got the hsqldb file persistance working. I just added
                      EJB3StandaloneBootstrap.shutdown(); to main. Infact I added it in a finally block. This needs to be added to the simple_embedded example.

                      Thanks for your help