AppMapping and root paths

Under the web root I have an application directory with nothing more
than application.cfc, colboxproxy.cfc, index.cfm for a Flex app. I
have coldbox and the actuall application code in another director on
another drive. I used to have this working, but now I am receiving
errors from coldbox that it can't find things. Mainly this error:

"No handlers were found in: D:\inetpub\wwwroot\D:\application\handlers
or in . So I have no clue how you are going to run this application."

First question is, why is it appending the D:\inetput\wwwroot on the
front?

Currently I have this in the application cfc:

<cfset COLDBOX_APP_ROOT_PATH = getDirectoryFromPath("/application/
coldbox")>

<cfset COLDBOX_APP_MAPPING = "/application">

/application is a Coldfusion mapping to the application folder.

If I change the app root path to:

<cfset COLDBOX_APP_ROOT_PATH = getDirectoryFromPath("/application")>

Then it complains that it can't find the config.

Any help appreciated.

Hm, what happens if you don’t mess with the app root path, let it discover it on its own, but change the app mapping to the root of your app

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Thanks for the reply. When I change the root to this:

<cfset COLDBOX_APP_ROOT_PATH =
getDirectoryFromPath(getCurrentTemplatePath())>

I get this error:

Config file not located in conventions: config/coldbox.xml.cfm,config/
Coldbox.cfc

The config folder is in D:\application\config and the D:\application
folder is in a Coldfusion mapping as /application.

Thanks,
Jim

Add this:

  // APP MAPPINGS
  this.mappings["/"] = COLDBOX_APP_ROOT_PATH;

No dice, same error. Thanks.

Can you post your ColdBox.cfc and Application.cfc?

I am switching over to using an xml configuration to cfc
configuration, so that could very well have something to do with it,
but in this case it's saying it can't find the config, so I don't
know. I have verified that I do have a coldbox.cfc in the config
folder and the permissions on it should be correct. In any case here
is the application.cfc and after that the coldbox.cfc:

<cfcomponent extends="coldbox.system.coldbox" output="false">

  <!--- APPLICATION CFC PROPERTIES --->
  <cfset this.name = hash(getCurrentTemplatePath())>
  <cfset this.applicationName = hash(getCurrentTemplatePath())>
  <cfset this.sessionManagement = true>
  <cfset this.sessionTimeout = createTimeSpan(0,0,30,0)>

  <!--- COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE
ROOT OF YOUR COLDBOX APP --->
  <!--- <cfset COLDBOX_APP_ROOT_PATH =
getDirectoryFromPath(getCurrentTemplatePath())> --->
  <cfset COLDBOX_APP_ROOT_PATH = getDirectoryFromPath("/application")>

  <!--- COLDBOX PROPERTIES --->
  <cfset COLDBOX_CONFIG_FILE = "">

  <cfset COLDBOX_APP_MAPPING = "application">

  <!--- <cfset this.mappings["/"] = COLDBOX_APP_ROOT_PATH> --->

  <!--- on Application Start --->
  <cffunction name="onApplicationStart" returnType="boolean"
output="false">
    <cfscript>
      //Load ColdBox
      loadColdBox();

      return true;
    </cfscript>
  </cffunction>

  <!--- on Request Start --->
  <cffunction name="onRequestStart" returnType="boolean" output="true">
    <!--- *************************************************************
--->
    <cfargument name="targetPage" type="string" required="true" />
    <!--- *************************************************************
--->
    <cfsetting enablecfoutputonly="yes">

    <cfset objRequest = GetPageContext().GetRequest()>

    <!--- Reload Checks --->
    <cfset reloadChecks()>

    <!--- Process A ColdBox Request Only --->
    <cfif findNoCase('index.cfm', listLast(arguments.targetPage, '/'))>
      <cfset processColdBoxRequest()>
    </cfif>

    <!--- WHATEVER YOU WANT BELOW --->
    <cfsetting enablecfoutputonly="no">
    <cfreturn true>
  </cffunction>

  <!--- on Application End --->
  <cffunction name="onApplicationEnd" returnType="void"
output="false">
    <!--- *************************************************************
--->
    <cfargument name="applicationScope" type="struct" required="true">
    <!--- *************************************************************
--->
    <!--- WHATEVER YOU WANT BELOW --->
  </cffunction>

  <!--- on Session Start --->
  <cffunction name="onSessionStart" returnType="void"
output="false">
    <cfset super.onSessionStart()>
    <!--- WHATEVER YOU WANT BELOW --->
  </cffunction>

  <!--- on Session End --->
  <cffunction name="onSessionEnd" returnType="void" output="false">
    <!--- *************************************************************
--->
    <cfargument name="sessionScope" type="struct" required="true">
    <cfargument name="appScope" type="struct" required="false">
    <!--- *************************************************************
--->
    <cfset super.onSessionEnd(argumentCollection=arguments)>
    <!--- WHATEVER YOU WANT BELOW --->
  </cffunction>

</cfcomponent>

COLDBOX.CFC :

component
{
  void function development()
  {
    coldbox.HandlerCaching=false;
    coldbox.HandlersIndexAutoReload=true;
        coldbox.IOCObjectCaching=false;
    coldbox.DebugMode=true;
    coldbox.DebugPassword="xxx";
    coldbox.ReinitPassword="xxx";
    debugger.EnableDumpVar=true;
    coldbox.EnableColdboxLogging=true;
    coldbox.onInvalidEvent="";
    coldbox.ConfigAutoReload=true;
    coldbox.EnableBugReports=false;
    coldbox.EnableSQLLogging=true;
    coldbox.IOCFrameworkReload=true;

  }

  void function production()
  {
    HandlerCaching=true;
    coldbox.HandlersIndexAutoReload=false;
        coldbox.IOCObjectCaching=true;
    coldbox.DebugMode=false;
    coldbox.DebugPassword="xxx";
    coldbox.ReinitPassword="xxx";
    debugger.EnableDumpVar=true;
    coldbox.EnableColdboxLogging=true;
    coldbox.onInvalidEvent="";
    coldbox.ConfigAutoReload=false;
    coldbox.EnableBugReports=true;
    coldbox.EnableSQLLogging=false;
    coldbox.IOCFrameworkReload=false;

    ioc.reload = false;
    ioc.objectcaching = true;

  }

  void function configure()
  {
     coldbox =
     {
      AppName ="xxx",
      AppMapping ="D:/application",
      DebugMode =true,
      DebugPassword ="",
      // EnableColdfusionLogging ="false",
      //EnableColdboxLogging ="true",
      //ColdboxLogsLocation ="logs",
      DefaultEvent ="ehFlex.nothing",
      RequestStartHandler ="",
      RequestEndHandler ="",
      ApplicationStartHandler ="ehGeneral.onApplicationStart",
      SessionStartHandler ="",
      SessionEndHandler ="",
      UDFLibraryFile ="",
      CustomErrorTemplate ="",
      //MessageboxStyleOverride =false,
      HandlersIndexAutoReload =true,
      ConfigAutoReload =false,
      ExceptionHandler ="",
      onInvalidEvent ="",
      // MyPluginsLocation" =""
      HandlerCaching =false,
      //IOCFramework ="coldspring"
      //IOCDefinitionFile ="config/coldspring.xml.cfm"
      //IOCObjectCaching =""
      //IOCFrameworkReload =true
      RequestContextDecorator ="",
      ProxyReturnCollection =false
    };

    settings = {
      auditLogFile ="xxx.log" ,
      uploadSizeThreshold ="100000000" ,
      downloadSizeThreshold ="200000000" ,
    };

    debugger =
    {
      enableDumpVar = false,
      persistentRequestProfilers = true,
      maxPersistentRequestProfilers = 20,
      maxRCPanelQueryRows = 10,
      //Panels
      showTracerPanel = true,
      expandedTracerPanel = true,
      showInfoPanel = true,
      expandedInfoPanel = true,
      showCachePanel = true,
      expandedCachePanel = true,
      showRCPanel = true,
      expandedRCPanel = true,
      showModulesPanel = true,
      expandedModulesPanel = false
    };

    environments =
    {
      development = "xxx",
      production = "yyy"
    };

    cacheBox =
    {
      caches =
      {
        // Named cache for all coldbox event and view template caching
        template =
        {
          provider =
"coldbox.system.cache.providers.CacheBoxColdBoxProvider",
          properties =
          {
            objectDefaultTimeout = 120,
            objectDefaultLastAccessTimeout = 30,
            useLastAccessTimeouts = true,
            freeMemoryPercentageThreshold = 0,
            reapFrequency = 2,
            evictionPolicy = "LRU",
            evictCount = 2,
            maxObjects = 300,
            objectStore = "ConcurrentSoftReferenceStore" //memory sensitive
          }
        },
        sampleCache1 =
        {
          provider="coldbox.system.cache.providers.CacheBoxProvider",
          properties =
          {
            objectDefaultTimeout="20",
            useLastAccessTimeouts="false",
            reapFrequency="1",
            evictionPolicy="LFU",
            evictCount="1",
            maxObjects="100",
            objectStore="ConcurrentSoftReferenceStore"
          }
        },
        sampleCache2 =
        {
          provider = "coldbox.system.cache.providers.CFProvider"
        }
      },
    // Please note that each object store could have more configuration
properties
      scopeRegistration =
      {
        enabled = true,
        scope = "application",
        key = "cacheBox"
      },

      defaultCache =
      {
        objectDefaultTimeout = 60,
        objectDefaultLastAccessTimeout = 30,
        useLastAccessTimeouts = true,
        reapFrequency = 2,
        freeMemoryPercentageThreshold = 0,
        evictionPolicy = "LRU",
        evictCount = 1,
        maxObjects = 200,
        // Our default store is the concurrent soft reference
        objectStore = "ConcurrentSoftReferenceStore",
        // This switches the internal provider from normal cacheBox to
coldbox enabled cachebox
        coldboxEnabled = false
      }
    };

    interceptors = [
      {class="coldbox.system.interceptors.security",
            properties={rulesSource="xml",
                  rulesFile="config/securityrules.xml.cfm",
                  debugMode=true,
              validatorIOC="securityManager"}
      }
      ];

      ioc = {
      framework = "coldspring",
      reload = true,
      objectCaching = false,
      definitionFile = "config/coldspring.xml.cfm"
    };

    logBox =
    {
      // Define Appenders
      root = { levelMin="FATAL", levelMax="INFO", appenders="*" },

      appenders =
      {
        /* coldboxTracer =
        {
            class="coldbox.system.logging.appenders.ColdboxTracerAppender",
            layout="coldbox.testing.cases.logging.MockLayout",
            properties =
            {
              name = "default"
          }
          }, */
          rollingFile =
          {
  
class="coldbox.system.logging.appenders.AsyncRollingFileAppender",
          levelMax="WARN",
          levelMin="FATAL",
          properties=
          {
              filePath="/#appMapping#/logs",
              autoExpand="true",
              fileMaxSize="3000",
              fileMaxArchives="5"
          }
          }
      }
    };
  }
}

First glance...

APPLICATION.CFC:

<cfcomponent extends="coldbox.system.coldbox" output="false">

change into:

<cfcomponent output="false">

Uncomment following line:

<cfset COLDBOX_APP_ROOT_PATH =
getDirectoryFromPath(getCurrentTemplatePath())>

Comment these lines:

<cfset COLDBOX_APP_ROOT_PATH = getDirectoryFromPath("/application")>
<cfset COLDBOX_APP_MAPPING = "application">

COLDBOX.CFC:

AppMapping ="D:/application",

change into:

AppMapping = "", // Should be empty, because you use mappings set in
Application.cfc

Remove any "D:/application" ColdFusion mappings in CF-Admin.

Ernst

And uncomment this line:
<!--- <cfset this.mappings["/"] = COLDBOX_APP_ROOT_PATH> --->

A couple of things.

First, if you use the inheritance method, isn't the
extends="coldbox.system.coldbox" required?

Also, this is called from a flex app, so isn't the COLDBOX_APP_MAPPING
required?

I tried the changes otherwise, and I still get the same error.

Thanks,
Jim

Ok, after a lot of debugging I figured out something.

In the CFCApplicationLoader in the parseInvocationPaths function is
this line of code:

configStruct["HandlersPath"] = "/" & configStruct.AppMapping & "/
#fwSettingsStruct.handlersConvention#";

So it ends up putting the "/" on the front. So if there already was a
"/" on the front, you end up with two. It later performs and
ExpandPath on this, which ends up getting mangled with the "//" on the
front.

Maybe the Codbox code should be changed here to first check if there
is a leading "/" before adding one?

Jim

Ok, after more debugging I found another issue.

In the system/coldbox.cfc in the reloadChecks function is this code:

<cfif cbController.getSetting("ConfigAutoReload")>
        <cflock type="exclusive" name="#instance.appHash#"
timeout="#instance.lockTimeout#" throwontimeout="true">
          <cfif cbController.getSetting("ConfigAutoReload")>
            <cfset
cbController.getLoaderService().loadApplication(COLDBOX_CONFIG_FILE)>
            <cfif
( len(cbController.getSetting("ApplicationStartHandler")) )>
              <cfset
cbController.runEvent(cbController.getSetting("ApplicationStartHandler"),true)>
            </cfif>
          </cfif>
        </cflock>
        <cfreturn>
      </cfif>

Now look at the following line of code:

<cfset
cbController.getLoaderService().loadApplication(COLDBOX_CONFIG_FILE)>

The loadApplication function actually has two optional parameters, the
second one is the overrideAppMapping. Since this is not passed into
the loadApplication function, it ends up trying to find the config
under the web root, not the application root. Shouldn't this line of
code check for the COLDBOX_APP_MAPPING and if it exists the call the
function with the app mapping as the second argument? Like so:

<cfset
cbController.getLoaderService().loadApplication(COLDBOX_CONFIG_FILE,
COLDBOX_APP_MAPPING)>

It just seems to me that in version 3.1 if you actually have coldbox
and your application in some place that is not under the web root, it
just breaks. Like my application, all I have under the web root is
the Application.cfc, coldboxproxy.cfc and an index.cfm. Everything
else is not under the web root. I ended up having to make the above
change in the system/coldbox.cfc code and set my mappings like so:

<cfset COLDBOX_APP_ROOT_PATH = ExpandPath("/application")>
<cfset COLDBOX_CONFIG_FILE = "/application/config/Coldbox.cfc">
<cfset COLDBOX_APP_MAPPING = "application">
<cfset COLDBOX_APP_KEY = "">

I know this isn't the way it's supposed to be, but it's the only way I
could get it to work. It seemed to work fine in 3.0 using the
coldbox.xml

Thanks,
Jim

is this 3.5?

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

No, 3.1.

Jim

Can you verify on 3.5, we made some changes on this.

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Ok, I figured it out. The problem is actually in the FlexAirRemote
application template.

The Application.cfc in the template does not have the loadColdbox() in
the onApplicationStart event, so I did it the same way, thinking this
is the way it should be done. Once I included the loadColdbox,
everything was kosher.

Sorry for the hassle.

Jim