CS-14856: upgrade script:schema-2214to30.sql fails while upgrading CS 2.2.14 to Bonita

http://bugs.cloudstack.org/browse/CS-14856

- Problem is with the awsapi webapp being loaded first in tomcat before cloudstack webapp. There is no way this order can be controlled.

- We are not supporting upgrades for awsapi feature

- The solution is awsapi will check if the db exists during initialization. If not, the webapp will fail to load. Error loading the webapp can be seen in the catalina.out output.

- But this should not affect CloudStack db upgrade.
This commit is contained in:
prachi 2012-05-14 15:37:45 -07:00
parent b4b10dc5bc
commit e3cf8a6140
6 changed files with 24 additions and 18 deletions

View File

@ -10,7 +10,6 @@
<!-- transactiion isolation level : 1 - read uncommitted, 2 - read committed, 4 - repeatable read, 8 - Serializable -->
<property name="hibernate.connection.isolation">2</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.order_updates">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

View File

@ -10,7 +10,6 @@
<!-- transactiion isolation level : 1 - read uncommitted, 2 - read committed, 4 - repeatable read, 8 - Serializable -->
<property name="hibernate.connection.isolation">2</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.order_updates">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

View File

@ -18,6 +18,9 @@ package com.cloud.bridge.lifecycle;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.ServiceLifeCycle;
import org.apache.log4j.Logger;
import com.cloud.bridge.persist.dao.UserCredentialsDao;
import com.cloud.bridge.service.controller.s3.ServiceProvider;
@ -29,13 +32,23 @@ import com.cloud.bridge.service.controller.s3.ServiceProvider;
*/
public class ServiceEngineLifecycle implements ServiceLifeCycle {
private static final long serialVersionUID = -249114759030608486L;
public static final Logger logger = Logger.getLogger(ServiceEngineLifecycle.class);
private static boolean initialized = false;
public void startUp(ConfigurationContext config, AxisService service) {
// initialize service provider during Axis engine startup
ServiceProvider.getInstance();
try{
UserCredentialsDao.preCheckTableExistence();
ServiceProvider.getInstance();
ServiceEngineLifecycle.initialized = true;
}catch(Exception e){
logger.error("Error initializing awsapi: "+ e.getMessage());
}
}
public void shutDown(ConfigurationContext config, AxisService service) {
ServiceProvider.getInstance().shutdown();
if(ServiceEngineLifecycle.initialized){
ServiceProvider.getInstance().shutdown();
}
}
};

View File

@ -139,13 +139,9 @@ public class UserCredentialsDao extends BaseDao{
conn = null;
}
public static void preCheckTableExistence() {
public static void preCheckTableExistence() throws Exception{
UserCredentialsDao dao = new UserCredentialsDao();
try {
dao.checkTableExistence();
} catch (Exception e) {
e.printStackTrace();
}
dao.checkTableExistence();
}
private void checkTableExistence() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {

View File

@ -40,12 +40,11 @@ public class EC2MainServlet extends HttpServlet{
if(value != null){
isEC2APIEnabled = Boolean.valueOf(value);
}
}finally {
PersistContext.commitTransaction(true);
PersistContext.commitTransaction(true);
PersistContext.closeSession(true);
}
}catch(Exception e){
throw new ServletException("Error initializing awsapi: " + e.getMessage());
}
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {

View File

@ -115,10 +115,10 @@ public class S3RestServlet extends HttpServlet {
if(value != null) {
isS3APIEnabled = Boolean.valueOf(value);
}
}finally {
PersistContext.commitTransaction(true);
PersistContext.commitTransaction(true);
PersistContext.closeSession(true);
}catch(Exception e){
throw new ServletException("Error initializing awsapi: " + e.getMessage());
}
}