0 Replies Latest reply on Jan 17, 2003 1:21 PM by michaelukpong

    ] Managed Connection equals Null! Problems in JBOSS 3.0.3 an

    michaelukpong

      The .remove() method of some Entity beans I wrote and
      deployed in JBoss 3.0.0 is now throwing a "Managed
      Connection = null" exception in Jboss 3.0.3.

      I earlier noticed that these entities gave a "you are not
      getting the semantics you expect" warning (both in
      Jboss 3.0.0 and 3.0.3) but I ignored this warning in
      Jboss 3.0.0. Could this be the cause of the exception
      now thrown in Jboss 3.0.3?

      The funny thing is that if you keep looping on the remove
      (), where the number of iterations is the record length of
      the underlying table + 1, it eventually works! So its like
      the managed connection is restored after a certain
      number of failed attempts. What could this mean?

      Note that this remove() method is NOT called directly
      from a servlet, but through a stateless session bean.

      The bean is uses BMP

      #!!!!!!!Here is the Session bean level Method that calls the
      remove it is Stateless

      public void deletePortal(Integer portalID) throws
      PortalException {

      PortalSettingsHome portalSettingsHome;
      PortalRolesHome portalRolesHome;
      PortalUsersHome portalUsersHome;
      PortalsHome portalsHome;

      java.util.Iterator i;

      try{
      portalSettingsHome = (PortalSettingsHome)
      EjbUtilities.getHome("portal/PortalSettings",
      PortalSettingsHome.class);
      portalRolesHome = (PortalRolesHome)
      EjbUtilities.getHome("portal/PortalRoles",
      PortalRolesHome.class);
      portalUsersHome = (PortalUsersHome)
      EjbUtilities.getHome("portal/PortalUsers",
      PortalUsersHome.class);
      portalsHome = (PortalsHome) EjbUtilities.getHome
      ("portal/Portals", PortalsHome.class);

      // remove some dependencies

      i = portalSettingsHome.findByPortal
      (portalID).iterator();
      while(i.hasNext()){
      ((com.sw.portal.entity.portalSetting.PortalSettings)
      i.next()).remove();
      }

      i = portalRolesHome.findByPortal(portalID).iterator();
      while(i.hasNext()){
      ((PortalRoles)i.next()).remove();
      }

      i = portalUsersHome.findByPortal
      (portalID).iterator();
      while(i.hasNext()){
      ((PortalUsers)i.next()).remove();
      }

      //finally, remove the Portal

      portalsHome.findByPrimaryKey(portalID).remove(); //
      Here is where the exception is thrown

      } catch (Exception e) {
      throw new PortalException(e.getMessage());
      }

      }

      #!!!!!!! Here is the Entity bean level remove method it is a BMP

      public void ejbRemove() {
      try
      {
      String sqlStmt = "DELETE FROM Portals WHERE
      PortalID = ? ";
      con = ds.getConnection();
      PreparedStatement stmt = con.prepareStatement
      (sqlStmt);

      stmt.setInt(1, portalID);
      stmt.executeUpdate();
      stmt.close();

      }catch (Exception e)
      {
      throw new EJBException(e);
      }finally
      {
      try
      {
      if (con != null)
      {
      con.close();
      }
      } catch (SQLException sqle) {}
      }
      }


      Here is a code fragment of the exception

      java.lang.IllegalArgumentException: disconnect
      (ManagedConnection mc: null, Object c:
      org.jboss.resource.adapter.jdbc.local.LocalConnection@70ad
      76) called with unknown managed connection at
      org.jboss.resource.connectionmanager.BaseConnectionMana
      ger2.unregisterAssociation
      (BaseConnectionManager2.java:661) at
      org.jboss.resource.connectionmanager.BaseConnectionMana
      ger2.disconnect(BaseConnectionManager2.java:619) at
      org.jboss.resource.connectionmanager.CachedConnectionMa
      nager.disconnect(CachedConnectionManager.java:371) at
      org.jboss.resource.connectionmanager.CachedConnectionMa
      nager.popMetaAwareObject
      (CachedConnectionManager.java:160) at
      org.jboss.resource.connectionmanager.CachedConnectionInte
      rceptor.invoke(CachedConnectionInterceptor.java:190) at
      org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke
      (EntityReentranceInterceptor.java:64) at
      org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke
      (EntityInstanceInterceptor.java:152) at
      org.jboss.ejb.plugins.EntityLockInterceptor.invoke
      (EntityLockInterceptor.java:107) at
      org.jboss.ejb.plugins.EntityCreationInterceptor.invoke
      (EntityCreationInterceptor.java:69) at
      org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
      (AbstractTxInterceptor.java:107) at
      org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions
      (TxInterceptorCMT.java:178) at
      org.jboss.ejb.plugins.TxInterceptorCMT.invoke
      (TxInterceptorCMT.java:60) at
      org.jboss.ejb.plugins.SecurityInterceptor.invoke
      (SecurityInterceptor.java:130) at
      org.jboss.ejb.plugins.LogInterceptor.invoke
      (LogInterceptor.java:203) at
      org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.Container.invoke(Container.java:712) at
      org.jboss.ejb.EntityContainer.invoke
      (EntityContainer.java:1058) at
      org.jboss.mx.server.MBeanServerImpl.invoke
      (MBeanServerImpl.java:517) at
      org.jboss.invocation.local.LocalInvoker.invoke
      (LocalInvoker.java:98) at
      org.jboss.invocation.InvokerInterceptor.invoke
      (InvokerInterceptor.java:102) at
      org.jboss.proxy.TransactionInterceptor.invoke
      (TransactionInterceptor.java:77) at
      org.jboss.proxy.SecurityInterceptor.invoke
      (SecurityInterceptor.java:80) at
      org.jboss.proxy.ejb.EntityInterceptor.invoke
      (EntityInterceptor.java:116) at
      org.jboss.proxy.ClientContainer.invoke
      (ClientContainer.java:76) at $Proxy282.remove(Unknown
      Source) at
      com.sw.portal.session.PortalManagerBean.deletePortal
      (Unknown Source) at java.lang.reflect.Method.invoke(Native
      Method) at
      org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor
      .invoke(StatelessSessionContainer.java:660) at
      org.jboss.resource.connectionmanager.CachedConnectionInte
      rceptor.invoke(CachedConnectionInterceptor.java:186) at
      org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.inv
      oke(StatelessSessionInstanceInterceptor.java:77) at
      org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
      (AbstractTxInterceptor.java:107) at
      org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions
      (TxInterceptorCMT.java:178) at
      org.jboss.ejb.plugins.TxInterceptorCMT.invoke
      (TxInterceptorCMT.java:60) at
      org.jboss.ejb.plugins.SecurityInterceptor.invoke
      (SecurityInterceptor.java:130) at
      org.jboss.ejb.plugins.LogInterceptor.invoke
      (LogInterceptor.java:203) at
      org.jboss.ejb.StatelessSessionContainer.invoke
      (StatelessSessionContainer.java:313) at
      org.jboss.ejb.Container.invoke(Container.java:712) at
      org.jboss.mx.server.MBeanServerImpl.invoke
      (MBeanServerImpl.java:517) at
      org.jboss.invocation.local.LocalInvoker.invoke
      (LocalInvoker.java:98) at
      org.jboss.invocation.InvokerInterceptor.invoke
      (InvokerInterceptor.java:102) at
      org.jboss.proxy.TransactionInterceptor.invoke
      (TransactionInterceptor.java:77) at
      org.jboss.proxy.SecurityInterceptor.invoke
      (SecurityInterceptor.java:80) at
      org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke
      (StatelessSessionInterceptor.java:111) at
      org.jboss.proxy.ClientContainer.invoke
      (ClientContainer.java:76) at $Proxy275.deletePortal(Unknown
      Source) at
      com.sw.admin.module.admin.AdminModuleBean.deletePortal
      s(Unknown Source) at
      com.sw.admin.module.admin.AdminModuleBean.execute
      (Unknown Source)