Friday, February 18, 2005

First "Official" ColdFusion 7 Upgrade

So today was the day--I kicked everyone off one of our development servers and upgraded from CFMX 6.1 Standard to CFMX 7 Enterprise. I've done the installation on several machines by this point but this was the first installation on a server at my company that "matters" (i.e. other people use it and would gripe if it was down for too long).


As expected everything went 100% smoothly! I just thought I'd share some thoughts about the installation and the improvements I'm already seeing in moving from CFMX 6.1 Standard to CFMX 7 Enterprise.


 


This installation was on Windows Server 2003 (Enterprise Edition), and I did the multi-instance/integrated JRun installation (option 2). The server supports three separate web sites, and we use IIS 6. We have maybe 20 datasources involved and a bunch of Verity collections as well, but nothing too out of the ordinary. I must admit when I upgrade things I actually tend to do a completely fresh installation, so I decided to do that here as well. Yes, probably unnecessary, but it gives me a bit more peace of mind. (Hey, that's just me--I've done the "co-exist" install on some other machines and it worked great as well.)


So step one was to move all our web app files to a backup directory and then uninstall CFMX 6.1. No problems, no lingering "stuff" after the uninstall, so that was all good.


Step two was to install CFMX 7, and as most of you probably know by know, the installer is really sweet. I know there are people on the Macromedia forums that are having problems with the download, etc. but I did a fresh download today just as a test, and I had no problems whatsoever with the installer I just downloaded.


As I said above, I chose option 2 which does an integrated JRun installation. The reason for this is that it includes the Enterprise Manager that allows you to manage multiple instances of ColdFusion from the CF administrator. I blogged about this feature briefly before, but to reiterate, this is seriously cool stuff. Now you can much more easily deploy and control multiple instances of CF, even on remote servers.


So after the installation succeeded I moved my web app files into their new home and everything just worked. This was for the first of the three sites this servers supports. Now here's where things get cool!


Next, I went to the Enterprise Manager and clicked on "Instance Manager." Then I clicked on "Add New Instance," gave my new instance a name, and away it went. A couple of minutes later I had a second instance of ColdFusion. This of course is to run the second site on this server, and this isolation is going to be fantastic for several reasons. First, if one site needs to be restarted it doesn't affect the other. Second, I have better control over access, security, etc. because the sites are now running completely independently of one another.


Since this is our dev server we just use a single IP address for the whole server and user host headers in IIS for the different sites, so I used the JRun web server connector tool and hooked CF server 1 into IIS web site 1, and server 2 into a different IIS web site that had a host header. Again, no problems, everything just worked! I'll sleep better at night now that all my sites are independent from one another.


That's pretty much all there is to report right now--once this setup has been running well on our dev server for a week or two we're going to schedule this same process on our two clustered production servers. I'm really encouraged by how smoothly this went.


How about the rest of you? Any installation experiences to share?


Comments


Don't tell me you had to re-add the 20 datasources all over again?


In this case I did, but I have all that stuff in a spreadsheet anyway so it only took a few minutes. Let me be clear and say that you do NOT have to manually re-add your datasources if you install CFMX 7 while CFMX 6.1 (maybe 5 as well, but I haven't done any 5 -> 7 upgrades) is still on your machine. I've done that on a few machines and it'll pick them up for you. I just decided to uninstall CFMX 6.1 first in this case so everything would be 100% clean. I know I'm being overly anal by doing that, so it's definitely not a case of having to do it if you don't want to.


The other thing I haven't looked into is whether or not you can use the neo-query.xml file (I believe that's the correct file anyway) from CFMX 6.1 and drop that into CFMX 7 so it'll pick up your datasources. Maybe I'll give that a shot on another machine and see what happens.


Yeah, just took a look at neo.query.xml. Now, I have a question: if I inserted portions into the xml file, will coldfusion see the datasource? could someone comprise that by using cffile to cause issues? are the folders protected????


I personally haven't ever done this, but I would think that if you manually add things to neo-query.xml and restart CF, it would pick up what you added. That's not to say it's going to work, however. I just haven't messed with it enough to know what happens. (You may have inspired me to try this out later just because now I'm curious.) The questions I would have are A) why would you want to do that vs. using the CF administrator (or in CFMX 7 now you can easily programmatically create datasources via the Admin API), and B) how are you going to handle password security? Here's some info on the Admin API in CFMX 7: http://tinyurl.com/6rrzl If you're looking into creating datasources programmtically in CFMX 6.1, then I'd use the undocumented ServiceFactory method as opposed to modifying neo-query.xml. Here's one thing I found on that: http://tinyurl.com/6bzy6 Also, the passwords in the neo-query.xml file are encrypted somehow (hashed with MD5 or maybe blowfish?), so I'm not sure if you stick plain text in there it will work. Again, I haven't experimented with it so I could be wrong. As for the cffile issue, neo-query.xml is no more or less protected than any other file on your server. I'm sure that on shared hosting accounts they sandbox people in so they can't upload files to this area (which is outside the webroot), but I don't think there's anything inherent permission-wise or anything else that is put into place by default when you install CF to protect this directory. Then again, if someone's on your server and you're giving them access enough to use cffile with no restrictions, and you aren't using a sandbox, I hope you trust them enough not to do something like this! ;-)


The easiest way to get those 20 data sources over is to export the data sources to a .car file and then import them back in the new CF. Works really well.


Thanks Ben! Something else I just hadn't done yet, but I'll definitely do this on future installations.


I have manually edited the neo-query.xml file and restarted CF and the new datasource showed up, so that works. Not sure if it is a good way to upgrade datasources to a new version though. I've used the Administrator components that you linked to above, and they work great. You can import the datasource information from CF5 or CF6 and then just loop over all of them to create them again. I was able to pull all CF5 datasources even after 5 was uninstalled. I guess the registry entries don't get removed during uninstall.


how do you export datasources to a car file?


John2--if you're using CFMX Enterprise this is done in the CF administrator under "packaging and deployment" (at least that's the nomenclature in CFMX 7; unfortunately I don't have CFMX 6.1 installed on the machine I have access to at the moment). When you build your CAR file you can specify, for example, just to include the datasource information and reploy that CAR on another server, which will create your datasources on the new server for you.

Thursday, February 10, 2005

getContextRoot() in CFMX 7

Maybe others aren't as excited about this as I am, but having the getContextRoot() method available in Java/JSP applications has always been extremely handy, and I was just bemoaning the lack of this in CFMX the other day.


Bemoan no more! I finally had a chance to go over the CFMX 7 feature list in detail, and this one slipped by me: getContextRoot() is now available in CFMX 7. This will make writing context root-agnostic applications a lot simpler and is generally just a handy function to have available. One more reason to dive into CFMX 7!


Comments


I have to agree 100%. I was not even aware of this until I read your blog. I then checked the live docs to make sure this wasnt some crule joke :). This will save alot of varing and time, nice find. I also read your presentation on OOP, great job!


OK... what does it do... and how do you use it? Don't just be elated... tell others what it does for you and us.


This kind of thing has been around a while. <a href="http://e-docs.bea.com/wlp/docs81/javadoc/com/bea/p13n/management/ApplicationH...">try here</a> for some javadoc on the method. Hope that answers your question.


Whoops, guess I broke the law of Blog HTML up there. I'll copy and paste the interesting part of the doc below. Hope this helps. public static String getContextRoot(String applicationName, String webAppName) throws javax.management.InstanceNotFoundException Retrieve the context root for a webapp. The context root can be used to build a URL to access that webapp. The context root is specified in either the application's or the webapp's deployment descriptors. This can be used when a webapp needs to build an absolute URL to itself, or a URL to some other webapp


Sorry, I guess I was operating under the assumption "if you've needed this you'll know what it is and be happy that it's there ..." Basically in the J2EE world you can have multiple "servers" (virtual servers in essence) running on a single Java application server. In most cases, however, only one of these virtual servers can have a context root of /, meaning you don't have to add anything extra to the URL to get to your server's contents. So what's a context root? A context root is basically a "base URL" that's unique to each server, and this translates into the part of the URL that would appear immediately following the host name. What this does on the J2EE server side is that it uses that context root to determine which application needs to respond to the request. So a typical situation in my server setup is I'll have a production instance of ColdFusion running at the / context root, and a dev instance running at something like /cfusion for a context root. So what problems does this cause? Well, in your application you have to account for context root. So when I want to move an app from dev to production, the context root is going to change. I've handled this various ways such as by checking the server name in Application.cfm and setting the context root as an application variable, etc. While that works, it wasn't the same way you do things in the Java world. In a Java application you would just slap getContextRoot() before things in your application that you know need the context root to operate correctly (e.g. image paths, etc.). So now we can do this same simple thing in CFMX 7 and not worry about having to set a variable to handle it. Cool stuff.


Hi Matt,

I used this just today!

Currently we have a page that uses cflocation. I have changed this to a server side redirect in the belief that it will work with search engines. Can anyone confirm this?


Wednesday, February 9, 2005

CFC-101: An Introduction to OOP in CFMX

Here's a presentation (and the accompanying little application I built) that I gave to the Dallas/Fort Worth ColdFusion User Group last night. We had a good turnout and a lot of people are wanting to get into OOP in ColdFusion, so this is highly encouraging.


Caveats on the app:




  • It uses the new cfgrid and cfform in CFMX 7, so you'll have to run it on CFMX 7


  • The "Cancel" and "Delete" buttons on the cfforms don't do anything yet because I didn't have time prior to the presentation to figure out how to use the onClick ActionScript stuff


  • I cranked it out pretty quickly--a.k.a. "Standard Disclaimer" ;-)



As always, feedback is greatly appreciated. If you have questions, see something weird, think something could be explained better, etc. please feel free to let me know. That's how we're all going to learn this stuff and make every app we write in CFMX 7 OO!





Comments


Sorry, I forgot to put the database script in the application zip. I'll repost another one later today.


Matt, this is great stuff. I've already put a link to it in our reference section and will make sure all of our developers that aren't experts on OOP w/CFMX view it, which is pretty much all of us. Thanks very much.


Thanks Jim, glad to help. I'll get the version of the application zip with the database script up here shortly.


I just posted the updated cfc101_app.zip file (same link as before). This contains a cfc101.sql file that's a dump from MySQL but should be usable (it's plain text SQL commands) to create this database on another RDBMS or in Access. Let me know if you have any problems.


Matt, Fantastic presentation. I especially like the work you've done with Data Access Objects and gateways. I might have to go back and look at some of my code (crud <--- muttered comment, not an acronym). I thought you were pretty strong in your discussion of using the var scope inside components. When you talk about variables leaking out of the function, are you referring to some bug? I've been using the variables scope regularly to set up private variables. It seems to be pretty predictable so far to me. You do have to be careful with querries, though. It would be nice if they were private by default. I had a bigger problem with the resolution of the unnamed scoped variables and the arguemnts scope. That one caused me a bunch of headaches until I found out what the problem was. Funny how a simple order of operations issue can really blow apart your application when you and your computer don't agree on how to do the math. :)


Mike--not talking about a bug, this is just the way things work and if you're not aware of it, it can bite you in the kiester. Specifically I'm talking about using var to declare variables within functions, which is a different situation than using variables within your CFC to make your variables private to that CFC. Hopefully the difference between the two wasn't a point of confusion. var scoped variables will stay within a function, while variables scoped variables are accessible throughout the CFC (but only within the CFC).

Friday, February 4, 2005

A Week With CFEclipse

I finally felt like I was at a point with projects, etc. that I could try CFEclipse this week. When I want to try a new piece of software (or when I switched from the PC to the Mac for example), I always try to give it a real try, meaning I abandon my old tool/program/computer/what have you and only use the new tool for an entire week. So this week I shut down Dreamweaver MX 2004 and fired up CFEclipse to see how it would go.


 


I have to admit this wasn't my absolute first time using Eclipse, but I'd only really dabbled before or used it when I was doing some Java stuff (for which Dreamweaver is absolutely horrendous). I really love some of the features so I was pretty sure I'd take right to it, but you never know until you cut the cord and only use the new tool.


When I did this one-week trial with a Mac I never went back to a PC and it's looking like this is going to be the case with CFEclipse as well. I kept expecting there would be several "I wish I could do X like I did in Dreamweaver," but it didn't happen once, and there's a lot CFEclipse has going for it over Dreamweaver. I won't go into this in detail since you've probably read about CFEclipse before in other blogs; this entry is more just to serve as one more CFer singing its praises and to be counted amongst the converted.


Couple things I noticed.




  • The colored syntax-highlighting doesn't always update properly. This is apparently a known issue so I'm sure it will be fixed shortly.


  • When I open XML files they don't seem to have syntax highlighting (it's all black text). Probably a setting I just need to dig for.



That really is pretty much it, believe it or not! The one huge thing I'd love to see that I also know is in the works is the ability to FTP right from the file browser. That's the one thing I miss from Dreamweaver, but the rest of Eclipse is good enough that I'll live without it for a while.


I'll still be using Dreamweaver on my PC for work because we do a lot with Contribute and use Dreamweaver templates pretty heavily, but when I'm doing my own stuff or doing coding that doesn't involve DW templates, CFEclipse has definitely become my main IDE. Time to start digging deeper and seeing what other cool Eclipse plugins there are out there ...


Kudos to Spike and the whole CFEclipse team--keep up the fantastic work!


Comments


Matt, check out http://www.dopefly.com/pages/cfeclipse.cfm for links to XML, JS and CSS plug-ins. I just setup Eclipse on Monday. Finally got my current project into CVS and figured I'd see how the integration went. FYI, there's an issue between the latest version of CVS and the latest release of Eclipse. Hopefully another build of Eclispe will fix it. Also, I got the XML plug-in to work, but the CSS and JS ones are giving me a hell of a time. Now if someone could just tell me how to change the editor's background color, I could overlook the problems I've had. :)


Very cool--now that I'm going to be using this full time I really need to get familiar with what all is out there. Good to know on CVS. There's another set of add-ons that Simeon (http://www.simb.net) pointed me to called "MyEclipse" (http://myeclipseide.com/). Looks like some pretty neat stuff for a pretty nominal price. They have a free trial so I think I'm going to check this out as well. My other annoyance I failed to mention is that on the Mac, when you launch Eclipse and tell it to keep it in your dock, on subsequent launch attempts from the dock it doesn't work. Any Mac users know what's up with that?


I'm just trying the new build for the first time myself. Maybe someone reading here can help? Any idea how the css editor dopefly suggested works? Or what it does? On a new css file it pops up values after the attibutes, that's it. No closing of brackets, no suggestions when typing an attribute. On an existing css file it wouldn't even do that. I beieve I have the js editor plugin installed (how do I even check? It's in the plugins folder) but doesn't appear to do anything. How to make toolbar items for the different editors, or add custom buttons to toolbars? Also, I closed the errors tab on the bottom bar and can see no way to get it back now. Any suggestions? It also uses about twice the memory of HS+, but the popup selector in cfscript alone is worth that.


There's a webdav/ftp plugin that you can get that allows you to "export" to an ftp site...


> Now if someone could just tell me how to change the editor's background color, I could overlook the problems I've had. :) Window>preferences>CFEclipse>CFML Colours ... the very last one ;) > My other annoyance I failed to mention is that on the Mac, when you launch Eclipse and tell it to keep it in your dock, on subsequent launch attempts from the dock it doesn't work. Any Mac users know what's up with that? I've just dragged icon it to the launcher bar (with the app closed) and it launches fine that way... If you still can't get it to work right post to the CFE list and we'll get you going >beieve I have the js editor plugin installed (how do I even check? It's in the plugins folder) but doesn't appear to do anything. Open a file with a .js extension if it is color coded and you have an outline sall good >Also, I closed the errors tab on the bottom bar and can see no way to get it back now. Look in Window>Show View>Other... Cheers


Thanks Critter, I've seen the webdav/ftp plugin but (unless I'm using a different one than what you're talking about) it's for transferring the whole project at once. Being able to do a single file at a time directly from the file tree would be really handy. My understanding is that this is in the works.


Cool Rob, dragging it to the dock worked. That must be a different action somehow than launching it and choosing "keep in dock" on the context menu. When I launch Eclipse I do get two Eclipse icons on the dock, and the second one goes away when I quit, but at least I can launch it from the dock now!


>>Open a file with a .js extension if it is color coded and you have an outline sall good -yes, color-coded, but doesn't seem to offer any features that I can see yet. Hmmm. >>Look in Window>Show View>Other... -thanks! If anyone knows a simple way to add buttons and toolbars, or where to read up on that...


Thanks for the info about CFEclipse.

Thursday, February 3, 2005

CFHibernate

In order to "put my money where my mouth is" about open source ColdFusion software, today I registered a new project at cfopen.org called CFHibernate. If you're familiar with Hibernate for Java, what I'd like to do is give ColdFusion users the tremendous capabilities that Hibernate has to offer. If you're not sure what Hibernate is, read on ...


 


Hibernate is an object-relational mapping (ORM) persistence framework for Java. What this means is that you define XML mapping files that describe your objects to Hibernate, and Hibernate creates your relational database model for you as well as many of your business objects (beans). Then in your application code, you literally don't ever have to write any SQL code. That's right, no SQL code. You make calls to the Hibernate service and it handles the database interaction for you. Being able to pass objects to Hibernate and not worry about all the "junk" that we typically have to concern ourselves with when persisting objects in an RDBMS is extremely powerful and very cool stuff.


The CFHibernate project is obviously in the pre-planning stages. I've been messing with Hibernate for Java for a little over a week now is all, but I'm extremely impressed and would absolutely love to be able to use this same functionality in my CF applications. Maybe it was the tedium of writing a bunch of DAOs that brought this on. ;-) At any rate, if you're interested in this effort and want to help, please consider registering on cfopen.org and signing up for the project. It's a big undertaking but I think it would be a huge benefit to OO CFers, and since the Hibernate code is in Java it might even be relatively leverageable (if that's even a word).


Comments


I wouldn't say that hibernate "creates" your business objects for you... although it will instantiate them. It doesn't create your DAO's either... something has to TELL hibernate what to do, and that's usually a "DAO"-type class/cfc/whatever. I'd actually say it would more likely be called a "service", that extends hibernateDAOSupport, and thus can get() save() and find() objects of the proper type for you. The beauty of hibernate is the abstraction of the storage "medium". Is it a database? Is it xml? What if it's just an in-memory cache? Who cares! Disclaimer: everything I just said was provided w/ my "limited experience" with Hibernate.


Well, actually Hibernate does create your business objects for you if you want it to. You can create an XML mapping and Hibernate will generate all your Java code for your business objects (by "business objects" I'm talking beans here) for you, complete with getters, setters, the appopriate datatypes, etc. This is based on what I've been doing with Hibernate anyway--I didn't have to write a single Java bean by hand, I just had to write the Java classes that use the beans (the application itself, in other words). Also based on what I've been doing, it doesn't create your DAOs for you either, but then again you don't really need any DAOs. Once you set up all your mapping files those tell Hibernate what to do when you call the various methods on Hibernate and pass it the objects you want persisted in your database. To me that's one of the big advantage of Hibernate. Yes, it also abstracts the storage mechanism, and this is another huge advantage. You want to switch from MS SQL to MySQL, or to Oracle, or HSQLDB, or whatever ... all you do is change a single properties file to tell Hibernate to use a different "dialect", give it the new driver and connection info, and you're literally done. That means changing about 4 lines of code in one file and seriously, that's all there is to it. I'm admittedly pretty new to Hibernate as well, but it definitely can generate a lot of code for you if you want it to. Yes, you still have to create XML files that it can use so it knows what you're wanting to do, but that's a lot simpler than writing the objects by hand, and these mapping files are also used to generate your database schema.


ahh yes... I remember reading that it could do that (create your "beans"), but never having seen it set up that way in practice, it must have slipped my mind. I will be trying my best to contribute to the project, but as I said last night, it's quite a large undertaking.


Yep, most definitely a large undertaking, but I think it's a worthwhile one, and hey, better too much ambition than not enough. ;-) Even if this project gets part-way to the full Hibernate feature set I think we'll get some darn useful tools out of it.


Matt, This is a great idea. I don't know how much time I have to contribute but I would like keep in the loop. Can I suggest you create a RSS-capable mailing list for the project so folks can monitor via their favorite newsreader? I find google groups works fine for the CFE list (topica doesn't do RSS). -Phil p.s. Want to help me win a Mac Mini ;)


Thanks Phil--I'll check into the RSS thing. It would be cool if cfopen had this built in but I'm not sure if it does. It has mailing list functionality I see but I haven't looked any further. I'm not sure how much time I'll have to contribute myself ;-), but I'm going to do what I can because I'm really excited about the possibilities this would offer. I need to do an even deeper dive into Hibernate itself to make sure I understand it really thoroughly but even after a week of working with it I think I have a decent handle on the functionality at a high level and how it works on the surface. The hard part will be digging into the technical side of how it does what it does, where the cutoff point between what Java code can be leveraged and what can't is, etc. It's going to be interesting if nothing else! As for the Mac Mini, I'm not sure I can help since I've already registered. My wife said she'd sign up on someone's if they can get someone who isn't registered to return the favor on mine, but since we're in the same household I'm not sure that would work either. If you know how they check, etc. and what's legit and what isn't, send me an email and I'll see what I can do.


I have a base DAO that I started uses a cf structure to map tables to a bean. This could easily be changed to use XML like Hibernate does. I would be happy to share it as a part of this project if people think it would help.


Excellent--we'll take all the help we can get! Thanks Kurt!


Matt some people have got hibernate working with coldfusion over on the flex yahoo group http://groups.yahoo.com/group/flexcoders/message/7801?threaded=1 It takes a fair amount of modification to coldfusion as the cf log4j.jar is an old version. Maybe blackstone will provide easier integration.


Thanks Mike--I found some references to that but didn't ever see the message that they got it working. I'll have to look into that because I'm curious exactly what they're doing with it, how they're persisting things, etc. My goal would be to use CFCs as my objects and be able to pass those into Hibernate, which I don't believe you can do. Now of course you could use Java objects as your beans within CF (which I've done before with Mach-II), but I really don't want to go that route because then it's a hybrid Java/CF application instead of a CF application that happens to use parts of the Java version of Hibernate or alternatively has its own CF-based ORM. Thanks a lot for the link though--I'll follow up with these folks and see exactly how they're approaching this.


Great stuff, Matt. I was just talking with Hal Helms earlier this evening about the problem of getting old RDBMS-heads (like me) to see the world in something other than a relational model. A project like this would go a long way to reinforce the "database last" attitude that we encourage in FLiP, and stress the application model instead of the storage model.


Thanks Jeff--I must admit when I first started reading about Hibernate I was a bit doubtful about how well it would handle the database schema generation piece. It's actually quite amazing--in the applications I've been playing with so far Hibernate does pretty much what I'd do myself, it sets up indexes, primary and foreign key relationships, and is pretty darn adept at handling one-to-many and many-to-many relationships. As with any of these sorts of tools you have to know a little about how it "thinks" to get the results you want, but it's amazingly straight-forward, and as you said it takes the emphasis off the database model and puts us completely in the object realm. I think (as Hal's said 100 times) that's another hangup we all have as we switch from procedural to OO; there's still that pesky database we have to deal with that doesn't quite think in objects. With ORMs you can let the computer worry about all that stuff! I'll admit that I'm probably still in the honeymood period with Hibernate, but I think I've dug semi-deep so far and I don't see any glaring annoyances yet. It does a great job of mapping objects to an RDBMS and has huge advantages when it comes to switching an application from one datastore to another as well. It's going to be challenging getting this going in ColdFusion but I think it's something that would make a lot of the repetitive stuff we all do on a daily basis a whole lot less tedious.


Don't forget the advantage of managed lazy loading. Let hibernate handle all the caching. Hibernate has a performance impact, like any other persistence layer, so use it wisely. :)


I was part of the group that is mentioned in the Yahoo group. Basically, our goal was slightly different than your stated goal here. We wanted to have all of our business logic in one place (Java), and be able to use ColdFusion (using Mach-II) for a public site, and Flex for an internal order-entry site. We were able to get Hibernate to work correctly with Flex without any real problems (other than understanding Hibernate and how it works). And I must say that we've been nothing short of amazed at how well Hibernate seems to work. However, we were unable to get ColdFusion to work correctly with Hibernate for any length of time. We ran into several issues, and most of them seemed to stem from JRun itself (mostly the classloader). We would be able to get it to work with an instance based version of CFMX, but then it wouldn't work with a standalone version of CFMX. We also ran into cross compatability issues between the Mac and PC, where something would work on the Mac, but not on PC. In looking around the internet, we were unable to find anyone else who had broached the subject of Hibernate for CF, or even JRun. Because of a project deadline, we had to essentially scrap the Hibernate for ColdFusion concept. We do plan on picking it up though in a couple months. It's a very daunting task, but I think it's possible and should definitely be explored!


Yep Micha, everything's a tradeoff and there are defintely some performance issues that you have to be aware of with Hibernate. By that I mean (based on what I've done with it so far) you just have to be very aware of how you're using it, when things get loaded, etc. etc. Luckily the Hibernate folks are well aware of what the gotchas are and it's documented quite well. I'll be curious to see how all this translates over to the CF side and I begin working on all of this.


Thanks for the follow-up Rob. Based on what I could tell from the flexcoders list I thought that's what you were doing. It's an option I considered but I'd really like to see a more CF-centric solution that wouldn't force people to use Java objects. Not that it's a bad solution necessarily, but it's one level removed from CF and would required CFers to learn enough Java to build their beans in Java. Simple enough really, but it's not CF. :-) I definitely think it's possible to get this rolling in CF, but you're right, pretty daunting. I'm just going to take it one step at a time and see how it all plays out. Thanks much for the feedback.


Good to see someone else trying this. I have NOT been able to get this working so far. I am primarily a JAVA/J2EE developer doing back end work for presentation layers done in CF. I love Hibernate for my JAVA projects and I am trying to implement it in the CF environment for my team. I'm registered at CFOpen.org but I am unsure of how to sign up for the project development.


Excellent Troy--just e-mail me your cfopen.org ID and I can add you to the project.


Matt, I am running JBoss and Bluedragon. Having some trouble with the datasource configuration. Hibernate docs point you to put the config in conf/server.xml for Tomcat. BD doesnt have this file.. instead has bluedragon.xml. Do you know how to set the datasource setting for JBoss + BD? Thx Joe


I could not make work Hibernate and Flex, could someone help me?


Miguel--there was some discussion on this quite a long time ago over on the Flex Coders list at Yahoo! Groups. If you search the Yahoo! Groups you should be able to find it, then search within that group for Hibernate and there's some information available.


I am hoping to implement a ColdFusion / Java hybrid application that uses POJOs and Hibernate in

the model, and coldfusion for the view and controller.

I've been thinking about the issues with running hibernate on CF for a while and have come up with

the following idea.


Part 1
------------------
1. Download the source for the Commons Logging package
2. Create an Eclipse project for it
3. Refactor the base package for commons logging to be:
cf.org.apache.commons.logging instead of
org.apache.commons.logging
4. Build a jar. cf-commons-logging.jar

Part 2
------------------
1. Download the souce for Hibernate
2. Create an Eclipse project for it
3. Refactor the base package for Hibernate to be:
cf.org.hibernate instead of
org.hibernate
4. Buidl a jar. cf-hibernate.jar

Part 3
------------------
Place the 2 jars you created above, along with all other supporting jars where CF can pick them up

and start/restart ColdFusion



I forgot one of the most important steps in my post above!!!

In part 2, before you build the cf-hibernate.jar, there should be an additional step:

** Do a search and replace in the entire hibernate source and update all references to: org.apache.commons.logging
to instead point to: cf.org.apache.commons.logging




Actually, now that I think about things, Step 3 under Part 2 should be eliminated. There is no need to change hibernate's package name.

So ignore the following instruction:
3.) Refactor the base package for Hibernate to be:
cf.org.hibernate instead of
org.hibernate

and instead do the following:

3.) Do a search and replace in the entire hibernate source and update all references to: org.apache.commons.logging
to instead point to: cf.org.apache.commons.logging




Beware. i tried to follow these steps today. i agree they seem like they should work & probably will in the end, but much labor! I followed build instructions carefully. Using Eclipse 3.1.

i tried building hibernate versions 2.1.2, 2.1.3, and 3.0CR2.
In each case the source files are missing this package
org.hibernate.hql.antlr

i can find nothing about this through extensive searching. building commons logging with the renamed packages went smoother.

See my post to the hibernate forum (perhaps a solution will come)
http://forum.hibernate.org/viewtopic.php?p=2306368



It looks like you actually have to build hibernate using the build.xml file that comes with it to generate this package. Then you'd have to do the refactoring..

See the notes at the bottom of the page:

http://www.hibernate.org/hib_docs/v3/api/org/hibernate/hql/antlr/package-summ...

And checkout this line in the build.xml file.
...

...

....

Man, I've got to spend some time and get this working. Back to work...



Here's a re-pose with the stuff that was between tags having it's tags removed so you can acutally see what I was posting.

It looks like you actually have to build hibernate using the build.xml file that comes with it to generate this package. Then you'd have to do the refactoring..

See the notes at the bottom of the page:

http://www.hibernate.org/hib_docs/v3/api/org/hibernate/hql/antlr/package-summ...

And checkout this line in the build.xml file.
...
property name="parser.src" value="${generated.src}/org/hibernate/hql/antlr"/
...
target name="init.antlr" depends="init"
description="Check ANTLR dependencies."
uptodate property="antlr.isUpToDate"
targetfile="${parser.src}/.antlr_run"
srcfiles dir="${grammar.dir}" includes="*.g"/
/uptodate
/target
....

Man, I've got to spend some time and get this working. Back to work...



I got CFMX 7.0.1 and Hibernate 3.1.3 working!!!! I don't know how far other people got CF and Hibernate to work, but this is totally working!! I'm doing full CRUD functionality!!

I followed the steps I outlined in my prevoius posts, which was pretty much refactoring the commons-logging and log4j packages to be "cf.org.apache..." instead of "org.apache..." and then I updated any references in the Hibernate source code to the commons-loggging and log4j packages to now point to my new "cf.org..." packages.

So after that I had 3 jar files
cf-commons-logging.jar
cf-log4j.jar
cf-hibernate.jar

I then put these files in:
__cfinstall__/wwwroot/WEB-INF/lib
and restarted MX

(I also put in the MySQL connector JAR and a JAR that my application uses - my app is a cf/java hybrid)

I created a simple test CFM template which executed a number of business actions (Java Classes) which handle all my hibernate access, and detaching objects.... and I could do everything, with NO complaints from CF!!



Why to write cfhibernate you can use hibernate...


Hi Kurt,
Can you publish the modified .jar files somewhere, so anybody can use these files?

Thanks,
-dipak


Tuesday, February 1, 2005

Open Source CF Applications

The DFW CFUG had a really great meeting last month about open source in general, and specifically as it relates to CF, so I thought I'd pass along a the presentation I put together.


It contains my general thoughts about open source as well as a list of some open source CF applications that you might not be aware of. If you have any comments or questions about this presentation (it was thrown together pretty quickly), please let me know, and particularly if you have good open source CF resources, links, applications, etc. that aren't on my list, please tell me. I'd like to keep a running link list to spread the word about open source CF applications.


This has kind of turned into a crusade of mine as of late, because I get a bit annoyed when I see CF-centric sites using PHP applications. Most recently someone started up a "worldwide CFUG" and it's running PHPBB. Its creator had all sorts of reasons for doing this (none of which were valid IMO other than perhaps the free hosting issue), but even CF Open is running on a PHP application. We all need to work to change this situation!





open_source_cf.pdf
Download this file



Comments


I wrote an article for CFDJ on how to integrate an open-source Java spell checker with ColdFusion, and created "CFSpellCheck" out of it. http://www.sys-con.com/story/?storyid=42120&DE=1 It really needs an update, and perhaps this post from you is just the motivation I need to refresh it and provide a gui for it and such...


Very cool--thanks for the reminder! I remember reading about this. I don't know that there's an existing list of open source CF apps so I'm thinking about making one; cfopen.org is a decent resource for projects (although it seems to be down today ...), but it doesn't seem to have become the centralized resource for open source CF projects that they were probably hoping. There's also OpenXCF (http://sourceforge.net/projects/openxcf/), cflib.org, and cfczone.org, so I'm looking to do something more along the lines of a simple list, or maybe even have it searchable by category, etc. and point to these other resources. When I tell people about this stuff I'm amazed at how few CFers are even aware it's out there!


There is cfopen.org too, although they seem to be offline at the moment.


Thanks Douglas, I noticed that as well--hopefully that doesn't mean they're offline permanently!


OpenXCF is home to a number of Mach II components, CFCUnit (the test harness) and Tartan (the service framework) as well as some Java CFX tags that include Excel reading/writing.


fuseblog also is a free opensource blog software coded with the fusebox metodology - http://www.riahsoftware.com/fuseblog/ (it also would great benefit by the inclusion in cfopen.org in my opinion)


Thanks for the additional info Sean and Luca. I'll get this added to my list and come up with some decent way of sharing it with folks. cfopen.org is still down ... I hope that's not a permanent thing!


Netdispatch also, a free open source fusebox newsletter marketing application, already on cfopen.org (but with no much success for now). I know that i'm not here on a team fusebox blog, but really i hope that the folks behind the rebuilding of the fusebox site will pose in great evidence the fusebox application already open source. This moment can sign a great starting point in the second decade of live for CFML !! :-)- fantastic productivity of CFML + Great and not too hard to understand framework like fusebox + natural benefits of open source (better quality, documentation, community support ) . Fusebox modularity can help so much for the building of higly modularized software package, being modularity one of the key selling point of many successfull php web software (eg Mambo).


Team Fusebox are planning to add the ability for people to submit articles and resources etc to the new fusebox.org website - I think that will address your concerns!


Excellent Sean, and I completely agree with you Luca--we have a bit of work to do in order to combat PHP on that front. It's getting better all the time, and I've seen an increasing interest in this lately, but we have some catching up to do. Modularity is definitely one of the big keys, which leads into the use of standard CF frameworks as well as more of an emphasis on OOP (something else that's increasingly on the minds of CFers). The more of this kind of stuff we can get out there the better off we'll all be. Keeping my fingers crossed on cfopen.org ... if the person who was maintaining that (IIRC it was Ray someone who also does CommunityMX, but I may be conflating people) is dropping it for time constraint or other issues I'd definitely volunteer to pick it up and host it.


I don't know what platform you will select to do the Open Source CF version... but I am game. I agree this needs to be done. There seems to be a "persistant" roadblock. You need to find a methodology to build this with and enough volenteers to get it done in that methdology.


Cool John, I noticed that you're involved with the GellyBeans project on cfopen.org which sounds like it's along these same lines, so any input you have based on your experience there will be greatly appreciated. If you want to join the project on cfopen just let me know and I'll get you added!


Send me an invite... certainly interested. I find it counter productive to have a PHP system for doing CF Opensource projects. Sure willing to see some progress made on this topic.