Version 2
    SQLException: org.jboss.util.NestedSQLException: You are trying to use
    a connection factory that has been shut down: ManagedConnectionFactory
    is null.

     

    The above error is seen when the application is using the DataSource which had been shutdown, it happens when the corresponding datasource is being redeployed while it has been in use.

     

    Let us see the code from where this error is cropping from

     

    if
    (poolingStrategy == null)
          throw
    new ResourceException(
                "You
    are trying to use a connection factory that has been shut down:
    ManagedConnectionFactory is null.");
    
    

     

    protected
    void stopService() throws Exception
    {
       //notify
    the login modules the mcf is going away, they need to look it up
    again later.
    
    
    sendNotification(new Notification(STOPPING_NOTIFICATION, getServiceName(), getNextNotificationSequenceNumber()));
    if (jaasSecurityManagerService != null && securityDomainJndiName != null)
    server.invoke(jaasSecurityManagerService,"flushAuthenticationCache", new Object[] {securityDomainJndiName }, new String[] { String.class.getName() })poolingStrategy.setConnectionListenerFactory(null);  
    poolingStrategy = null;
    
    securityDomain = null;
    ccm = null;
    }
    
    
    

    Here is the code reference

     

    http://anonsvn.jboss.org/repos/jbossas/branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java

     

     

    We can avoid this error by defining the new additional datasource in seperate -ds.xml file, this will not lead to redeployment of the existing datasources which could be in use.

    If there is a need of making the changes in the existing datasource properties then this error could not be avoided.