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.
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″?
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.
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
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.
ColdFusion is a cool tool for programming
Hello there,
Iwas browsing the web and found this blog. Some interesting quotes. Keep them coming!
Alice
online loans
Hi, You should check out Buspar
Guten Tag – Hier ist ein sehr schooner Site. Cheap Staples
Danke!
Bob Staple