In ColdFusion MX, you can create a Java object by calling the handy CreateObject() function.

<CFSET myObj = CreateObject("java", "java.util.Hashtable")>

Suppose you have the following Java class:

class Person {
    private String name;

    public void setName(String n) {
       this.name = n;
    }
}

Now, let’s create an instance in ColdFusion and set a name:

<CFSET somebodySpecial = CreateObject("java", "Person")>
<CFSET somebodySpecial.setName("Chuck")>

Cool, but what happens if you pass an argument that isn’t a string:

<CFSET somebodySpecial.setName(123)>
coldfusion.runtime.java.MethodSelectionException:
    The selected method setName was not found.

Whoops! ColdFusion wasn’t able to find a method of Person with a signature of “public void setName(int)“. What you need to do is cast the arguments to the correct datatype. For this example, you could do something like this:

<CFSET somebodySpecial.setName(ToString(123))>

The problem is what if you need to call methods that use other data types such as int, double, or boolean. ToString() won’t cut it. Instead use ColdFusion’s JavaCast() function:

JavaCast(type, variable)

type        "boolean"
            "int"
            "long"
            "float"
            "double"
            "String"

variable    A ColdFusion variable that holds a scalar or string type

So, the correct way is:

<CFSET somebodySpecial.setName(JavaCast("String", 123))>
<CFSET somebodySpecial.setName(JavaCast("String", "Chuck"))>

No more MethodSelectionExceptions!


The new Parallels Desktop 3.0 for Mac is out! At first, everything looks great! Then I noticed my Cisco VPN Client v4.9 stopped working.

Error 51: Unable to communicate with the VPN subsystem. Please make sure that you have at least one network interface that is currently active and has an IP address and start this application again.

I tried uninstalling both the VPN client and Parallels, then reinstalling and everything worked until I rebooted. So, that wasn’t going to work. After doing a ton of digging around, I found this post that suggested a fix that works!

Bring up a terminal and execute an ifconfig -a:

$ ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet6 ::1 prefixlen 128 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
        inet 127.0.0.1 netmask 0xff000000 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
vmnet8: flags=8862<BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 172.16.91.1 netmask 0xffffff00 broadcast 172.16.91.255
        ether 00:50:56:c0:00:08 
vmnet1: flags=8862<BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 172.16.197.1 netmask 0xffffff00 broadcast 172.16.197.255
        ether 00:50:56:c0:00:01 
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether 00:17:f2:cd:20:02 
        media: autoselect status: inactive
        supported media: autoselect 10baseT/UTP <half-duplex>
                10baseT/UTP vfull-duplex>
                10baseT/UTP <full-duplex,hw-loopback>
                10baseT/UTP <full-duplex,flow-control>
                100baseTX <half-duplex>
                100baseTX <full-duplex>
                100baseTX <full-duplex,hw-loopback>
                100baseTX <full-duplex,flow-control>
                1000baseT <full-duplex>
                1000baseT <full-duplex,hw-loopback>
                1000baseT <full-duplex,flow-control> none
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        tunnel inet  -->
        inet6 fe80::219:e3ff:fe06:93f0%en1 prefixlen 64 scopeid 0x7 
        inet 192.168.1.97 netmask 0xffffff00 broadcast 192.168.1.255
        ether 00:19:e3:06:93:f0 
        media: autoselect status: active
        supported media: autoselect
        vlan: 0 parent interface: <none>
        bond interfaces: <none>
wlt1: flags=41<UP,RUNNING> mtu 1500
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 2030
        inet 169.254.90.185 netmask 0xffff0000 broadcast 169.254.255.255
        lladdr 00:19:e3:ff:fe:69:37:c4 
        media: autoselect <full-duplex> status: inactive
        supported media: autoselect <full-duplexv
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        inet6 fe80::21c:42ff:fe00:0%en2 prefixlen 64 scopeid 0xa 
        inet 10.0.1.3 netmask 0xffffff00 broadcast 10.0.1.255
        ether 00:1c:42:00:00:00 
        media: autoselect status: active
        supported media: autoselect
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        inet6 fe80::21c:42ff:fe00:1%en3 prefixlen 64 scopeid 0xb 
        inet 10.0.2.12 netmask 0xffffff00 broadcast 10.0.2.255
        ether 00:1c:42:00:00:01 
        media: autoselect status: active
        supported media: autoselect

Find the interface that starts with “fw”. In my case, mine is called “fw0”. Next, shut off the interface:

$ sudo ifconfig fw0 down

fw0’s flags will now be 8822 and now the Cisco VPN client should work!

But what happens if you reboot? Oops! The fw0 interface comes back on. Disable the interface when the Cisco VPN subsystem is started:

$ sudo pico /System/Library/StartupItems/CiscoVPN/CiscoVPN

Then change the StartService() function to look like this:

StartService ()
{
    #disable fw0
    /sbin/ifconfig fw0 down

    if [ -d $CISCO_VPN_DIR ]; then
        ConsoleMessage "Starting Cisco Systems VPN Driver"
        kextload $CISCO_VPN_DIR
    fi
}

Test with a quick reboot and everything should work!


Parallels Desktop 3.0 for Mac

Jun 01, 2007

Virtualization is an essential tool these days for cross-platform development and testing. Parallels is a piece of software that allows you to create virtual machines that can run a variety of operating systems such as Linux and Windows. I use a MacBook Pro, so in order to run other operating systems, Parallels is the way to go.

Parallels

Version 3.0 of Parallels Desktop for the Mac is on the verge of being released this June. If you are currently a Parallels Desktop for Mac customer, you can upgrade for only $40 before June 6th. That’s 50% off! Whoo!

Parallels

Here’s a list of new features:
Completely Seamless User Experience:

  • Cross OS application & file integration with Parallels SmartSelect
  • Offline access to virtual machine files with Paralles Explorer
  • Coherence 2.0, including shared folders and UI enhancements
  • Linux Tools for seamless integration betwen Mac OS X and Linux

Native Hardware Experience

  • 3D graphics support to play the hottest games and run the most popular applications
  • Expanded support for USB 2.0 devices
  • USB connection assistant quickly connects you to your OS of choice
  • Shared printers for cross OS printing
  • Significantly enhancements performance and audio quality

Protection against Mishaps

  • Hit a problem? Quickly and easily go back in time to a clean VM state
  • Bulletproof your VMs with SnapShots
  • Control the levels of integration and isolation with Security Manager
  • Make your virtual machine read-only
  • Get virus and spyware protection with a FREE 6-month Kaspersky
    subscription trial

They claim that 3D graphics are supported now, so you can run your favorite Windows games. I assume that you can run other 3D applications such as Autodesk Inventor or 3D Studio Max. I am curious if 3D acceleration is supported for Linux VMs.

Parallels

I’ve already pre-ordered my upgrade. If you have a Intel-based Mac, you should seriously consider giving Parallels a try.