Sunday, February 15, 2009

Apache Axis (java.io.IOException: Non nillable element '[ElementName]' is null)

Much has been written on this frustrating error (seemingly most of it along the lines of "Hey, guys, I have this problem. Anyone know what's up? ... Hello? Guys? Anyone?" Often, the are older posts referencing a known and now-fixed issue in Apache Axis 1.2 involving elements whose "nillable" attribute is set to true. However, when no value is set for that element, the aforementioned java.io.IOException is thrown. In my case, I was using ColdFusion MX7, a jar file comprised of java stub classes ripped with WSDL2Java, and a version of Axis 1.2 customized to address an issue in accessing NetSuite's web service. The element in question was a datetime field, of type java.util.Calendar specifically. Due to the web service provider's documented business logic, setting a value in that field would actually result in the request being rejected outright, so setting a dummy value was not an option. Additionally, I tried setting the element to an unitialized Calendar object, but that resulted in the same error as not setting it at alll.

Solution

My first course of action was to upgrade to Axis 1.4. No dice. I still was getting the same error. My next step was to delete the jar file I'd made of the WSDL classes from the CFusionMX7/lib directory (if you've read previous posts here regarding ColdFusion and its interactions with Axis, you understand why I tend to lean toward that method instead of using the auto-compiled stub classes in the ColdFusion installation directory), added the stub class file directory I was using to the Java classpath in ColdFusion administrator, and restarted the CF service. Blam! Problem fixed.

Post Mortem

To be honest, I am not 100% certain what the issue was, but I strongly suspect this was an issue between the version of Java that had compiled the Axis jar file distribution, the version of Java our ColdFusion installation was running on, and/or the version of Java I had used to manually compile the stub class jar file I had been using previously. If anyone else has had this issue and has further details into the "why" of the fix, I'd love to hear them.

No comments: