tag:blogger.com,1999:blog-31425501.post-30506151999265965672008-04-16T14:08:00.005-05:002008-04-30T11:34:04.300-05:00Process for generating Netsuite java files, compiling stub classes, and creating jar fileIf you've read other posts I've done about ColdFusion and Netsuite integration, you may recall that I solved an issue with MX7 refusing to compile all of the necessary stub files from the Netsuite WSDL by manually compiling them and creating a jar file. This used to be a huge hassle for me each time Netsuite released an upgrade. This time, however, it should be a ridiculously smooth process. I know the following steps will look intimidating if you are not familiar with <a href="http://ant.apache.org/">Apache ANT</a> or <a href="http://ant.apache.org/ivy/">Apache Ivy</a>, but trust me, they will make your life a lot easier.<br /><br />Someone recently wrote me with some questions about this process, and I thought I would post this for everyone's benefit. Or at least I hope it's for your benefit and not your additional confusion. *grin*<br /><br />Oh, and a couple of notes. I have not done any development in ColdFusion 8, so some of the steps and issues below may not apply. In fact, this entire process may not be necessary at all for all I know. Also I'm quite green when it comes to ANT and Ivy, so as with everything else I post here, if there is a more efficient way to any of these steps, I'd love to hear from you.<br /><br /> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >Assumptions for this process (modify as necessary for your environment):<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >[Netsuite WSDL version] = 2_6_0</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >[CF install path] = C:\CFusionMX7</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >You are using ColdFusion MX 7 (Notes for ColdFusion 8 will be given where necessary)</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >[java install path] = C:\j2sdk1.4.2_12</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >[major java version that your CF installation uses] = 1.4</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >[stub class target] = C:\netsuiteclasses\2_6_0</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >[Apache Axis version] = 1.2.1</span></li></ul> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >Prerequisites: </span></p> <ul type="disc"><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >You have Apache ANT 1.7.0 or higher installed and have all environment variables set per its installation documentation. (Download binaries and see documentation at http://ant.apache.org/)</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >You have Apache Ivy 2.0.0 beta 2 or higher installed and have all environment variables set per its installation documentation. (Download binaries and see documentation at http://ant.apache.org/ivy/)</span></li><li class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >A version of the java jdk compatible with the java runtime version of your ColdFusion installation.</span></li><li class="MsoNormal" style=""><b style=""><i style=""><span style=";font-family:Arial;font-size:10;" >NOTE: This item is only for ColdFusion MX7 and likely does not apply to ColdFusion 8.</span></i></b><span style=";font-family:Arial;font-size:10;" > A modified version of the Apache Axis 1.2 jar file (axis.jar) (distributed by Netsuite to fix a login issue caused by how cookies are passed by Axis in the HTTP header) was copied into <b style=""><i style="">[CF install path]</i></b>\lib, and the ColdFusion server was restarted afterward.</span></li></ul> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" ><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >Generate and Compile Process:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" ><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >1. Generate java class source code (windows dos window).<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=";font-family:Arial;font-size:10;" >[java install path]\bin\java -cp <b style=""><i style="">[CF install path]</i></b>\runtime\lib\wsdl2java.jar org.apache.axis.wsdl.WSDL2Java -v -O 120 -a -o <b style=""><i style="">[stub class target]</i></b> https://webservices.netsuite.com/wsdl/<b style=""><i style="">[Netsuite WSDL version]</i></b>/netsuite.wsdl<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=";font-family:Arial;font-size:10;" >2. Create Apache ANT build file.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=";font-family:Arial;font-size:10;" >Create a file named build.xml in <b style=""><i style="">[stub class target] </i></b>with the following contents (pay attention to bracketed areas that you will need to modify accordingly):<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=""><?xml version="1.0" encoding="UTF-8"?><br /><project name="netsuite_<b style=""><i style="">[Netsuite WSDL Version]</i></b>" default="init" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant"><br /><span style=""> </span><description><br /><span style=""> </span>Build file for Netsuite <b style=""><i style="">[Netsuite WSDL Version]</i></b> WSDL.<br /><span style=""> </span></description><br /><span style=""> </span><property name="classes.dir" location="classes" /><br /><span style=""> </span><property name="dist.dir" location="dist" /><br /><span style=""> </span><property name="dist.jarfile" value="netsuite_<b style=""><i style="">[Netsuite WSDL Version]</i></b>.jar" /><br /><br /><span style=""> </span><target name="resolve" description="--> retrieve dependencies with ivy"><br /><span style=""> </span><ivy:retrieve pattern="${lib.dir}/[type]/[artifact]-[revision].[ext]" conf="runtime"/><br /><span style=""> </span></target><br /><br /><span style=""> </span><target name="clean" description="Clean up output directories."><br /><span style=""> </span><delete dir="${classes.dir}" /><br /><span style=""> </span></target><br /><br /><span style=""> </span><target name="compile" depends="-init" description="Compile all sources."><br /><span style=""> </span><mkdir dir="${classes.dir}" /><br /><span style=""> </span><javac srcdir="." destdir="${classes.dir}" debug="true" deprecation="true"><br /><span style=""> </span><compilerarg line="-source <b style=""><i style="">[major java version that your CF installation uses]</i></b>" /> <!—NOTE: The “-source” option may not be necessary for CF8 --><br /><span style=""> </span><compilerarg line="-classpath <b style=""><i style="">[CF install path]</i></b>\lib\axis.jar; <b style=""><i style="">[CF install path]</i></b>\lib\jaxrpc.jar" /><br /><span style=""> </span></javac><br /><span style=""> </span></target><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=""><span style=""> </span><target name="rebuild" depends="clean,compile" description="Cleanly compiles all sources." /><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=""><span style=""> </span><target name="-init"><br /><span style=""> </span><!-- Create the time stamp. --><br /><span style=""> </span><tstamp><br /><span style=""> </span><format property="TODAY_US" pattern="dd MMM yyyy HH.mm" locale="en_US" /><br /><span style=""> </span></tstamp><br /><span style=""> </span></target><br /><br /><span style=""> </span><target name="dist" depends="rebuild" description="Creates the binary distribution."><br /><span style=""> </span><mkdir dir="${dist.dir}/${TODAY_US}" /><br /><span style=""> </span><jar basedir="${classes.dir}" destfile="${dist.dir}/${TODAY_US}/${dist.jarfile}" /><br /><span style=""> </span></target><br /><br /></project><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=";font-family:Arial;font-size:10;" >3. Create Apache Ivy config file.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=";font-family:Arial;font-size:10;" >Create a file named ivy.xml in <b style=""><i style="">[stub class target] </i></b>with the following contents (pay attention to bracketed areas that you will need to modify accordingly):<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=""><ivy-module version="2.0"><br /><span style=""> </span><info organisation="apache" module="hello-ivy"/><br /><span style=""> </span><dependencies><br /><span style=""> </span><dependency org="apache" name="axis" rev="<b style=""><i style="">[Apache Axis version]</i></b>"/><br /><span style=""> </span></dependencies><br /></ivy-module><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=";font-family:Arial;font-size:10;" >4. Compile files and generate jar file.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style=";font-family:Arial;font-size:10;" >Open a Command Prompt window and change directories to your <b style=""><i style="">[stub class target]</i></b> directory and run the following command:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="">ant dist<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" ><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" >You may see multiple warning messages throughout the compile process, but as long as you see a <i style="">BUILD SUCCESSFUL</i> message upon completion, there shouldn’t be any problems. Copy the generated jar file (the output of the ant command should indicate the filename and location of the jar file) to <b style=""><i style="">[CF install path]</i></b>\lib and restart your ColdFusion Application Server service.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style=";font-family:Arial;font-size:10;" ><o:p> </o:p></span></p>Jeremy "King Skidz" Gibbensnoreply@blogger.com