Ian Winter Ian Winter

CF8 JRun init script error

Setting up a staging server environment which will run 3 instances of CF and looking to alter the init scripts so it fires them all up on boot. Took a look at the one the installer creates and thought simple enough to just put multiple calls in for each server instance. Oh no.

On our RHES4 platform we have CF starting up as the apache user, but, running the script causes a "This account is currently not available." error to be thrown because it has no shell and it's locked. After looking at another server running a server install I notice the issue is down to the su command issued.

JRun

su $RUNTIME_USER -c "$CF_DIR/bin/jrun -stop cfusion"
su $RUNTIME_USER -c "$CF_DIR/bin/jrun -start cfusion >& $CF_DIR/logs/cfusion-event.log &"

Server Install

su -s /bin/sh $RUNTIME_USER -c "export PATH=$PATH:$CF_DIR/runtime/bin; export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
; cd $CF_DIR/runtime/bin; nohup $CF_DIR/runtime/bin/cfmx7 -jar jrun.jar -autorestart -start coldfusion &"

Key difference is the "-s /bin/sh" part. Altering my script to the following makes it work. Yay. Not sure if this a known bug of something funky in our setup, but, as it's a vanilla OS install I don't see what it could be.

su -s /bin/sh $RUNTIME_USER -c "$CF_DIR/bin/jrun -stop cfusion"
su -s /bin/sh $RUNTIME_USER -c "$CF_DIR/bin/jrun -start cfusion >& $CF_DIR/logs/cfusion-event.log &"

CFMail and Gmail

Been looking a lot lately at various email related projects. One of the issues I noticed as part of this work is that if you send a mail with cfmail to a gmail account that only has a cfmailpart text/plain gmail won't render it.

If you send both, it works fine.

Plain
Strong HTML

So, if you're sending plain only, don't put it in a cfmailpart. Probably shouldn't have been in the first place, but, issue now solved.

ColdFusion 8.0.1

The latest update to ColdFusion has been released in the form of 8.0.1 which will let you have a painless install on Leopard and on 64 bit OS'

Full details on the Adobe site.

A lot of other tweaks and bug fixes as well including new FCKEditor and changes to the attributeCollection stuff.

ColdFusion Leap Year Fun

So just an update on this. I sent off some emails to folks at Adobe and have had acknowledgment but as yet no reply. I'll you know if and when I get something back.

Coldfusion possible Leap Year bug

My colleague noticed that as of midnight GMT one of our applications at work broke. After some digging it looks like a CF leap year bug.

<cfset attributes.minage = 18>
<cfoutput>
#now()#<br />
#attributes.minage#<br />
#dateadd("yyyy", -(attributes.minage), now())#<br>
#datediff("yyyy", dateadd("yyyy", -(attributes.minage), now()), now())#<br />
#datediff("yyyy", dateadd("yyyy", -(attributes.minage), now()), DateAdd("d", 1, now()))#
</cfoutput>

The code was run on CF 7.0.1, 7.0.2 & 8.0.0 on Windows and Linux, all produce same results.

Not sure for definite it's a bug, but, it's always worked until today, in theory it might work again tomorrow as well. Last leap year of course was CF6 so may not have shown up.

Yay for dateDiff()... :|

Update

A more detailed example. It only effects the 28/2. Other dates fine suggesting more that it's leap year related.

<cfoutput>
	<cfset variables.datea = createDate(2008,02,3)>
	<cfloop from="2008" to="1990" step="-1" index="variables.y">
		<cfset variables.dateb = createDate(variables.y,02,3)>
		<cfset variables.diff = datediff("yyyy", variables.datea, variables.dateb)>
		#variables.datea# - #variables.dateb# = #variables.diff#<br />
	</cfloop>
</cfoutput>

And it's output....

{ts '2008-02-28 00:00:00'} - {ts '2008-02-28 00:00:00'} = 0
{ts '2008-02-28 00:00:00'} - {ts '2007-02-28 00:00:00'} = 0
{ts '2008-02-28 00:00:00'} - {ts '2006-02-28 00:00:00'} = -1
{ts '2008-02-28 00:00:00'} - {ts '2005-02-28 00:00:00'} = -2
{ts '2008-02-28 00:00:00'} - {ts '2004-02-28 00:00:00'} = -4
{ts '2008-02-28 00:00:00'} - {ts '2003-02-28 00:00:00'} = -4
{ts '2008-02-28 00:00:00'} - {ts '2002-02-28 00:00:00'} = -5
{ts '2008-02-28 00:00:00'} - {ts '2001-02-28 00:00:00'} = -6
{ts '2008-02-28 00:00:00'} - {ts '2000-02-28 00:00:00'} = -8
{ts '2008-02-28 00:00:00'} - {ts '1999-02-28 00:00:00'} = -8
{ts '2008-02-28 00:00:00'} - {ts '1998-02-28 00:00:00'} = -9
{ts '2008-02-28 00:00:00'} - {ts '1997-02-28 00:00:00'} = -10
{ts '2008-02-28 00:00:00'} - {ts '1996-02-28 00:00:00'} = -12
{ts '2008-02-28 00:00:00'} - {ts '1995-02-28 00:00:00'} = -12
{ts '2008-02-28 00:00:00'} - {ts '1994-02-28 00:00:00'} = -13
{ts '2008-02-28 00:00:00'} - {ts '1993-02-28 00:00:00'} = -14
{ts '2008-02-28 00:00:00'} - {ts '1992-02-28 00:00:00'} = -16
{ts '2008-02-28 00:00:00'} - {ts '1991-02-28 00:00:00'} = -16
{ts '2008-02-28 00:00:00'} - {ts '1990-02-28 00:00:00'} = -17

Calling the Mailbuild API from CF

Had to help with someone out today who was trying to call the Mailbuild API from ColdFusion. It's a webservice and was proving a little annoying to get going, but after a bit of playing the final code looks like this.

<cfscript>
 params = structNew();
 params.ApiKey = '{yourkey}';
 params.ListID = '{yourlistid}';
 params.Email = 'name@domain.com';
 params.Name = 'Name';
</cfscript>

<cfinvoke webservice="http://{company}.createsend.com/api/api.asmx?wsdl" method="AddSubscriber" parameters = "#params#">

This is adding a new subscriber to a given list. Hopefully this might help someone integrating with CF!

ColdFusion 64bit and Leopard Beta

Slow to the game on this but been busy working! If you want to get in on the 64bit / Leopard beta check out Kristen's blog.

Deploying CF7 on JRun with CF8 on Leopard, Single IP Error

Having got ColdFusion 8 running in multi-server mode on Leopard I decided to try and deploy CF7 to it as well. Started out going well, following the same process I've always used. I created a new server, removed the default-ear, started the proxy service and stopped the web service then dropped in the cf7 ear file. Setup all the apache2 config and restarted that OK. For reference I've got a jrun.conf with the module in then a cf702.conf included by default with the jrun.conf in httpd.conf then a cf8.conf I include in vhosts as needed. The server started OK but when I tried browsing the cf7.local vhost I created I was shown the message:

500

java.lang.NullPointerException at coldfusion.license.LicenseManager._isSingleIP(LicenseManager.java:171) at coldfusion.license.LicenseManager.isSingleIP(LicenseManager.java:68) at coldfusion.CfmServlet.getFilterChain(CfmServlet.java:66) at coldfusion.CfmServlet.service(CfmServlet.java:103) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Interesting as it's the same box, both configured on 127.0.0.1. A reload didn't cure it, so off to google. I found a couple of posts relating to flash remoting. The first one was over on <a href="http://www.talkingtree.com/blog/index.cfm/2004/9/15/flashgateway">Steven Erat's</a> blog from way back in 2004 related to something with flash remoting. I found a few other posts saying I'd need to remove the flash remoting ear file, which, I didn't have showing in the JMC.

I decided to take a look in the JRun4 directory to see what flash related files there were:

macmini:JRun4 ianwinter$ find . -name "*flash*"
./docs/jmchelp/gs-flash-jrun.htm
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/CFIDE/administrator/images/flashmenu.swf
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfform/flash-unicode-table.xml
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashgateway.jar
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashremoting_update.jar
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfform/flash-unicode-table.xml
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/flashgateway.jar
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/preso/loadflash.js
./servers/samples/flashsamples-ear
./servers/samples/flashsamples-ear/ejbs/flashgateway
./servers/samples/SERVER-INF/classes/flashgateway

Some of these obviously can stay but as I don't use flash remoting I decided to remove the flashgateway.jar and flashremoting-update.jar files. I backed up the servers directory as well first and have at this point stopped the servers.

macmini:JRun4 ianwinter$ sudo rm 
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashgateway.jar 
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashremoting_update.jar 
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/flashgateway.jar

Restart all the JRun servers and browse back to cf7.local and voila it works. Bit of a faf and no good if you want flash remoting but it works. I don't know if you remove just one of the flash remoting jar's, like just from the cf7 server if it'd work, or, perhaps you can change mappings somewhere, solves my problem so I'm happy.

Lingon for Leopard and starting JRun servers

I still can't get CF8 to start correctly on Leopard so having used Lingon previously on Tiger I downloaded the latest version from SourceForge. It's been redesigned for Leopard as version 2.0.1 and looks really nice.

Configuration is easy, just add in a name, I choose com.adobe.jrunStartCfusion. In the "what" box just stick in "/Applications/JRun4/bin/jrun -start cfusion" and I only choose "Run it when it is loaded by the system (at startup or login)". Once you've got that in hit save, reboot (I think logout would work but hey) and you're done. Do a quick "ps -ef | grep cfusion" and you should see your CF process.

ColdFusion Leopard & 64 bit hints

Looks like Adobe could be announcing support for ColdFusion on Leopard and 64bit (other than Solaris) soon (hopefully). [via forta.com]

More Entries

Powered by BlogCFC, 5.9.002. Contact Me

All comments, view, rants, raves and opinions are mine and mine alone.

del.icio.us Digg Flickr Last.fm LinkedIn Pownce Twitter YouTube