wirebox issue on legacy non coldbox code

138 views
Skip to first unread message

dehian

unread,
Mar 19, 2015, 5:10:21 PM3/19/15
to col...@googlegroups.com
Hi,

we have an app (partially) using coldbox but also (partially) running a legacy code base.
We want to use wirebox on the legacy part and so we defined in the application.cfc that onapplicationstart wirebox should be initiated

like this =>

<cfscript>
//Load ColdBox
application.cbBootstrap = CreateObject("component","coldbox.system.Coldbox").init(COLDBOX_CONFIG_FILE,COLDBOX_APP_ROOT_PATH,COLDBOX_APP_KEY,COLDBOX_APP_MAPPING);
application.cbBootstrap.loadColdbox();
application.injector = createObject("component","coldbox.system.ioc.Injector").init();
return true;
</cfscript>

then in some legacy page we try to use the injector like this=>
<cfscript>
someModel = application.injector.getInstance("modules.some.model.something");
</cfscript>

it fails on first attempt 

Element COLDBOXDSL is undefined in a Java object of type class [Ljava.lang.String;.

 
The error occurred in //something/coldbox/system/ioc/Builder.cfc: line 318
Called from //something/coldbox/system/ioc/Injector.cfc: line 594
Called from //something/coldbox/system/ioc/Injector.cfc: line 481
Called from //something/coldbox/system/ioc/scopes/CFScopes.cfc: line 58
Called from //something/coldbox/system/ioc/Injector.cfc: line 261
Called from //something/some.cfm: line 2
Called from //something/some.cfm: line 1
316 : 				// ColdBox Context DSL
317 : 				case "ioc" : case "ocm" : case "webservice" : case "javaloader" : case "coldbox" : { 
318 : 					refLocal.dependency = instance.coldboxDSL.process(argumentCollection=arguments); break; 
319 : 				} 

but works after a refresh

any idea on what i should do to avoid this first attempt error?

Thanks for any help

Andrew Scott

unread,
Mar 19, 2015, 7:58:16 PM3/19/15
to col...@googlegroups.com
Wirebox is part of Coldbox, so there is no need to set it up again.

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/


--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/c56dfc58-f48f-493a-9e4a-e2850e5643b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis Majano

unread,
Mar 19, 2015, 8:26:01 PM3/19/15
to col...@googlegroups.com
Are you sure you are not trying to inject anything based on coldbox
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/CACLZGD%3D0y0hugmyPLMTvjer7h2M4AJhyWFAYbw01-jSyzxt5Fg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


--
Luis F. Majano
CEO
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
IECFUG Manager: http://www.iecfug.com

dehian

unread,
Mar 20, 2015, 4:20:44 AM3/20/15
to col...@googlegroups.com
As mentionned, the app is partially using coldbox
so everything goes through the same application.cfc but on requeststart if we are in some legacy cfm file we skip processing it as a coldbox request
so lines below are not executed
<cfset application.cbBootStrap.processColdBoxRequest()>
<cfset application.cbBootstrap.onRequestStart(arguments.targetPage)>

so we can say that its not linked to coldbox, i guess?



To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+unsubscribe@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/c56dfc58-f48f-493a-9e4a-e2850e5643b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+unsubscribe@googlegroups.com.

Luis Majano

unread,
Mar 20, 2015, 12:56:01 PM3/20/15
to col...@googlegroups.com, col...@googlegroups.com
Yes, the exception you are getting is when an object is requesting another object from the ColdBox application eco-system.  SO that was my question, are you reusing your entire object model?



Luis Majano

CEO
Ortus Solutions, Corp
www.ortussolutions.com


To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/c56dfc58-f48f-493a-9e4a-e2850e5643b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.


--
Luis F. Majano
CEO
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
IECFUG Manager: http://www.iecfug.com

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.

dehian

unread,
Mar 22, 2015, 5:18:52 PM3/22/15
to col...@googlegroups.com
What do you mean by are you reusing your entire object model?
if i do 
try{
someModel = application.injector.getInstance("modules.some.model.something");
}
catch{
someModel = application.injector.getInstance("modules.some.model.something");
}

it works 
so after failing once, it works 
don't understand why
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+unsubscribe@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/c56dfc58-f48f-493a-9e4a-e2850e5643b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+unsubscribe@googlegroups.com.

Luis Majano

unread,
Mar 23, 2015, 11:54:31 AM3/23/15
to col...@googlegroups.com
Ok let me rephrase. 

In your legacy app you are requesting an instance. However for some reason the exception is mentioning a dependency that requires ColdBox.this dependency can be a plugin, setting, etc.

That's why I asked why? As the dependency is expecting a running ColdBox app. If that's the case it means the app must be running so either it has to be bootstrapped or the dependency eliminated as you are in legacy mode.  

For more options, visit https://groups.google.com/d/optout.

dehian

unread,
Mar 24, 2015, 5:04:02 AM3/24/15
to col...@googlegroups.com
As i mentionned, 
this page is not processed as a coldbox request 
because when it goes to the onrequeststart method, it's detected to be a legacy file and both processColdBoxRequest() method is not exectued

below is how the application.cfc looks like 
so the only thing there is that when it's legacy code the following is not processed
<cfif( findNoCase('fw.cfm',listLast(arguments.targetPage,"/")) ) and ( not findNoCase('index.cfm',listLast(arguments.targetPage,"/")) )>
<cfset application.cbBootStrap.processColdBoxRequest()>

<!--- On Request Start via ColdBox --->
<cfset application.cbBootstrap.onRequestStart(arguments.targetPage)>
</cfif>

========>

<cfcomponent output="false">
<!--- APPLICATION CFC PROPERTIES --->
<cfset this.name = "myapp"> 
<cfset this.applicationTimeout = createTimeSpan( 1, 0, 0, 0 ) />
        <cfset this.sessionManagement = true>
<cfset this.sessionTimeout = createTimeSpan(0,0,30,0)>
<cfset this.setClientCookies = true>
<!--- COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE ROOT OF YOUR COLDBOX APP --->
<cfset COLDBOX_APP_ROOT_PATH = getDirectoryFromPath(getCurrentTemplatePath())>
<!--- The web server mapping to this application. Used for remote purposes or static purposes --->
<cfset COLDBOX_APP_MAPPING   = "">
<!--- COLDBOX PROPERTIES --->
<cfset COLDBOX_CONFIG_FILE = "">
<!--- COLDBOX APPLICATION KEY OVERRIDE --->
<cfset COLDBOX_APP_KEY = "">
<!--- on Application Start --->
<cffunction name="onApplicationStart" returnType="boolean" output="false">
<cfscript>
//Load ColdBox
application.cbBootstrap = CreateObject("component","coldbox.system.Coldbox").init(COLDBOX_CONFIG_FILE,COLDBOX_APP_ROOT_PATH,COLDBOX_APP_KEY,COLDBOX_APP_MAPPING);
application.cbBootstrap.loadColdbox();
application.injector = createObject("component","wirebox.system.ioc.Injector").init();
return true;
</cfscript>
</cffunction>
<!--- on Request Start --->
<cffunction name="onRequestStart" returnType="boolean" output="true">
<!--- ************************************************************* --->
<cfargument name="targetPage" type="string" required="true" />
<!--- ************************************************************* --->
<!--- BootStrap Reinit Check --->
<cfif not structKeyExists(application,"cbBootstrap") or application.cbBootStrap.isfwReinit()>
<cflock name="coldbox.bootstrap_#hash(getCurrentTemplatePath())#" type="exclusive" timeout="5" throwontimeout="true">
<cfset structDelete(application,"cbBootStrap")>
<cfset application.cbBootstrap = CreateObject("component","coldbox.system.Coldbox").init(COLDBOX_CONFIG_FILE,COLDBOX_APP_ROOT_PATH,COLDBOX_APP_KEY,COLDBOX_APP_MAPPING)>
</cflock>
</cfif>
<cfif( findNoCase('fw.cfm',listLast(arguments.targetPage,"/")) ) and ( not findNoCase('index.cfm',listLast(arguments.targetPage,"/")) )>
<cfset application.cbBootStrap.processColdBoxRequest()>
<!--- On Request Start via ColdBox --->
<cfset application.cbBootstrap.onRequestStart(arguments.targetPage)>
</cfif>
<cfreturn true>
</cffunction>
<!--- on Application End --->
<cffunction name="onApplicationEnd" returnType="void"  output="false">
<!--- ************************************************************* --->
<cfargument name="appScope" type="struct" required="true">
<!--- ************************************************************* --->
<cfset arguments.appScope.cbBootstrap.onApplicationEnd(argumentCollection=arguments)>
</cffunction>
<!--- on Session Start --->
<cffunction name="onSessionStart" returnType="void" output="false">
<cfset application.cbBootstrap.onSessionStart()>

</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 appScope.cbBootstrap.onSessionEnd(argumentCollection=arguments)>
</cffunction>
<!--- OnMissing Template --->
<cffunction name="onMissingTemplate" access="public" returntype="boolean" output="true" hint="I execute when a non-existing CFM page was requested.">
<cfargument name="template" type="string" required="true" hint="I am the template that the user requested."/>
<cfreturn application.cbBootstrap.onMissingTemplate(argumentCollection=arguments)>
</cffunction>
</cfcomponent>



i still don't get why it works on second attempt but anyway, what do you recommend to make it work?

Luis Majano

unread,
Mar 24, 2015, 2:37:21 PM3/24/15
to coldbox
I undersstand you are diverting the requests. I am not talking about the requests.

I am talking about your object model. The error you posted denoted that an objected requested a dependency that REQUIRED coldbox.

dehian

unread,
Mar 24, 2015, 4:57:11 PM3/24/15
to col...@googlegroups.com
but the cfm file contains only this line failing

someModel = application.injector.getInstance("modules.some.model.something");
i abort it just after for testing purpose
so what else could it be requesting?

Andrew Scott

unread,
Mar 24, 2015, 7:53:12 PM3/24/15
to col...@googlegroups.com
Ok, shows us the code for that model. But I am guessing that there is a DI being used in that model that is from a ColdBox application. The clue is that it is in the modules folder.

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/


Jason Durham

unread,
Mar 24, 2015, 9:06:56 PM3/24/15
to col...@googlegroups.com
Couldn't it also be that the model he's injecting _also_ has a dependency which requires Coldbox?  

It's odd that your path has "modules" in it.  That is a Coldbox convention.  You should be able to debug this one, just follow the trail of DI DSL in your model.  Start with "modules.some.model.something",

Jason Durham

Andrew Scott

unread,
Mar 24, 2015, 10:00:13 PM3/24/15
to col...@googlegroups.com
Jason, isn't that exactly what I said!

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/


Reply all
Reply to author
Forward
0 new messages