/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.camunda.bpm.container.impl.tomcat.deployment;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.camunda.bpm.container.impl.jmx.deployment.AbstractParseBpmPlatformXmlStep;
import org.camunda.bpm.container.impl.jmx.kernel.MBeanDeploymentOperation;
import org.camunda.bpm.engine.ProcessEngineException;

/**
 * <p>This deployment operation step is responsible for parsing and attaching the bpm-platform.xml file on tomcat.</p>
 * 
 * <p>We assume that the bpm-platform.xml file is located under <code>$CATALINA_HOME/conf/bpm-platform.xml</code>.</p>
 * 
 * @author Daniel Meyer
 *
 */
public class TomcatParseBpmPlatformXmlStep extends AbstractParseBpmPlatformXmlStep {

  protected URL getBpmPlatformXmlStream(MBeanDeploymentOperation operationcontext) {
    
    // read file from CATALINA_HOME directory.
    String catalinaHome = System.getProperty("catalina.home");
    String bpmPlatformFileLocation = catalinaHome + File.separator + "conf" + File.separator + "bpm-platform.xml";
    
    File bpmPlatformFile = new File(bpmPlatformFileLocation);
    
    if(bpmPlatformFile.exists()) {
      try {
        return bpmPlatformFile.toURI().toURL();
        
      } catch (MalformedURLException e) {
        throw new ProcessEngineException("Cannot construct URL for "+bpmPlatformFile, e);
        
      }
      
    } else {
      throw new ProcessEngineException(bpmPlatformFileLocation + " does not exist. This file is necessary for deploying the camunda BPM platform");
      
    }
  }


}

@@ -618,90 +618,8 @@
 t;%0A%0A
-import java.io.File;%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL;%0A%0A
 impo
@@ -700,16 +700,16 @@
 mlStep;%0A
+
 import o
@@ -830,16 +830,98 @@
 ption;%0A%0A
+import java.io.File;%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL;%0A%0A
 /**%0A * %3C
@@ -1391,16 +1391,48 @@
 le from 
+CATALINA_BASE if set, otherwise 
 CATALINA
@@ -1507,15 +1507,112 @@
 ina.
-home%22);
+base%22);%0A    if (catalinaHome == null) %7B%0A      catalinaHome = System.getProperty(%22catalina.home%22);%0A    %7D%0A
 %0A   

Check for CATALINA_BASE too