Amazon Web Services and SimpleDB Part Two

Next item: adding the AWS jar file libraries to the ant build.xml file.

Actually – this gets a bit round about.  Amazon supplies the SDK files – and if I had more experience with Eclipse this probably would not have been an issue.  In any event – I downloaded the AWS SDK for Java files into a directory on my C drive – C:\AWS_HOME to be exact.  I added the files to my path and class path – didn’t matter for building a servlet as the code wouldn’t compile.

Next step – I added a folder in my project, copied the AWS jar files into that file and set the path in my ant build.xml file.  Okay – got it to compile but Jetty would bomb.

Onto step number three – I added the following files to my Jetty ..\lib\ext folder:

From \aws-java-sdk-1.2.10\lib – aws-java-sdk-1.2.10.jar, aws-java-sdk-1.2.10-javadoc.jar and aws-java-sdk-1.2.10-sources.jar.

From \aws-java-sdk-1.2.10\third-party\commons-codec-1.3\commons-codec-1.3.jar.

From \aws-java-sdk-1.2.10\third-party\commons-logging-1.1.1\commons-logging-1.1.1.jar.

And lastly from \aws-java-sdk-1.2.10\third-party\httpcomponents-client-4.1.1\httpclient-4.1.1.jar and httpcore-4.1.jar.

My code would now compile – but then I got a weird error attempting to connect to SimpleDB.  I’m working with a 64 bit version of Windows 7, and Amazon supplies a 32 bit encrypt/decrypt codec from Apache.  I downloaded the commons-codec-1.5 jar file from Apache and added that to my Jetty directory – now it all worked fine.

Issue four – I naively thought that the Tomcat environment I was using on Amazon would have the library files included to connect to SimpleDB.  I was wrong – I had to include the files in my build file.  I created a WEB-INF\lib directory and placed copies of the above files into it.  My ant build file now included:

<path id=”compile.classpath”>

<fileset dir=”${env.JETTY_HOME}/lib”>

<include name=”**/*.jar”/>

fileset>

<fileset dir=”${env.AWS_HOME}/third-party” includes=”**/*.jar”/>

<fileset dir=”${env.AWS_HOME}/lib” includes=”**/*.jar”/>

<pathelement location=”.”/>

<pathelement location=”../lib/aws-java-sdk-1.2.10.jar”/>

<pathelement location=”../lib/aws-java-sdk-1.2.10-javadoc.jar”/>

<pathelement location=”../lib/aws-java-sdk-1.2.10-sources.jar”/>

<pathelement location=”../lib/commons-codec-1.5.jar”/>

<pathelement location=”../lib/commons-codec-1.5-javadoc.jar”/>

<pathelement location=”../lib/commons-codec-1.5-sources.jar”/>

<pathelement location=”../lib/commons-logging-1.1.1.jar”/>

<pathelement location=”../lib/httpclient-4.1.1.jar”/>

<pathelement location=”../lib/httpcore-4.1.jar”/>

</path>

Success!  Now not only could I connect to SimpleDB on my client using Jetty, but also on my Amazon environment.

Next post – some more on using SimpleDB.

Advertisements

About Lee Greffin
Just another programmer...

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: