Errors - cfml sample app

23 views
Skip to first unread message

Nando

unread,
Oct 23, 2011, 10:38:39 AM10/23/11
to cfmljure
Hi Sean,

After following the installation instructions for cfmljure, I'm seeing
a few errors, and I'm not sure if I'm doing something wrong, or
perhaps something unanticipated by your instructions.

I'm on CF 9.0.1

I unzipped the download to wwwroot/cj/ to test it. (I'm using the
built in web server)
I copied the .jar files into place under /Applications/ColdFusion9/
lib/
I copied the clj/cfml and clj/task directories into place under /
Applications/ColdFusion9/wwwroot/WEB-INF/classes/ (the directory
already existed) so now I have:

/Applications/ColdFusion9/wwwroot/WEB-INF/classes/cfml/
/Applications/ColdFusion9/wwwroot/WEB-INF/classes/task/

Restarted CF

Navigated to /cj/index.cfm and see "cfmljure examples" and the links
to the Basic example and Advanced example
Click on basic example link for the first error:

"Could not find the ColdFusion component or interface cfmljure"

OK. I poke around a moment in Application.cfc to figure out how it is
being called find cflmjure.cfc, and copy it to the webroot, and I'm
through that error.

Reload /cj/basic/index.cfm and hit the next error:

Could not locate cfml/examples__init.class or cfml/examples.clj on
classpath:
The error occurred in core.clj: line 4905
Called from core.clj: line 4904
Called from /Applications/ColdFusion9/wwwroot/cfmljure.cfc: line 121

So I go to /Applications/ColdFusion9/wwwroot/WEB-INF/classes/cfml/ and
indeed there is no examples.clj there, it's located several
directories deeper, under /Applications/ColdFusion9/wwwroot/WEB-INF/
classes/cfml/src/cfml/examples.clj (did I misunderstand the
instructions?). so I copy it into /Applications/ColdFusion9/wwwroot/
WEB-INF/classes/cfml/examples.clj

seems to work, but I hit the next error on the twice function call:

Calls via explicit handles on methods
(greet "World") = Hello World!
(twice [ 1 2 3 ]) =

java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Number

The error occurred in /Applications/ColdFusion9/wwwroot/cj/basic/
index.cfm: line 28
Called from examples.clj: line 13
Called from core.clj: line 2096

26 : <!--- pass CFML array to Clojure and loop over Clojure sequence
that comes back: --->
27 : <cfset list = twice._call( [ 1, 2, 3 ] ) />
28 : (twice [ 1 2 3 ]) = <cfloop index="n" array="#list#">#n# </
cfloop><br />

and this has me stumped.

I'm getting the same error from the Advanced examples link:

Calls via implicit method lookup after implicit installation
(greet "World") = Hello World!
(twice [ 1 2 3 ]) =

java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Number

The error occurred in /Applications/ColdFusion9/wwwroot/cj/advanced/
index.cfm: line 9
Called from /Applications/ColdFusion9/wwwroot/cj/advanced/
Application.cfc: line 18
Called from examples.clj: line 13
Called from core.clj: line 2096

7 : <!--- pass CFML array to Clojure and loop over Clojure sequence
that comes back: --->
8 : <cfset list = cfml.examples.twice( [ 1, 2, 3 ] ) />
9 : (twice [ 1 2 3 ]) = <cfloop index="n" array="#list#">#n# </
cfloop><br />
10 :
11 : <!--- simple function call (times_2 is def'd to an anonymous
function literal: --->


I know you plan to update these examples in the coming week, so don't
bother with this unless it helps to improve something moving forward.
I'll come back and try again once the update is released.

Thanks much!



Sean Corfield

unread,
Oct 23, 2011, 12:55:45 PM10/23/11
to cfml...@googlegroups.com
Yeah, you're really not going to get anywhere on this until I update the documentation. The way cfmljure is used has changed radically since the earlier release, after lots of production use.

I've never tried it on ACF9.0.1 so I can't speak to the library/class path issues there. I use it with Railo/Tomcat and adjust the common class loader settings to put src and lib folders on the class path. I use Leiningen to set up the Clojure project and manage dependencies etc.

If you're not familiar with class path stuff, you're unlikely to get cfmljure running until I've overhauled the documentation.

Suffice to say tho' that it is in daily production use by many thousands of users at World Singles :)
> -- cfmljure on github: http://github.com/seancorfield/cfmljure
>
> -- cfmljure on riaforge: http://cfmljure.riaforge.org
>

--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Sean Corfield

unread,
Oct 23, 2011, 1:02:00 PM10/23/11
to cfml...@googlegroups.com
Reading this again, I expect the class cast exception is due to a fundamental difference between ACF and Railo: in Railo, [1,2,3] is an array of numbers, in ACF it is an array of strings. That's one of the reasons Railo is so fast: it usually doesn't need to convert strings to numbers because it already stores them as numbers!

The Clojure interop in the examples relies on the Railo behavior (because the ACF behavior is, frankly, dumb and would require the code to be full of JavaCasts or Long/parseLong calls).

Sean

On Sunday, October 23, 2011, Nando <na...@carbonzero.ch> wrote:

Nando Breiter

unread,
Oct 23, 2011, 1:21:50 PM10/23/11
to cfml...@googlegroups.com
Hmmm ... well perhaps an example app that avoids this issue would be more helpful for beginners? Or if the problems with ACF have enough of an impact to warrant it, state out front that Railo is the only CFML engine supported by cfmljure (and why)?


CarbonZero Project
Via Rompada 40
6987 Caslano
Switzerland

+41 (0)91 600 9601
+41 (0)76 303 4477 cell
skype: ariamedia

Sean Corfield

unread,
Oct 23, 2011, 5:27:02 PM10/23/11
to cfml...@googlegroups.com
On Sun, Oct 23, 2011 at 10:21 AM, Nando Breiter <na...@carbonzero.ch> wrote:
> Hmmm ... well perhaps an example app that avoids this issue would be more
> helpful for beginners?

As I said, I need to overhaul the examples and documentation to
reflect the changes made to cfmljure over many months of production
use.

> Or if the problems with ACF have enough of an impact
> to warrant it, state out front that Railo is the only CFML engine supported
> by cfmljure (and why)?

cfmljure itself will work just fine with ACF but the interop between
CFML and Clojure won't be as smooth as it is in Railo. To be honest,
until you raised the issue, I hadn't even realized that ACF's [1,2,3]
won't pass seamlessly to Clojure as a numeric sequence... I don't use
ACF any more and only keep an instance around for compatibility
testing - which I will work on when I get around to overhauling the
examples!

My primary setup for running CFML and Clojure together is Tomcat so I
might create a WAR install of ACF to run on my Tomcat instance and
test cfmljure there - given that Adobe are (finally!) scrapping JRun
and adopting Tomcat. I do want to get cfmljure wired up with Jetty
too, so that I can create a simple, standalone bundle that folks can
just download and work on out of the box (it would be Jetty + Railo,
of course)...

Nando Breiter

unread,
Oct 24, 2011, 1:43:48 AM10/24/11
to cfml...@googlegroups.com
Sean,

Thanks for all your replies. If it isn't obvious, attempting to work with Clojure is certainly a stretch for me, average spread-thin trying-to-keep-a-business-afloat ColdFusion developer that I am. But I'm looking forward to trying out the next iteration and thinking how I might integrate it in my work, particularly in conjunction with a no-sql datastore solution.

Kind regards,

Nando



CarbonZero Project
Via Rompada 40
6987 Caslano
Switzerland

+41 (0)91 600 9601
+41 (0)76 303 4477 cell
skype: ariamedia





Sean Corfield

unread,
Oct 24, 2011, 12:36:57 PM10/24/11
to cfml...@googlegroups.com
On Sun, Oct 23, 2011 at 10:43 PM, Nando Breiter <na...@carbonzero.ch> wrote:
> Thanks for all your replies. If it isn't obvious, attempting to work with
> Clojure is certainly a stretch for me, average spread-thin
> trying-to-keep-a-business-afloat ColdFusion developer that I am.

Yeah, the amount of JEE infrastructure / classpath knowledge that most
CFers _don't_ have gets in the way of cross-language stuff like
this...

> But I'm
> looking forward to trying out the next iteration and thinking how I might
> integrate it in my work, particularly in conjunction with a no-sql datastore
> solution.

CongoMongo - the Clojure wrapper for MongoDB - is pretty sweet but
it's designed to be used from Clojure, which is why at World Singles
we wrote a thin CRUD layer that sits around clojure.java.jdbc (for
stuff like MySQL) and CongoMongo (for MongoDB) and now we can just do:

variables.clj.worldsingles.data.save_row("sometable",{name =
"Nando",location = "Switzerland"});

and it "does the right thing" (saving it to wherever "sometable" is
configured to go - MySQL or MongoDB). We can retrieve it in a
storage-neutral way by doing:

var cfguys = variables.clj.worldsingles.data.find_by_keys("sometable",{name
= "Nando"});
writeOutput("Found #arrayLen(cfguys)# CF guys called Nando");
writeDump(cfguys[1]);

Only if we need to deal with primary keys directly do we need to care
about storage (we return a sequence of generated keys from MySQL but
we return the whole updated document from MongoDB, due to the way they
work under the hood...).

Reply all
Reply to author
Forward
0 new messages