Ok, seeing as the JavaLoader is not available when trying to DI a Java object as a property I thought I would try it with the maps as suggested by Luis.
Here is the map
map(“timeZone”)
.noInit()
.toJava(“java.util.SimpleTimeZone”);
This throws the attached error below, but what I don’t understand is that I can comment this out restart the server. And I can still reference the java object in the code. That doesn’t make sense to me, so I am assuming that it is not needed somehow.
It would be nice if I did not have to do these mappings as it adds more work than is required.
Would be nice if I could just do
Property name=”calendar” inject=”javaloader: java.util.GregorianCalendar”;
What would also be nice is some more magic where I could also do this, could this be done or added as an enhancement sometime soon?
Property name=”calendar” inject=”javaloader: java.util.GregorianCalendar” initArg=””;
This would provide a much deeper experience enabling one to use the injection with different args and conditions, rather than making a map for each time it is required with different arguments on instantiation.
Thoughts?
Regards,
Andrew Scott
http://www.andyscott.id.au/
Andrew, just so you know, no attachment came through. Not sure if they’re permitted or not.
Crap, I was supposed to paste this in thanks Matt.
Oops! Exception Encountered
Application Execution Exception
Error Type: Autowire.AutowireException : [N/A]
Error Messages: Error autowiring system.controllers.space. Unable to find a constructor for class java.util.SimpleTimeZone that accepts parameters of type ( ‘’ ).
coldfusion.runtime.java.JavaProxy$NoSuchConstructorException: Unable to find a constructor for class java.util.SimpleTimeZone that accepts parameters of type ( ‘’ ). at coldfusion.runtime.java.JavaProxy.CreateObject(JavaProxy.java:178) at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:80) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at Statement0.evaluate(:1) at coldfusion.compiler.ExprClassLoader.evaluate(ExprClassLoader.java:143) at coldfusion.runtime.CFPage.Evaluate(CFPage.java:1759) at cfBuilder2ecfc1014423334$funcBUILDJAVACLASS.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\ioc\Builder.cfc:166) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:491) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:337) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cfInjector2ecfc173334829$funcBUILDINSTANCE.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\ioc\Injector.cfc:281) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:491) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:337) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cfNoScope2ecfc399251311$funcGETFROMSCOPE.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\ioc\scopes\NoScope.cfc:31) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:491) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:337) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cfInjector2ecfc173334829$funcGETINSTANCE.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\ioc\Injector.cfc:252) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:491) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:337) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cfBuilder2ecfc1014423334$funcGETMODELDSL.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\ioc\Builder.cfc:351) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2582) at cfBuilder2ecfc1014423334$funcBUILDDSLDEPENDENCY.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\ioc\Builder.cfc:296) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:491) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:337) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cfInjector2ecfc173334829$funcPROCESSINJECTION.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\ioc\Injector.cfc:536) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at
Regards,
Andrew Scott
http://www.andyscott.id.au/
I fixed this by delving into the builder.cfc and added a conditional on the return that seems to have fixed this.
var x = 1;
var DIArgs = arguments.mapping.getDIConstructorArguments();
var DIArgsLen = arrayLen(DIArgs);
var args = [];
// Loop Over Arguments
for(x = 1; x <= DIArgsLen; x++){
// do we have javacasting?
if( structKeyExists(DIArgs[x],“javaCast”) ){
ArrayAppend(args, “javaCast(DIArgs[#x#].javaCast, DIArgs[#x#].value)”);
}
else{
ArrayAppend(args, “DIArgs[#x#].value”);
}
}
if (arrayLen(args)) {
return evaluate(‘createObject(“java”,arguments.mapping.getPath()).init(#arrayToList(args)#)’);
} else {
return evaluate(‘createObject(“java”,arguments.mapping.getPath())’);
}
Regards,
Andrew Scott
http://www.andyscott.id.au/
Andrew, you da man!! THanks for this, I have added a ticket for this and fix according to your suggestion. Here is where I would love pull requests
Thanks
Luis F. Majano
President
Ortus Solutions, Corp
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
Thanks Luis, But I don’t have git installed as yet, I find installing it a pain in the butt.
But on a side note your welcome, I only wish I can find how to get JavaLoader loaded by the time I do it the way I want to do it in my properties definition of the component.
Regards,
Andrew Scott
http://www.andyscott.id.au/
I also, fixed the noInit(), since it was ignoring it for java objects.
Luis F. Majano
President
Ortus Solutions, Corp
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
I am commiting fixes for these in about 4 minutes, please check the solution there.
Luis F. Majano
President
Ortus Solutions, Corp
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