Hey Coldboxers,
I have a very puzzling problem with a plugin I am writing…
Firstly the plugin is based on Mark Mandel’s asyncHTTP project that you can download here:
http://www.compoundtheory.com/?action=asynchttp.index
Here is my directory structure for the plugin:
–plugins
– -- AsyncHTTP-lib
– -- – asyncHTTP.jar
– -- AsyncHTTP.cfc
– -- ExternalJavaLoader (FIX)
Here is a working version of the plugin:
/**
- Provides an Asynchronous HTTP service
*/
component extends=“coldbox.system.Plugin” singleton=“true”{
/* original */ //property name=“jl” inject=“coldbox:plugin:JavaLoader”;
property name=“asyncHTTP”;
AsyncHTTP function init(required any controller){
super.init(arguments.controller);
// Plugin Properties
setPluginName(“AsyncHTTP”);
setPluginVersion(“1.0”);
setPluginDescription(“Provides an Asynchronous HTTP service”);
setPluginAuthor(“Mark Mandel - Tom Van Schoor”);
setPluginAuthorURL(“http://www.compoundtheory.com/?action=asynchttp.index”);
return this;
}
function onDIComplete(){
var path = getDirectoryFromPath(getMetaData(this).path);
/* fix / var jl = createObject(“component”, “ExternalJavaLoader”).init([path & “AsyncHTTP-lib\asyncHTTP.jar”]);
/ original */ //jl.appendPaths(path & “\AsyncHTTP-lib”);
asyncHTTP = jl.create(“com.compoundtheory.asyncHTTP.AsyncHTTP”).init();
}
public void function get(required String url){
var URLObject = createObject(“java”, “java.net.URL”).init(arguments.url);
asyncHTTP.get(URLObject);
}
public void function post(required String url, Struct formData = {}){
var URLObject = createObject(“java”, “java.net.URL”).init(arguments.url);
cleanFormData(arguments.formData);
asyncHTTP.post(URLObject, formData);
}
private void function cleanFormData(required Struct formData){
for(var key in arguments.formData){
arguments.formData[key] = JavaCast(“string”, arguments.formData[key]);
}
}
}
As you can see on the line where it says /* fix */ I am using createObject to initialize an ExternalJavaLoader. It is actually the JavaLoader that comes with the original asyncHTTP project that I renamed so it doesn’t clash with the coldbox plugin.
This plugin works, so hooray! But I would like to use the built in JavaLoader that comes with coldbox…
To change the code to use the built in JavaLoader just comment out the /* fix / and un-comment the / original */ code…
It will now throw the error:
Application Execution ExceptionError Type: Object : [N/A]
Error Messages: Object instantiation exception.
An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. Error: ‘’.
Yet if you look at the source code that comes with the original project; the com.compoundtheory.asyncHTTP.AsyncHTTP is a normal class; not an interface nor abstract…
I find that very strange…
Ideas are more then welcome?