Search code examples
javacoldfusionjavaloader

How do you tell the reference path when loading a class?


I'm trying to use JavaLoader to load a java (HttpAsyncClient) class into ColdFusion.

client = loader.create("org.apache.commons.HttpAsyncClient")

How do we know the reference that is org.apache.commons.HttpAsyncClient? I thought if you open the jar file and follow the directory structure, it will give you the reference path. But I don't think this is true.

I'm trying to use the HttpAsyncClient but I'm unable to load it:

client = loader.create("org.apache.commons.HttpAsyncClient") returns a class not found error.

Loader is a reference to JavaLoader, which loads Java classes into your CF server.


Solution

  • Rather than reinvent the wheel, why not try an existing tool like Mark Mandel's AsyncHTTP library?

    Update: From the comments, that tool is ACF only. So you might try using the concrete class DefaultHttpAsyncClient as shown in the Asynchronous HTTP Exchange example.