CFC as VO for Java

71 views
Skip to first unread message

JoeyC

unread,
Jun 8, 2010, 7:15:04 PM6/8/10
to Railo
I may have this subject wrong, certainly not getting me any good
Google hits...

I have a need to call a single function/method in a java class that
will return a single object with three properties, each property being
a typed array (or arrayList if need be) of objects.

So... from CF I call the CFC method which calls the JAVA method which
returns an object with three arrays populated. (each array will need
to be used as a query result set in CF) Ideally (i think...), when
back in CF I am working with a ? structure ? that has three queries on
it.


Can anyone point me at a "good" source or enlighten me as to how best
accomplish this?

TIA -Joey!

Sean Corfield

unread,
Jun 8, 2010, 9:29:57 PM6/8/10
to ra...@googlegroups.com
On Tue, Jun 8, 2010 at 4:15 PM, JoeyC <coch...@comcast.net> wrote:
> I may have this subject wrong, certainly not getting me any good
> Google hits...

CFC as VO for Java suggests you are trying to pass a CFC to Java -
which won't work in CFML (well, Railo 4.0 will support it).

> I have a need to call a single function/method in a java class that
> will return a single object with three properties, each property being
> a typed array (or arrayList if need be) of objects.

Then you'll get back that Java object.

Show us the signature of the Java method and we can tell you more about it.

> So... from CF I call the CFC method which calls the JAVA method which
> returns an object with three arrays populated.  (each array will need
> to be used as a query result set in CF)  Ideally (i think...), when
> back in CF I am working with a ? structure ? that has three queries on
> it.

You're working with a Java object with three Java arrays in it.

Java arrays != CFML queries. In fact, Java 'queries' != CFML queries
either. Java has a type RecordSet which is a bit like a CFML query
(but not interchangeable).

Basically, if you're interacting with Java, you need to follow the
Java APIs for the code you're calling...
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Joseph C. Cochran II

unread,
Jun 9, 2010, 9:34:01 PM6/9/10
to ra...@googlegroups.com
Show us the signature of the Java method and we can tell you more about it.

I am not authoring the JAVA side, although I may/might have some influence.  Currently this is in the design/architect level of solving the problem (finding a solution).  So it can be what it needs to be.  The data source(s) are NOT databases.  They are proprietary and accessible as a JAVA Array.  I can then convert them as needed, if needed.

I know from my experience with ActionScript 3 (for Flex) interactions with JAVA, that I can use JAVA ArrayList mapped to ??? to deliver a collection to iterate through.

I am hoping to find something similar for CF.  Surely I am not the first person to want to have JAVA deliver to CF a resultSet from a data source.  Then just take that one step further and bring back three result sets at once.

Can this be done?

Sean Corfield

unread,
Jun 9, 2010, 10:05:25 PM6/9/10
to ra...@googlegroups.com
On Wed, Jun 9, 2010 at 6:34 PM, Joseph C. Cochran II
<coch...@comcast.net> wrote:
> I am hoping to find something similar for CF.  Surely I am not the first
> person to want to have JAVA deliver to CF a resultSet from a data source.
>  Then just take that one step further and bring back three result sets at
> once.
> Can this be done?

Well, yes and no.

No, insofar as a CF "query" is a very different beast to a Java
ResultSet. In fact a CF query is a specific Java type defined within
the CFML engine itself so you won't be able to return a native
CF-compatible query.

Yes, you can either convert your Java array of maps (presumably?) to a
CF query - using queryNew() / querySetCell() etc - or iterate directly
over the native Java types.

If your Java method returns a map with three keys, each referencing an
array of maps (name/value pairs), then CF can interact with that
pretty easily. A Java HashMap is pretty much a CF struct and an array
is... well, it should convert to a CF array I think.

It'll be hard to provide specific guidance for you tho' without
specific code examples...

denstar

unread,
Jun 9, 2010, 10:07:14 PM6/9/10
to ra...@googlegroups.com
On Tue, Jun 8, 2010 at 7:29 PM, Sean Corfield wrote:
...
> CFC as VO for Java suggests you are trying to pass a CFC to Java -
> which won't work in CFML (well, Railo 4.0 will support it).

Javaloader can do it. :-)

Mark Mandel is a rockstar.

:Den

--
Take away paradox from the thinker and you have a professor.
Soren Kierkegaard

denstar

unread,
Jun 9, 2010, 10:09:59 PM6/9/10
to ra...@googlegroups.com
On Wed, Jun 9, 2010 at 8:05 PM, Sean Corfield wrote:
> On Wed, Jun 9, 2010 at 6:34 PM, Joseph C. Cochran II
> <coch...@comcast.net> wrote:
>> I am hoping to find something similar for CF.  Surely I am not the first
>> person to want to have JAVA deliver to CF a resultSet from a data source.
>>  Then just take that one step further and bring back three result sets at
>> once.
>> Can this be done?
>
> Well, yes and no.
>
> No, insofar as a CF "query" is a very different beast to a Java
> ResultSet. In fact a CF query is a specific Java type defined within
> the CFML engine itself so you won't be able to return a native
> CF-compatible query.

I'm 95% sure I have turned a java result set into a cfquery using Railo.

I'd have to dig to find where, but I'm pretty sure it's pretty doable.

Ah:

http://stackoverflow.com/questions/2227134/how-does-one-convert-from-a-java-resultset-to-coldfusion-query-in-railo

:Den

--
The function of prayer is not to influence God, but rather to change
the nature of the one who prays.
Soren Kierkegaard

Sean Corfield

unread,
Jun 9, 2010, 10:23:08 PM6/9/10
to ra...@googlegroups.com
On Wed, Jun 9, 2010 at 7:07 PM, denstar <vallia...@gmail.com> wrote:
>> CFC as VO for Java suggests you are trying to pass a CFC to Java -
>> which won't work in CFML (well, Railo 4.0 will support it).
> Javaloader can do it. :-)

Are you *certain* about that? I don't believe JavaLoader does that...
I can't see how it would let you instantiate a Java object and pass a
CFC in as an argument to methods on that Java object (and have Java
code call methods on that CFC).

> Mark Mandel is a rockstar.

That I agree with.

Sean Corfield

unread,
Jun 9, 2010, 10:24:18 PM6/9/10
to ra...@googlegroups.com
On Wed, Jun 9, 2010 at 7:09 PM, denstar <vallia...@gmail.com> wrote:
> http://stackoverflow.com/questions/2227134/how-does-one-convert-from-a-java-resultset-to-coldfusion-query-in-railo

That's much neater than iterating over the ResultSet and creating a CF
query object row-by-row - nice!

Paul Kukiel

unread,
Jun 9, 2010, 10:35:34 PM6/9/10
to ra...@googlegroups.com
+1 for Open Source hey!

Paul.

denstar

unread,
Jun 9, 2010, 11:05:24 PM6/9/10
to ra...@googlegroups.com
On Wed, Jun 9, 2010 at 8:23 PM, Sean Corfield wrote:

> On Wed, Jun 9, 2010 at 7:07 PM, denstar wrote:
>>> CFC as VO for Java suggests you are trying to pass a CFC to Java -
>>> which won't work in CFML (well, Railo 4.0 will support it).
>> Javaloader can do it. :-)
>
> Are you *certain* about that? I don't believe JavaLoader does that...
> I can't see how it would let you instantiate a Java object and pass a
> CFC in as an argument to methods on that Java object (and have Java
> code call methods on that CFC).

It's black magic, and there are caveats, but yup, that's what it does.

There are docs for that feature too, but they're sorta hidden away,
and I can't remember where off hand. Google knows.

>> Mark Mandel is a rockstar.
>
> That I agree with.

So do I! Oh, yeah. But Still. Worth reiterating. :)

:Den

--
To dare is to lose one's footing momentarily. Not to dare is to lose oneself.
Soren Kierkegaard

James Holmes

unread,
Jun 9, 2010, 11:25:27 PM6/9/10
to ra...@googlegroups.com

Sean Corfield

unread,
Jun 10, 2010, 12:02:21 AM6/10/10
to ra...@googlegroups.com
Interesting. Not one copy that I can find in all the projects on my
hard drive implements that - all 0.5/0.6 versions that are bundled
with MXUnit and ColdBox and so on. Seems to be new in 1.0 (which is
still in beta). I'll have to download it and see how it works... I
assume it has to create Java wrappers based on introspection of CFCs
and compile them on the fly?

Sean

BTW, Railo 4.0 is going to provide that natively.

James Holmes

unread,
Jun 10, 2010, 12:33:59 AM6/10/10
to ra...@googlegroups.com
Yes, there's a dynamic compilation feature in there as well (so in the middle of your CF code you can write a chunk of Java to the filesystem and have it compile at runtime):


mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/


Sean Corfield

unread,
Jun 10, 2010, 2:02:27 AM6/10/10
to ra...@googlegroups.com
On Wed, Jun 9, 2010 at 9:02 PM, Sean Corfield <seanco...@gmail.com> wrote:
> I'll have to download it and see how it works... I
> assume it has to create Java wrappers based on introspection of CFCs
> and compile them on the fly?

Hmm, that's pretty gnarly stuff and relies on some deep CF internals.
Does it run on Railo? (I'd be surprised, given the classes it relies
on but...)

It relies on Java's own dynamic proxy mechanism to provide an
intercept point for invocation of methods and delegates to the CFC. I
didn't realize Java had a dynamic proxy facility! Learn something new
every day (several things today, in fact).

denstar

unread,
Jun 10, 2010, 2:27:30 AM6/10/10
to ra...@googlegroups.com
1.0 has been in beta for a while now. I mentioned something on
cf-talk I think when I noticed, as I was way pleased to see what he'd
put into it.

Cool stuff!

Railo 4 is going to knock my socks off! Cherry features man, cherry.

:Den

--
Trouble is the common denominator of living. It is the great equalizer.
Soren Kierkegaard

denstar

unread,
Jun 10, 2010, 2:32:07 AM6/10/10
to ra...@googlegroups.com
On Thu, Jun 10, 2010 at 12:02 AM, Sean Corfield wrote:
...

> Hmm, that's pretty gnarly stuff and relies on some deep CF internals.
> Does it run on Railo? (I'd be surprised, given the classes it relies
> on but...)

I don't think it works on Railo. =)

Micha posted something a while back that was pretty close. I don't
remember if a fully working example was ever put together... maybe it
was some RPC stuff, come to think of it.

> It relies on Java's own dynamic proxy mechanism to provide an
> intercept point for invocation of methods and delegates to the CFC. I
> didn't realize Java had a dynamic proxy facility! Learn something new
> every day (several things today, in fact).

I love days like that.

:Den

--
Any necessary truth, whether a priori or a posteriori, could not have
turned out otherwise.
Saul Kripke

denstar

unread,
Jun 10, 2010, 2:32:20 AM6/10/10
to ra...@googlegroups.com
For years I'd been using Javaloader to compile stuff with JDT and then
load it, so I was all happy to see that.

I think it's super cool that Railo has some of this sort of stuff
built right in.

:Den

--
What is a poet? An unhappy person who conceals profound anguish in his
heart but whose lips are so formed that as sighs and cries pass over
them they sound like beautiful music.
Soren Kierkegaard

Seay, Walter

unread,
Jun 10, 2010, 3:51:19 PM6/10/10
to ra...@googlegroups.com
Has anyone one integrated Railo with a Java Portal like Jetspeed or
Liferay?

I am building a collection of utilities in CFM for various departments.
Distribution would work the best to have these apps built into Portlets
and deployed across the organization.

Our Goal is that you will be very satisfied with the services you
receive. Please let us know how we are doing.

Walter Seay
Integration Specialist
Eisenhower Medical Center
39000 Bob Hope Drive
Rancho Mirage, CA 92270
760-340-3911 ext: 5977

Todd Rafferty

unread,
Jun 10, 2010, 4:00:42 PM6/10/10
to ra...@googlegroups.com
Have you searched? :)

http://groups.google.com/group/railo/search?group=railo&q=Liferay&qt_g=Search+this+group
--
~Todd Rafferty ** Volunteer Railo Open Source Community Manager ** http://getrailo.org/

Seay, Walter

unread,
Jun 10, 2010, 4:50:45 PM6/10/10
to ra...@googlegroups.com
Evidently not...
 
In a quick review there appears to be some good information here.  I would still appreciate any feedback where this has been put into practice.  For example, lessons learned, best practice, etc.
 
Walter Seay
 


From: ra...@googlegroups.com [mailto:ra...@googlegroups.com] On Behalf Of Todd Rafferty
Sent: Thursday, June 10, 2010 1:01 PM
To: ra...@googlegroups.com
Subject: Re: [railo] Anyone implement Railo with a Java Portal

Todd Rafferty

unread,
Jun 10, 2010, 4:59:00 PM6/10/10
to ra...@googlegroups.com
I believe one of the guys on the volunteer team (Andrea) has implemented something with Liferay, but he's offline for the week due to computer problems. I know Adam Haskell is familiar with it as well, but not from a Railo standpoint. Not sure if anyone else can chime in here.


On Thu, Jun 10, 2010 at 4:50 PM, Seay, Walter <Ws...@emc.org> wrote:
Evidently not...
 
In a quick review there appears to be some good information here.  I would still appreciate any feedback where this has been put into practice.  For example, lessons learned, best practice, etc.
 
Walter Seay


Seay, Walter

unread,
Sep 3, 2010, 12:37:23 PM9/3/10
to ra...@googlegroups.com
I thought I would bring this topic of Portals back up.  My goal is to take of the of CF applications done for various hospital departments and package them up in a portal server.  We will be going forward with the portal server and I really don't want to recode everything as .jsp pages. 
 
I am looking for anyone with experience using Railo within Jetspeed, Liferay or other Java portals.  I am familiar with creating portlets, but how do I get Railo in the mix to call my cfm pages?
 
Any step by step intros to get started will be greatly appreciated!!
 
 
---------- Forwarded message ----------
From: Todd Rafferty <to...@getrailo.org>
Date: Thu, Jun 10, 2010 at 4:59 PM
Subject: Re: [railo] Anyone implement Railo with a Java Portal

Mark Drew

unread,
Sep 3, 2010, 1:26:12 PM9/3/10
to ra...@googlegroups.com
Strangely enough I shall be looking at this next week. 

Regards

Mark Drew 

On 3 Sep 2010, at 17:37, Seay, Walter wrote:

I thought I would bring this topic of Portals back up.  My goal is to take of the of CF applications done for various hospital departments and package them up in a portal server.  We will be going forward with the portal server and I really don't want to recode everything as .jsp pages. 
 
I am looking for anyone with experience using Railo within Jetspeed, Liferay or other Java portals.  I am familiar with creating portlets, but how do I get Railo in the mix to call my cfm pages?
 
Any step by step intros to get started will be greatly appreciated!!

Mark Drew
Railo Technologies UK
Professional Open Source
skype:  mark_railo
email:  ma...@getrailo.com
gtalk:  ma...@getrailo.com
tel:  +44 7971 85  22 96
web:  http://www.getrailo.com

Seay, Walter

unread,
Sep 3, 2010, 2:30:46 PM9/3/10
to ra...@googlegroups.com
Glad to hear it!!
 
You have a very willing & eager tester at your disposal! 
 
My targets are the Vignette portal for the Clinical staff.  I would like to use a FOSS portal for everyone else.
 
Walter Seay
Integration Specialist
Eisenhower Medical Center
39000 Bob Hope Drive
Rancho Mirage, CA  92270


From: ra...@googlegroups.com [mailto:ra...@googlegroups.com] On Behalf Of Mark Drew
Sent: Friday, September 03, 2010 10:26 AM
To: ra...@googlegroups.com

Subject: Re: [railo] Anyone implement Railo with a Java Portal

Seay, Walter

unread,
Apr 8, 2011, 7:39:23 PM4/8/11
to ra...@googlegroups.com
Greetings all:
 
My goal is to deploy Liferay as an application portal.  The portlets will be cfml code run by Railo. 
 
I have made progress in getting Tomcat (6.0.26) to run Liferay (6.0.5 CE) and Railo (3.2.2.000).
 
I can access Liferay at: http://localhost:8080/web
Cfml app with datasources working is here: http://localhost:8080/railo/EDCallLog
 
I am familiar (not expert) with jsp Portal apps from another portal that we run on Vignette.  So I was able to bring some straight jsp Portlets into my new Liferay installation.  Those are working.
 
Next I got the Railo server to display in a portlet window via 'com.liferay.util.bridges.wai.WAIPortlet.'  But that would dedicate a Railo instance to serve only one application.  So on to Portlets...
 
In my search to get Liferay to properly call Railo, all roads led to http://wiki.cfinnovate.com/display/cfmlportlets/Home.
 
After reading up, I tried the following:
Placed 'cfmlporlets-0.5.jar' into \tomcat-6.0.26\lib
Built Liferay Portlet with recommended settings to call 'com.cfinnovate.portlet.CfmPortlet'
Deployed portlet
 
I get the following dump after the deploy:
 
23:26:43,096 INFO  [PortletAutoDeployListener:81] Portlets for C:\dev\liferay-portal-tomcat-6.0.5\liferay-portal-6.0.5\deploy\hello-railo-portlet-6.0.6.1.war copied successfully. Deployment will start in a few seconds.
Apr 8, 2011 11:26:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory hello-railo-portlet
23:26:48,220 INFO  [PortletHotDeployListener:220] Registering portlets for hello
-railo-portlet
23:26:48,299 ERROR [HotDeployUtil:112] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for hello-railo-portlet
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for hello-railo-portlet
        at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:45)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:104)
        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent
(HotDeployUtil.java:109)
        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182)
        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38)
        at com.liferay.portal.kernel.servlet.PortletContextListener.doPortalInit
(PortletContextListener.java:99)
        at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
        at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:52)
        at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:50)
        at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:55)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
 
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
        at com.cfinnovate.portlet.CfmlEngineInteraction.installFile(Unknown Source)
        at com.cfinnovate.portlet.CfmlEngineInteraction.installFile(Unknown Source)
        at com.cfinnovate.portlet.CfmPortlet.installPortletHelperFile(Unknown Source)
        at com.cfinnovate.portlet.CfmPortlet.init(Unknown Source)
        at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
        at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:245)
        at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:216)
        at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:139)
        at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:40)
        at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:290)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:456)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy
(PortletHotDeployListener.java:253)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:101)
        ... 24 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 37 more
It appears that I have an issue with the cfinnovate jar.
 
So here I am, 4:30 pm on a Friday afternoon, Brain cells tired.  I feel I am so very close to Railo/Portlet Nirvana!
 
I would appreciated any direction from the more experienced members of this group.

AJ Mercer

unread,
Apr 8, 2011, 8:04:02 PM4/8/11
to ra...@googlegroups.com
I have been messing around with LifeRay and Railo too - I think have CFML portlets would be sooo neat.

I was able to get Railo running when I dropped a Railo WAR into my LifeRay install.

But I was not able to do a Railo JAR install into Tomcat :-(
I think the Issue is with jar conflicts.
I pulled out the duplicated jars which got Tomcat starting and LifeRay running, but Railo complained about something (dont have it handy at the moment).


I would be very keen to work on this project with you.

Seay, Walter

unread,
Apr 28, 2011, 11:53:39 AM4/28/11
to ra...@googlegroups.com
Sorry for the delayed response.  I am in the final stages of an upgrade for a different project.
 
I have the go ahead to bring this project to life!  My full attention will begin on it in mid May.  The plan is to have Railo serving JSR168 applets in the Liferay portal.  I will be posting updates of my progress in this group.
 
Walter Seay
Integration Specialist
Eisenhower Medical Center
39000 Bob Hope Drive
Rancho Mirage, CA  92270
 

From: ra...@googlegroups.com [mailto:ra...@googlegroups.com] On Behalf Of AJ Mercer
Sent: Friday, April 08, 2011 5:04 PM
To: ra...@googlegroups.com
Subject: Re: [railo] Tomcat/Liferay/Railo - Attempting to build cfm Portlets

Reply all
Reply to author
Forward
0 new messages