0 Replies Latest reply on Feb 14, 2006 2:21 PM by Michael Moran

    Portal 2.2 AS 4.0.3sp1 - JTATransactionFactory is hard coded

    Michael Moran Newbie

      Can anyone tell me why the SessionFactoryBinder hard codes the hibernate.transaction.factory_class property with org.hibernate.transaction.JTATransactionFactory

      I am trying to manage my own transaction and cannot seem to get JBoss Portal to let me. I commented out all of the transaction interceptors in jboss-service.xml, as well as the the BMT entries for stateless session beans in standardjboss.xml but then Hibernatre fails to close connections even though I have close statements in finally blocks.

      If I leave in the CachedConnectionInterceptor, the connections close but I still get the following errors

      Error 1:
      09:49:34,890 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@1be18e2
      java.lang.Throwable: STACKTRACE
      at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:333)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:482)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:894)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:73)
      at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
      at org.hibernate.jdbc.JDBCContext.userConnection(JDBCContext.java:114)
      at org.hibernate.impl.SessionImpl.connection(SessionImpl.java:366)
      at com.agistics.platform.service.data.ejb.DataServicesBean.getSession(DataServicesBean.java:374)
      at com.agistics.platform.service.data.ejb.DataServicesBean.uniqueQuery(DataServicesBean.java:115)
      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:345)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:873)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:415)
      at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
      at $Proxy138.uniqueQuery(Unknown Source)

      Error 2
      09:49:35,046 INFO [NoTxConnectionManager] Throwable from unregisterConnection
      java.lang.IllegalStateException: Trying to return an unknown connection2! org.jboss.resource.adapter.jdbc.WrappedConnection@1be18e2
      at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:385)
      at org.jboss.resource.connectionmanager.NoTxConnectionManager$NoTxConnectionEventListener.connectionClosed(NoTxConnectionManager.java:93)
      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:247)
      at org.jboss.resource.adapter.jdbc.WrappedConnection.close(WrappedConnection.java:111)
      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.resource.connectionmanager.CachedConnectionManager.closeConnection(CachedConnectionManager.java:585)
      at org.jboss.resource.connectionmanager.CachedConnectionManager.closeAll(CachedConnectionManager.java:480)
      at org.jboss.resource.connectionmanager.CachedConnectionManager.popMetaAwareObject(CachedConnectionManager.java:299)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:153)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:873)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:415)
      at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
      at $Proxy138.uniqueQuery(Unknown Source)

      First Session bean:
       protected String createProfileInternal(Entity e, Profile p) throws ProfileException {
       try {
       DataServicesLocal dataServices = dataServicesLocalHome.create();
      
       VersionedModelBase vmb = profileToPojo(e, p);
      
       String query = SQLGenerator.getEntityByProfile(e, p);
       ModelBase model = dataServices.uniqueQuery(query);
       if (model != null) {
       throw new DuplicateProfileException();
       }
      
       dataServices.save( vmb );
       return vmb.getGuid();
       } catch (ProfileException pe) {
       throw pe;
       } catch (Exception other) {
       log.error("createProfileInternal: error occurred while creating new profile", other);
       throw new ProfileException(other.getMessage());
       }
       }
      
      


      public ModelBase uniqueQuery(String queryString) throws EJBException {
       // find a unique result based on the input query
       Session session = getSession();
       ModelBase result = null;
       try {
       Query query = session.createQuery(queryString);
       result = (ModelBase)query.uniqueResult();
       } catch (HibernateException e) {
       String message = "DataServices: uniqueQuery failed: " + queryString;
       log.error(message, e);
       }
       finally {
       session.close();
       }
       return result;
       }
      
      
       protected Session getSession() {
       Session session = null;
       try {
       SessionFactory sf = (SessionFactory) new InitialContext()
       .lookup(SESSION_FACTORY);
      
       session = session = sf.openSession();
       session.connection().setAutoCommit(false);
      
       return session;
       } catch (NamingException e) {
       log.error(e);
       throw new RuntimeException("DataServicesBean: Cannot get Hibernate session.");
       } catch (SQLException e) {
       String message = "DataServices: SQLException: " + e.getMessage();
       log.error(message, e);
       }
       return session;
       }
      
      


      Any help is greatly appreciated.