7 Replies Latest reply on Dec 11, 2007 7:37 AM by Ales Justin

    Porting Hibernate MBean / deployer

    Ales Justin Master

      org.jboss.hibernate.jmx.Hibernate 'deployer' uses this piece of code:

       private URL determineHarUrl() throws Exception
       {
       log.trace( "Attempting to determine HarUrl..." );
       DeploymentInfo deploymentInfo = getDeploymentInfo();
       if ( deploymentInfo == null )
       {
       log.warn( "Unable to locate deployment info [" + getServiceName() + "]" );
       return null;
       }
      

      the interesting/critical part is this method:
       public DeploymentInfo getDeploymentInfo()
       throws JMException
       {
       Object[] args = {serviceName};
       String[] sig = {serviceName.getClass().getName()};
       DeploymentInfo sdi = (DeploymentInfo) server.invoke(SARDeployerMBean.OBJECT_NAME,
       "getService", args, sig);
       return sdi;
       }
      

      Which returns null, since old SARDeployer isn't used anymore, hence empty ObjectName --> DeploymentInfo map.

      Is there an equivalent thing?
      Or should I go and write new deployer from scratch?

      But since this class isn't really a true deployer, it's a simple MBean that knew how to do a URL lookup for entities, ... how to resemble between regualar mbeans and Hibernate mbean / 'deployer'?

      We can force the Hibernate users to declare this mbean in a renamed file, instead of jboss-service.xml it could be simple hibernate.xml.

      Any ideas on this port?

        • 1. Re: Porting Hibernate MBean / deployer
          Ales Justin Master

          I'm able to get all the Hibernate tests running/working, except this one, which gives me insufficient information to resolve:

          Client side:

          Testsuite: org.jboss.test.hibernate.test.HibernateIntgUnitTestCase
          Tests run: 2, Failures: 0, Errors: 1, Time elapsed: 6,313 sec
          ------------- Standard Error -----------------
          Found log4j.xml: file:/C:/projects/jboss5/trunk/testsuite/output/resources/log4j.xml
          ------------- ---------------- ---------------
          
          Testcase: testRedeployment took 2,39 sec
          Testcase: testCurrentSession took 0,078 sec
           Caused an ERROR
          EJBException:; nested exception is:
           javax.ejb.EJBException: Error performing store
          java.rmi.ServerException: EJBException:; nested exception is:
           javax.ejb.EJBException: Error performing store
           at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:365)
           at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:209)
           at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
           at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:651)
           at org.jboss.ejb.Container.invoke(Container.java:1013)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:230)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
           at $Proxy17.invoke(Unknown Source)
           at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:771)
           at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
           at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:387)
           at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
          Caused by: javax.ejb.EJBException: Error performing store
           at org.jboss.test.hibernate.ejb.ProfileBean.storeUser(ProfileBean.java:63)
           at org.jboss.invocation.Invocation.performCall(Invocation.java:386)
           at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:228)
           at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
           at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:174)
           at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
           at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
           at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
           at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
           at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:228)
           at org.jboss.ejb.plugins.security.PreSecurityInterceptor.invoke(PreSecurityInterceptor.java:84)
           at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
           at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
           at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:651)
           at org.jboss.ejb.Container.invoke(Container.java:1013)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:230)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
           at $Proxy17.invoke(Unknown Source)
           at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:771)
           at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
           at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:387)
           at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
           at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
           at org.jboss.remoting.Client.invoke(Client.java:1634)
           at org.jboss.remoting.Client.invoke(Client.java:548)
           at org.jboss.invocation.unified.interfaces.UnifiedInvokerProxy.invoke(UnifiedInvokerProxy.java:162)
           at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:244)
           at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:181)
           at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
           at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:86)
           at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:112)
           at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:101)
           at $Proxy3.storeUser(Unknown Source)
           at org.jboss.test.hibernate.test.HibernateIntgUnitTestCase.testCurrentSession(HibernateIntgUnitTestCase.java:210)
           at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
           at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
           at junit.extensions.TestSetup.run(TestSetup.java:25)
          Caused by: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
           at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
           at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
           at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
           at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
           at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
           at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
           at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
           at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
           at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
           at org.jboss.test.hibernate.ProfileService.storeUser(ProfileService.java:70)
           at org.jboss.test.hibernate.ejb.ProfileBean.storeUser(ProfileBean.java:59)
           at org.jboss.invocation.Invocation.performCall(Invocation.java:386)
           at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:228)
           at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
           at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:174)
           at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
           at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
           at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
           at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
           at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:228)
           at org.jboss.ejb.plugins.security.PreSecurityInterceptor.invoke(PreSecurityInterceptor.java:84)
           at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
           at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
           at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:651)
           at org.jboss.ejb.Container.invoke(Container.java:1013)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:230)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
           at $Proxy17.invoke(Unknown Source)
           at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:771)
           at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
           at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:387)
           at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
          Caused by: java.sql.BatchUpdateException: failed batch
           at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
           at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
           at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:476)
           at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:518)
           at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
           at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
           ... 48 more
          
          


          Server side:
          00:11:14,671 DEBUG [JDBCExceptionReporter] Could not execute JDBC batch update [insert into user (timeOfLastUpdate, handle, "password", email, timeOfCreation, firstName, "initial", lastName, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]
          java.sql.BatchUpdateException: failed batch
           at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
           at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
           at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:476)
           at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:518)
           at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
           at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
           at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
           at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
           at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
           at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
           at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
           at org.jboss.test.hibernate.ProfileService.storeUser(ProfileService.java:70)
           at org.jboss.test.hibernate.ejb.ProfileBean.storeUser(ProfileBean.java:59)
           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:585)
           at org.jboss.invocation.Invocation.performCall(Invocation.java:386)
           at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:228)
           at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
           at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:174)
           at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
           at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
           at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
           at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
           at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:228)
           at org.jboss.ejb.plugins.security.PreSecurityInterceptor.invoke(PreSecurityInterceptor.java:84)
           at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
           at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
           at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:651)
           at org.jboss.ejb.Container.invoke(Container.java:1013)
           at sun.reflect.GeneratedMethodAccessor128.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:230)
           at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           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:668)
           at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
           at $Proxy17.invoke(Unknown Source)
           at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:771)
           at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
           at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:387)
           at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
          00:11:14,671 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
          00:11:14,671 ERROR [JDBCExceptionReporter] failed batch
          


          Why would an insert fail?

          • 2. Re: Porting Hibernate MBean / deployer
            Steve Ebersole Apprentice

            Could you turn off batching and try it again?

            • 3. Re: Porting Hibernate MBean / deployer
              Ales Justin Master

              Aha, forgot.
              I didn't change that much, just how scanning is done against VFS.
              A visitor patter collects all the possible mapping files from the CL urls, and adds them to the CFG via InputStream.

              • 4. Re: Porting Hibernate MBean / deployer
                Ales Justin Master

                 

                "steve.ebersole@jboss.com" wrote:
                Could you turn off batching and try it again?

                00:44:49,562 DEBUG [JDBCExceptionReporter] could not insert: [org.jboss.test.hibernate.model.User] [insert into user (timeOfLastUpdate, handle, "password", email, timeOfCreation, firstName, "initial", lastName, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]
                java.sql.SQLException: Violation of unique constraint SYS_CT_135: duplicate value(s) for column(s) $$ in statement [insert into user (timeOfLastUpdate, handle, "password", email, timeOfCreation, firstName, "initial", lastName, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]
                


                • 6. Re: Porting Hibernate MBean / deployer
                  Scott Stark Master

                  The question is how are we getting into that state?

                  • 7. Re: Porting Hibernate MBean / deployer
                    Ales Justin Master

                    Did this test ever worked?
                    Since the test itself was broken.
                    The user wasn't deleted/removed after the first test method, so when you tried to save user with the same handle in next test method, it of course complained.

                    This is now fixed by deleting the user after first test method.