06
Aug
03

All about IllegalAccessException in CFMX

Occasionally when working with Java classes in ColdFusion MX gold you receive an error message, java.lang.IllegalAccessException. Why did you receive this when the method you’re calling is public? Why do we care since it’s been fixed in ColdFusion MX 6.1?

The answer to the first question leads into the second–exploring these issues helps us learn more about how ColdFusion MX works.

When you write code in ColdFusion that utilizes Java classes, the code often looks a lot like real Java. In many cases, you can actually copy simple Java code into CFScript and make it run with just a few minor changes. So how does this code differ in from real Java code in the final CFMX generated classes and why did we sometimes get java.lang.IllegalAccessException?

Even though CFML compiles down to Java, CF variables are not strongly typed and as such code that operates on these variables can not be converted directly to traditional Java method calls. Instead CFMX produces code that utilizes reflection to make the calls you specified in CFML.

Sometimes when using reflection the Java runtime won’t recognize the method call as having the necessary priviledges and generates an access exception. However, if the reflection context has sufficient privledges, then you can use the AccessibleObject functionality to tell the reflector to ignore security checks on the taget method.

ColdFusion MX 6.1 now does this for all Java calls which resolves the error message. I want to thank the CFMX team for all the fixes in CFMX 6.1 and for their great technical support and explanations, including this one, during the beta.


8 Responses to “All about IllegalAccessException in CFMX”


  1. 1 darron Aug 11th, 2003 at 7:56 pm

    Thanks for the explanation. I’m developing something on my home box (CFMX 6.1 Developer) and I tried to use it at work (CFMX) and ran into that error. I didn’t have time to investigate at all..

    Is there any sort of workaround for CFMX, or just “upgrade to 6.1″?

  2. 2 Sam Aug 12th, 2003 at 10:43 am

    This is an internal bug in CFMX that was fixed in 6.1. There is no work-around. 6.1 is a free upgrade, if you’re running CFMX and haven’t upgraded to 6.1 yet then you really should.

  3. 3 Sriram Oct 23rd, 2003 at 3:46 am

    Hi,

    We have tried upgrading the CFMX to CFMX6.1 but everytime we could not successfully upgrade to cfmx1, it there any chance that we can upgrde without any errors, your consideration in this regard will be highly appreciated.

    Regards
    Sriram
    Experthost

  4. 4 Sam Oct 23rd, 2003 at 8:13 am

    I’m sorry to hear you’re having trouble upgrading. I’d suggest calling Macromedia’s technical support or asking specific questions detailing your problems on their forums, http://webforums.macromedia.com/coldfusion.

  5. 5 vimax Mar 29th, 2004 at 11:59 am

    ColdFusion is a cool tool for programming

  6. 6 online loans Nov 2nd, 2004 at 3:24 pm

    Hello there,

    Iwas browsing the web and found this blog. Some interesting quotes. Keep them coming!

    Alice
    online loans

  7. 7 Buspar Nov 3rd, 2004 at 6:13 am

    Hi, You should check out Buspar

  8. 8 Bob Staple Nov 17th, 2004 at 7:07 am

    Guten Tag - Hier ist ein sehr schooner Site. Cheap Staples

    Danke!
    Bob Staple

Comments are currently closed.