Archive

Archive for January, 2010

SFTP on Amazon EC2

January 29, 2010 1 comment

Amazon Elastic Compute Cloud as well as Rackspacecloud (and many others) allows you to set up a remote server and deploy your web application (among other things).
I have setup my own account and run a small instance. For this I have used Amazon Web Toolkit plugin for Eclipse.
The documentation provided with this toolkit is fine. Unfortunately for me, as usual, it doesn’t work as expected: I have tried to run an instance located in the US but it seems that’s way too far ! I used to have this popup screen:

mmm… why did I do that ? Because I thought my fellows there would have a better time response and therefore a better user experience for the prototype that I did. I have changed the settings to point to a European instance.

This time it was starting up fine with AWS.

But running a simple dynamic web application as described in their tutorials (you don’t even need a tutorial though to create that) caused some trouble.

Another solution was to transfer the WAR file on the server and then put it into the webapps folder of tomcat. To do that why not use sftp, said Loïc to himself… 🙂
As the picture above shows you can right-click on the live server and select open shell. Your command is written at the top of the shell window. Here is what you should have:
Last login: Fri Jan 29 14:01:11 on ttys005
/usr/bin/ssh -o CheckHostIP=no -o TCPKeepAlive=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=120 -o ServerAliveCountMax=100 -i /Users/loic/.ec2/eclipse-keypair.pem root@ec2-xxx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
loic-talbots-macbook-pro:~ loic$ /usr/bin/ssh -o CheckHostIP=no -o TCPKeepAlive=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=120 -o ServerAliveCountMax=100 -i /Users/loic/.ec2/eclipse-keypair.pem root@ec2-xxx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com

We have a pem file that manages the access keys to the server. In order to use them with sftp just type:
ssh-add ~/.ec2/eclipse-keypair.pem
and then you can use sftp to transfer your WAR file:
sftp root@ec2-xxx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com

Categories: Amazon web services Tags: , , , ,

Mule ESB set up with Maven under Eclipse (OSX)

January 22, 2010 2 comments

I have followed the Mule ESB tutorial and found that it did not work with Java5 on OSX. I have switched to Java6 and everything was back to normal.

Everything is explained very well on Mule web site, here is what I did to get it running with Maven 2 under Eclipse on OSX.

Firstly I have of course downloaded Mule (community edition) on their download page and expanded everything in /opt folder with the following command:

tar -xvzf mule-standalone-2.2.1.tar.gz

I’ve also downloaded the mule ide plugin for eclipse and followed the instructions here

To get it running with Maven, I used the command line in my project folder :
mvn mule-project-archetype:create -DartifactId=MMuleProject -DmuleVersion=2.2.0

and then I have the following command:
mvn eclipse:eclipse

to make it available as a project in eclipse.

Then I have launched Eclipse and imported the project:

File->import->Existing project into workspace

and I have selected the MMuleProject folder as root folder. Once the project was imported i have right-clicked on the project name MMProject in the package explorer and added Mule libraries:

project properties under eclipse

the project finally appears like the following inside the package explorer:

With Java 5 enabled I had this issue when trying to run the project : (right-click on mule-config.xml -> run as -> Mule Server)

INFO 2010-01-22 14:15:41,561 [main] org.mule.MuleServer: Mule Server initializing...
ERROR 2010-01-22 14:15:41,648 [main] org.mule.MuleServer: A Fatal error has occurred while the server was running: [[B
java.lang.ClassCastException: [[B
at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1215)
at java.net.InetAddress.getLocalHost(InetAddress.java:1350)
at org.mule.config.DefaultMuleConfiguration.(DefaultMuleConfiguration.java:116)
at org.mule.context.DefaultMuleContextBuilder.getMuleConfiguration(DefaultMuleContextBuilder.java:125)
at org.mule.context.DefaultMuleContextBuilder.buildMuleContext(DefaultMuleContextBuilder.java:84)
at org.mule.context.DefaultMuleContextFactory.buildMuleContext(DefaultMuleContextFactory.java:197)
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:186)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:168)
at org.mule.MuleServer.initialize(MuleServer.java:351)
at org.mule.MuleServer.run(MuleServer.java:257)
at org.mule.MuleServer.start(MuleServer.java:244)
at org.mule.MuleServer.main(MuleServer.java:121)
ERROR 2010-01-22 14:15:41,671 [main] org.mule.MuleServer:

Switching to JDK 6 solved it :

INFO 2010-01-22 14:18:18,142 [main] org.mule.DefaultMuleContext:
**********************************************************************
* Mule ESB and Integration Platform *
* Version: 2.2.0 Build: 14110 *
* MuleSource, Inc. *
* For more information go to http://mule.mulesource.org *
* *
* Server started: 1/22/10 2:18 PM *
* Server ID: 999d182b-0758-11df-82a2-811cd9e5dabf *
* JDK: 1.6.0_15 (mixed mode) *
* OS encoding: UTF-8, Mule encoding: UTF-8 *
* OS: Mac OS X (10.5.8, x86_64) *
* Host: loic-talbots-macbook-pro.local (192.168.0.10) *
* *
* Agents Running: None *

pheeewww… it should have taken a few minutes, it took a few hours to figure out I should not use JDK5. Now I’ll experience this lightweight SOA architecture to expose SOAP web services. Something for a next post.

Categories: SOA Tags: , , ,