<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CUYHQXgzfCp7ImA9WhBaEk0.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731</id><updated>2013-05-22T09:12:10.684+03:00</updated><category term="mail" /><category term="nexus" /><category term="proxy" /><category term="jdbc" /><category term="web-services" /><category term="jndi" /><category term="registry" /><category term="junit" /><category term="my projects" /><category term="maven" /><category term="unit-testing" /><category term="tomcat" /><category term="coding guidelines" /><category term="about" /><category term="http" /><category term="mssql" /><category term="deployments" /><category term="infinispan" /><category term="wink" /><category term="encoder" /><category term="testng" /><category term="windows tricks" /><category term="git" /><category term="jetty" /><category term="spring" /><category term="windows" /><category term="eclipse" /><category term="devops" /><category term="axis2" /><category term="jax-ws" /><category term="xml" /><category term="hibernate" /><category term="java" /><category term="webdav" /><category term="security" /><category term="cifs" /><category term="putty" /><category term="rest-design" /><category term="jvm" /><category term="oracle" /><category term="httpclient" /><category term="kindle" /><category term="rest" /><category term="interview" /><category term="replace-file-plugin" /><category term="sql" /><category term="jpa" /><category term="unix" /><category term="tarlog-plugins" /><category term="javac" /><category term="surveys" /><category term="webos" /><category term="digital signatures" /><category term="palm" /><category term="ssl" /><category term="saml" /><category term="https" /><category term="axis" /><category term="jgroups" /><category term="gmail" /><category term="utilities" /><category term="google" /><title>Tarlog on Java</title><subtitle type="html">My blog on Java and other technical issues.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://tarlogonjava.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>99</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/tarlogonjava" /><feedburner:info uri="tarlogonjava" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CEQBRXk7fCp7ImA9WhBaEk0.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-6839933173628510300</id><published>2013-05-21T10:26:00.000+03:00</published><updated>2013-05-22T08:59:14.704+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-22T08:59:14.704+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="devops" /><category scheme="http://www.blogger.com/atom/ns#" term="deployments" /><category scheme="http://www.blogger.com/atom/ns#" term="nexus" /><category scheme="http://www.blogger.com/atom/ns#" term="maven" /><title>DevOps: Making Fast Deployments of Java Servers using Maven and Nexus</title><content type="html">&lt;i&gt;&lt;b&gt;A Warning:&lt;/b&gt; this post is theoretical. I have never tried something like this yet. Maybe I will try it in the future. But currently it's just a nice idea.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;In addition, if you know about somebody who works in a similar way, I would really like to know. So please comment!&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
If you provide a SAAS service you probably have multiple Java servers running in some sort of a cluster. If your SAAS solution is complicated, and if your solution is multi-tier, you should have multiple servers types. And now comes a question: &lt;b&gt;How to make quick deployments to the production?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The common solution suggests that you build a package and release it. It might be a war, or a zip, or a rpm if you are running on Linux.&lt;br /&gt;
Once released, you upload the package to the server, unzip/copy it to the relevant folder and restart the server.&lt;br /&gt;
&lt;br /&gt;
The problem with this solution might be if your packages are large. (And if you are using OSGi, your packages are usually very large!) So the upload itself takes time. It also uses traffic which might become expensive if you perform a lot of deployments. And the really funny thing is that most of the upload is redundant: most of the jars in your package are third parties that do not change between the deployments at all!&lt;br /&gt;
&lt;br /&gt;
The common solution suggests pre-uploading the third party jars to the server and exclude them from the package. I've seen such a solutions and in my opinion they are the exact opposite of a good solution: in this way you split the package, the third parties become manages in two (sometimes more) places and each deployment involves at least additional (probably manual!) step of checking if the third parties were changed and if additional deployment if third parties is required.&lt;br /&gt;
&lt;br /&gt;
But if you use Maven. And if you upload your released packages to Nexus (or actually any other Maven repository). This Nexus repository contains all the third parties, all the released packages and the most important: &lt;b&gt;The pom file that was used to build your project!&lt;/b&gt;&lt;br /&gt;
If you download this pom file, you will be able to build the package on the production server! Pay attention that you don't need to do the full build that includes the compilation, testing and so on. You just need your package, so considering that you deploy a war, you only need to run the &lt;i&gt;"mvn war:war"&lt;/i&gt; (Once again: I never tried it myself and the actual execution might be more complex, but I think that the idea is clear).&lt;br /&gt;
Sometimes, if you a running a java application with a main class (pure old java and not some kind of JEE inside the application server or a servlet container), you don't even need a package, you just need a correct classpath and Maven will be happy to assist you: &lt;i&gt;mvn dependency:build-classpath&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
So I guess that the idea is clear now. Each time Maven will download only the relevant jars and save them to the local repository. The dependencies are managed in the same pom file that is used to release the application, so when making a package, or creating a classpath on a production machine, the exact same dependencies will be used.&lt;br /&gt;
And the deployment process will become much faster!&lt;br /&gt;
&lt;br /&gt;
I know that this idea is somewhat different from the usual process. Instead of doing some like "build, deploy, run", we do something that might look even more complicated: "build, deploy descriptor only, package, run". But this should be much faster. So I definitely think that this idea is worth trying.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
P.S. The idea described in this post relates only to the package itself: building, packaging and running. The deployment may contains additional steps like changing the local configuration files and so on. These steps are not covered here as they are usually not covered in a build process, but part of release notes. The possible solution can be deploying the relevant scripts to Nexus repository and somehow describe them in a pom file. When downloading the pom, the relevant scripts will be also downloaded and executed. &lt;br /&gt;
&lt;br /&gt;
P.P.S. The idea also doesn't cover the tool that makes the whole process. Although it describes that the tool is using Maven, it says nothing about the actual implementation. It might be a java process. Or a shell script. Or even Ant.&lt;br /&gt;
&lt;br /&gt;
P.P.P.S. Notice that downloading files from Nexus using Maven makes important checks for you, for example it makes an integrity check, which is very important in case of a bad network between the Nexus with releases and a production site. &lt;br /&gt;
In addition, you can make some optimizations on Nexus. For example, if you have several production sites all over the world, each site may have a Nexus pointing to the main release repository and caching it. This will make the deployments even faster.&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;h3&gt;Recommended Reading&lt;/h3&gt;&lt;a href="http://www.amazon.com/gp/product/0988262592/ref=as_li_ss_il?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0988262592&amp;linkCode=as2&amp;tag=tarlog-20"&gt;&lt;img border="0" src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;ASIN=0988262592&amp;Format=_SL110_&amp;ID=AsinImage&amp;MarketPlace=US&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=tarlog-20" &gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=tarlog-20&amp;l=as2&amp;o=1&amp;a=0988262592" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;&lt;a href="http://www.amazon.com/gp/product/0321601912/ref=as_li_ss_il?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321601912&amp;linkCode=as2&amp;tag=tarlog-20"&gt;&lt;img border="0" src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;ASIN=0321601912&amp;Format=_SL110_&amp;ID=AsinImage&amp;MarketPlace=US&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=tarlog-20" &gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=tarlog-20&amp;l=as2&amp;o=1&amp;a=0321601912" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;&lt;a href="http://www.amazon.com/gp/product/B005JYRL3G/ref=as_li_ss_il?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B005JYRL3G&amp;linkCode=as2&amp;tag=tarlog-20"&gt;&lt;img border="0" src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;ASIN=B005JYRL3G&amp;Format=_SL110_&amp;ID=AsinImage&amp;MarketPlace=US&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=tarlog-20" &gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=tarlog-20&amp;l=as2&amp;o=1&amp;a=B005JYRL3G" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;&lt;br /&gt;
&lt;hr /&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/6839933173628510300/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=6839933173628510300" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6839933173628510300?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6839933173628510300?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/ieTKEATXplk/devops-making-fast-deployments-of-java.html" title="DevOps: Making Fast Deployments of Java Servers using Maven and Nexus" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2013/05/devops-making-fast-deployments-of-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUUHQXs8eSp7ImA9WhBTF0s.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-8792995921479511640</id><published>2013-02-13T16:53:00.001+02:00</published><updated>2013-02-13T16:53:50.571+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-13T16:53:50.571+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="jetty" /><category scheme="http://www.blogger.com/atom/ns#" term="coding guidelines" /><title>Deadlock in Jetty or Be Careful while Synchronizing</title><content type="html">About nine months ago I &lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=377610"&gt;reported a bug&lt;/a&gt; to the Jetty community that session timeout doesn't work properly. The bug was fixed quite quickly, but nine months later I have discovered that the fix leads to a &lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=399799"&gt;deadlock&lt;/a&gt; in some scenarios. &lt;br /&gt;
&lt;br /&gt;
Deadlock in Jetty illustrates an interesting coding guideline that you must follow while writing your code.&lt;br /&gt;
&lt;br /&gt;
So what happened in Jetty?&lt;br /&gt;
&lt;br /&gt;
Consider a class A that carries state and lives in a multi-threaded environment. Obviously this class must be synchronized.&lt;br /&gt;
Consider that you can subscribe to events of class A. So let's say class you must implement an interface I that will be notified when something important in class A happens.&lt;br /&gt;
Let's assume that the method in which class A invokes instances of I is synchronized (A carries state, remember?)&lt;br /&gt;
Let's also assume that your implementation of I also carries state and must be synchronized as well.&lt;br /&gt;
&lt;br /&gt;
And now let's see what happens:&lt;br /&gt;
&lt;br /&gt;
Thread-1: Some event on A occurs. It's wants to notify I, but first acquires LOCK_A and then invokes method of I. Method of I tries to change state of I, so it tries to acquire LOCK_I, but it was already acquired by Thread-2.&lt;br /&gt;
&lt;br /&gt;
Thread-2: Runs on I. It changes the state of I, so it acquires the LOCK_I. During the change it needs some information of A. It tries to get it, but LOCK_A was already acquired by class A.&lt;br /&gt;
&lt;br /&gt;
And here we have a deadlock.&lt;br /&gt;
&lt;br /&gt;
So what is wrong here?&lt;br /&gt;
The most wrong part is of class A: it invokes method of some other class while it is locked. BAD! Finish the lock before calling someone else! And when I say "someone else" I include the other methods of the class! (What really happened in Jetty is that in class A method f1() was synchronized. Method f1() called to f2(), which called to f3(), which called to f4(), which called to I. It was clear in f4() that no synchronization is needed. But the mistake is actually in f1()!)&lt;br /&gt;
So you have some member to change? acquire the lock, change them and release the lock.&lt;br /&gt;
&lt;br /&gt;
In addition, the situation could be a little improved if Read-Write lock was used instead of synchronized: most of the access to class are to read data. May be if LOCK_A was split to READ_LOCK_A and WRITE_LOCK_A; and LOCK_I was split to READ_LOCK_I and WRITE_LOCK_I, it was not causing the deadlock. But this is not about preventing the situation, but about improving.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Summary&lt;/h2&gt;The main point of my post is that when synchronizing, find the critical section and synchronize it only! Do not call other methods (even if they are of the same class) from the critical section: gather all information before and notify everyone else after.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/8792995921479511640/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=8792995921479511640" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8792995921479511640?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8792995921479511640?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/Zp2i0YIORnA/deadlock-in-jetty-or-be-careful-while.html" title="Deadlock in Jetty or Be Careful while Synchronizing" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2013/02/deadlock-in-jetty-or-be-careful-while.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QHQHk4eSp7ImA9WhNbEUo.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-965449592114183779</id><published>2013-01-14T16:53:00.001+02:00</published><updated>2013-01-14T16:55:31.731+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-14T16:55:31.731+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jgroups" /><category scheme="http://www.blogger.com/atom/ns#" term="infinispan" /><title>Initiate Infinispan with a Custom JChannel</title><content type="html">In all Infinispan sample the JGroups part is almost omitted. You are told that you should provide a configuration xml and the infinispan-core.jar contains three samples: udp, tcp and ec2.&lt;br /&gt;
&lt;br /&gt;
But what happens if you don't want to use samples? What happens if you want to have a dynamic configuration that changes based on the environment/database/external configuration tool? What happens if you want to configure it from code?&lt;br /&gt;
&lt;br /&gt;
It appears to be not an easy task, but not very complicated. A special interface org.infinispan.remoting.transport.jgroups.JGroupsChannelLookup exists that allows an injection of org.jgroups.Channel. &lt;br /&gt;
&lt;br /&gt;
So you can write something like: &lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;public classJGroupsChannelLookupImpl implements JGroupsChannelLookup {
   
    public Channel getJGroupsChannel(Properties p) {
        return new JChannel();  // of course the code here might be quite complex, initializing the channel with a custom configuration
    }

   
    public boolean shouldStartAndConnect() {
        return true; // change to false if you start and connect the channel yourself
    }

    
    public boolean shouldStopAndDisconnect() {
        return true; // change to false if you stop and disconnect the channel yourself
    }
}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Make sure to have a default public noargs constructor or a static getInstance() method that returns an instance of JGroupsChannelLookup.&lt;br /&gt;
(Personally I prefer a static method, so I have control how the instance is created and managed)&lt;br /&gt;
&lt;br /&gt;
Now you need to tell the Infinispan to use your JGroupsChannelLookup:&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;Configuration conf = new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC).sync().build();
GlobalConfiguration globalConf = new GlobalConfigurationBuilder().clusteredDefault().transport()
                    .addProperty(JGroupsTransport.CHANNEL_LOOKUP, JGroupsChannelLookupImpl.class.getName()).asyncTransportExecutor()
                    .build();

            
DefaultCacheManager manager = new DefaultCacheManager(globalConf, conf);&lt;/pre&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/965449592114183779/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=965449592114183779" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/965449592114183779?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/965449592114183779?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/H4GgzReWHgE/initiate-infinispan-with-custom-jchannel.html" title="Initiate Infinispan with a Custom JChannel" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2013/01/initiate-infinispan-with-custom-jchannel.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MGSHY4eSp7ImA9WhJaEUU.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-8195478218339313056</id><published>2012-10-02T14:29:00.001+02:00</published><updated>2012-10-02T14:37:09.831+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-02T14:37:09.831+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="gmail" /><category scheme="http://www.blogger.com/atom/ns#" term="mail" /><title>Send Mail Via Gmail</title><content type="html">I already spent some time few years ago to figure that out and now I spent this time again.&lt;br /&gt;
So here's the short code snippet with an example how to send mail using Java Mail and GMail.&lt;br /&gt;
&lt;br /&gt;
First, pom.xml. Include the following dependencies:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;&amp;lt;dependency&amp;gt;
    &amp;lt;groupid&amp;gt;javax.mail&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactid&amp;gt;javax.mail-api&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.4.5&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;
&amp;lt;dependency&amp;gt;
    &amp;lt;groupid&amp;gt;javax.mail&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactid&amp;gt;mail&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.4.5&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
And now the code:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;import java.util.Date;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import com.sun.mail.smtp.SMTPTransport;

public class SendMail {

 public static void main(String[] args) throws Exception {
  Properties props = System.getProperties();
  props.put("mail.smtps.host", "smtp.gmail.com");
  props.put("mail.smtps.auth", "true");
  Session session = Session.getInstance(props, null);
  Message msg = new MimeMessage(session);
  msg.setFrom(new InternetAddress("somebody@gmail.com"));
  msg.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse("somebody_else@gmail.com", false));
  msg.setSubject("I'm the subject!");
  msg.setText("And I'm text of your message");
  msg.setHeader("X-Mailer", "Java Program");
  msg.setSentDate(new Date());
  SMTPTransport t = (SMTPTransport) session.getTransport("smtps");
  t.connect("smtp.gmail.com", "somebody@gmail.com",
    "here comes the password");
  t.sendMessage(msg, msg.getAllRecipients());
  System.out.println("Response: " + t.getLastServerResponse());
  t.close();
 }
}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
And the thanks goes &lt;a href="http://stackoverflow.com/a/73649/547779"&gt;here&lt;/a&gt;.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/8195478218339313056/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=8195478218339313056" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8195478218339313056?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8195478218339313056?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/c30Pibn6iHQ/send-mail-via-gmail.html" title="Send Mail Via Gmail" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/10/send-mail-via-gmail.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMCR385eSp7ImA9WhJSEUk.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-4446109573310580162</id><published>2012-07-01T14:47:00.001+03:00</published><updated>2012-07-01T14:51:06.121+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-01T14:51:06.121+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="httpclient" /><category scheme="http://www.blogger.com/atom/ns#" term="ssl" /><category scheme="http://www.blogger.com/atom/ns#" term="https" /><title>Apache HTTP Client - Ignore SSL Problems</title><content type="html">Sometimes, especially when testing, it can be useful to make Apache HTTP Client ignore the SSL problems.&lt;br /&gt;
SSL problems may include ignoring of certificate trust (issuers) and host verification. The following snippet creates an Apache HttpClient with SingleClientConnManager that will ignore the SSL problems:&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;

public HttpClient createHttpClient() {
  TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {

    @Override
    public java.security.cert.X509Certificate[] getAcceptedIssuers() {
     return null;
    }

    @Override
    public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
    }

    @Override
    public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
    }
  } };
  SSLContext context = SSLContext.getInstance("TLS");
  context.init(null, trustAllCerts, null);

  SSLSocketFactory sf = new SSLSocketFactory(context, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

  SchemeRegistry schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
  schemeRegistry.register(new Scheme("https", 443, sf));

  SingleClientConnManager cm = new SingleClientConnManager(schemeRegistry);

  return new DefaultHttpClient(cm);
}
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Pay Attention! In production you must use a valid SSL! Use this code for testing purposes only!&lt;/b&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/4446109573310580162/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=4446109573310580162" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/4446109573310580162?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/4446109573310580162?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/O9Wn3lAmnLU/apache-http-client-ignore-ssl-problems.html" title="Apache HTTP Client - Ignore SSL Problems" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/07/apache-http-client-ignore-ssl-problems.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0ENSXk4eSp7ImA9WhJTEE4.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-2686915464513427692</id><published>2012-06-18T18:01:00.002+03:00</published><updated>2012-06-18T18:01:38.731+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-18T18:01:38.731+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jetty" /><title>Jetty - Basic Hardening</title><content type="html">Jetty by default is shipped with two annoying features that should be turned off in production.&lt;br /&gt;
&lt;br /&gt;
The first one is contexts listing. If you access the root folder, and if there is no special context configured to be a root context, Jetty will display a list of all contexts installed. While it may be nice to see it during the development, it's unnecessary information during production.&lt;br /&gt;
&lt;br /&gt;
The class responsible for displaying this list is &lt;b&gt;org.eclipse.jetty.server.handler.DefaultHandler&lt;/b&gt; and it's configured in jetty.xml. &lt;b&gt;setShowContexts&lt;/b&gt; to &lt;b&gt;false&lt;/b&gt; to turn off the contexts listing.&lt;br /&gt;
&lt;br /&gt;
Actually you may consider to provide your own Hanlder class instead of the DefaultHanlder. The &lt;b&gt;org.eclipse.jetty.server.handler.DefaultHandler&lt;/b&gt; is also responsible to display the Jetty's default favicon. It may be configured not to server the favicon at all by setServeIcon(false), but it does not allow to customize the favicon. So if you want to do it, you'll need a custom class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The second annoying feature is a directory content listing - when you access a directory, the Jetty will generate a page with a list of files located inside. This configuration can be turned off per context: under &amp;lt;Configure class=&amp;quot;org.eclipse.jetty.webapp.WebAppContext&amp;quot;&amp;gt; put the following init parameter:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;lt;Call name=&amp;quot;setInitParameter&amp;quot;&amp;gt;
  &amp;lt;Arg&amp;gt;org.eclipse.jetty.servlet.Default.dirAllowed&amp;lt;/Arg&amp;gt;
  &amp;lt;Arg&amp;gt;false&amp;lt;/Arg&amp;gt;
&amp;lt;/Call&amp;gt;&lt;/pre&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/2686915464513427692/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=2686915464513427692" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/2686915464513427692?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/2686915464513427692?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/DYqdbTGzSf8/jetty-basic-hardening.html" title="Jetty - Basic Hardening" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>5</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/06/jetty-basic-hardening.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEFQHY7eyp7ImA9WhVVE0Q.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-3441198478380316888</id><published>2012-05-07T15:10:00.000+03:00</published><updated>2012-05-07T15:10:11.803+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-07T15:10:11.803+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="rest-design" /><title>REST Best Practices: Use HTTP Status Codes</title><content type="html">When implementing RESTful service, keep in mind that HTTP already provides you with an ability to send the status code as part of the protocol. Do NOT put the error code inside the message itself!&lt;br /&gt;
&lt;br /&gt;
HTTP defines five types of status codes:&lt;br /&gt;
* &lt;b&gt;1xx - Informational&lt;/b&gt;&lt;br /&gt;
* &lt;b&gt;2xx - Successful&lt;/b&gt;&lt;br /&gt;
* &lt;b&gt;3xx - Redirection&lt;/b&gt;&lt;br /&gt;
* &lt;b&gt;4xx - Client Errors&lt;/b&gt;&lt;br /&gt;
* &lt;b&gt;5xx - Server Errors&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;See &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"&gt;Full reference of HTTP/1.1 Status Code Definitions&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
I'm not going to describe all HTTP Status codes here, but to give some basic tips.&lt;br /&gt;
&lt;br /&gt;
1. In case of a successful request, always return the status code from the &lt;b&gt;2xx&lt;/b&gt; group. It's highly recommended to use not only the basic 200 code, but also additional codes. For example 201 means a new resource was created and the LOCATION header contains its path. 204 means that the response contains no content, so the client can optimize its code and not even try to read the content of the response (saves some redundant objects creation).&lt;br /&gt;
&lt;br /&gt;
2. In case of an error request, clearly distinguish between the client and server errors. Client errors mean that the client has sent a bad request: it may be incorrectly formatted, unauthorized, method not allowed (e.g. Server accepts GET requests, while POST has been sent), and more.&lt;br /&gt;
In case of a client error, the best is to detect it as soon as possible in the server's code, to reduce amount of logic that will run, until the request is rejected. For example it's redundant to parse request body, if it misses the security header.&lt;br /&gt;
2.1 Send clear response to client. It can be a good practice to supply text or html content inside the message telling what was wrong in the request.&lt;br /&gt;
2.2 Don't log requests with a client's error above the info level. After all, it's a client's error, not server's. The only reason to log client' errors at all, is to help clients by taking look at the server logs. Make sure not to create a misleading picture of a log full with exceptions, while there is no problem at server side at all.&lt;br /&gt;
2.3 By receiving the 4xx code, the client must understand that it did something wrong and should correct its request.&lt;br /&gt;
&lt;br /&gt;
3. In case of a server error, return &lt;b&gt;5xx&lt;/b&gt; error code. Usually the best choice will be to return simply &lt;b&gt;500&lt;/b&gt;. Do NOT put the full stacktrace into the response body. Actually put nothing in the response body. Why should a client care about the reason of server's failure. Is the database down? Is it a code problem? Whatever it is, it's not the client's business.&lt;br /&gt;
3.1 Sometimes, it can be nice to return &lt;b&gt;501 Not Implemented&lt;/b&gt; code. Usually it will happen, if you agreed on some functionality, created a prototype for it but didn't implemented it yet.&lt;br /&gt;
3.2 By receiving the 5xx code, the client must understand that something went wrong and that it should retry the same request. Does it make sense to retry immediately, in 5 minutes or in 5 days depends on the client. The server can return the *Retry-After* header and client should respect it.&lt;br /&gt;
&lt;br /&gt;
There are more status code that can and should be used with RESTful APIs. For example &lt;b&gt;304 Not Modified&lt;/b&gt; allows you to save traffic and skip the response if the resource was not modified. Many status codes are implemented by the frameworks and intermediaries, for example JAX-RS frameworks will automatically return some client errors, like 405 and 415.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Summary&lt;/h2&gt;1. In case of successful request, always return a request from 2xx group.&lt;br /&gt;
2. In case of unsuccessful request, never return 2xx with embedded status code in the message. Return appropriate 4xx or 5xx status code.&lt;br /&gt;
3. For client errors, return 4xx. Don't log these requests above the info level. These are client's problems, not server's.&lt;br /&gt;
4. For server errors, return 5xx. Log the error, but don't send it to client.&lt;br /&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/3441198478380316888/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=3441198478380316888" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/3441198478380316888?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/3441198478380316888?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/QISiNLBrcT4/rest-best-practices-use-http-status.html" title="REST Best Practices: Use HTTP Status Codes" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/05/rest-best-practices-use-http-status.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UEQHwyfyp7ImA9WhVVEEk.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-380990486638880560</id><published>2012-05-03T15:37:00.004+03:00</published><updated>2012-05-03T15:46:41.297+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-03T15:46:41.297+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tarlog-plugins" /><title>Promoting tarlog-plugins</title><content type="html">In the last four years, since I have first published the &lt;a href="http://code.google.com/p/tarlog-plugins"&gt;tarlog-plugins&lt;/a&gt; Eclipse plugin, it has 4600+ downloads.&lt;br /&gt;
I know that many readers of this blog are actually using it.&lt;br /&gt;
I won't ask you why none of you has never clicked the Donate button. After all I have never did it myself...&lt;br /&gt;
But why you won't you share it?&lt;br /&gt;
You can &lt;b&gt;star&lt;/b&gt; and/or &lt;b&gt;+1&lt;/b&gt; it on the  &lt;a href="http://code.google.com/p/tarlog-plugins"&gt;project's page&lt;/a&gt;. &lt;br /&gt;
You can &lt;b&gt;favorite&lt;/b&gt; it on the &lt;A href="http://marketplace.eclipse.org/content/tarlog-plugins"&gt;marketplace&lt;/a&gt;.&lt;br /&gt;
You can... well, the previous two are enough. But if you really want to Donate, there is a Donate button on the project's page.&lt;br /&gt;&lt;br /&gt;

P.S. And there is also an &lt;a href="http://code.google.com/p/tarlog-encoder-tool/"&gt;Encoder Tool&lt;/a&gt;. It didn't become as popular as &lt;a href="http://code.google.com/p/tarlog-plugins"&gt;tarlog-plugins&lt;/a&gt;, but it still nice for small encoding/decoding tasks.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/380990486638880560/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=380990486638880560" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/380990486638880560?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/380990486638880560?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/ZRdhwVP2xj0/promoting-tarlog-plugins.html" title="Promoting tarlog-plugins" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/05/promoting-tarlog-plugins.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0ACSHY-fip7ImA9WhVXFUg.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-2531357266805809235</id><published>2012-04-16T10:01:00.001+03:00</published><updated>2012-04-16T10:02:49.856+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-16T10:02:49.856+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="rest-design" /><title>REST Best Practices: Using HTTP Verbs</title><content type="html">The common mistake about RESTful API that they MUST be &lt;a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete"&gt;CRUD&lt;/a&gt;-like: Create maps to POST. Read maps to GET. Update maps to PUT. Delete maps to DELETE.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;In fact this is incorrect&lt;/b&gt;. They MAY be CRUD-like or MAY be something else. The rule is: each resource MUST have &lt;i&gt;a set of predefined operation.&lt;/i&gt; But not necessary CRUD. Even not necessary GET-POST-PUT-DELETE should be used. In fact did you know that HTTP/1.1 defines 8 HTTP Verbs: HEAD, GET, POST, PUT, DELETE, OPTIONS, TRACE and CONNECT? And in addition you may define your own HTTP Verbs that will behave as you wish? For example &lt;a href="http://en.wikipedia.org/wiki/WebDAV"&gt;WebDAV&lt;/a&gt; defines the following verbs in addition to the standard ones: PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK.&lt;br /&gt;
&lt;br /&gt;
So now, when you know that you may not stick to the standard HTTP verbs, I still advocate you to do so. Why? It's relatively clear what action these methods will do with the resource. It's may be less clear what action your own verb will do.&lt;br /&gt;
&lt;br /&gt;
So let's consider that 90% of RESTful APIs will use only the standard HTTP verbs. What's important to pay attention to? The most important rule is &lt;b&gt;to use the HTTP verbs correctly&lt;/b&gt;. The most common example of an incorrect use of the GET verb can be taken from HTML forms: in HTML both GET and POST can be used to submit data to a server from a form. But actually GET is &lt;b&gt;a safe method&lt;/b&gt;, it means that it SHOULD NOT have the significance of taking an action other than retrieval. &lt;br /&gt;
&lt;br /&gt;
So remember, Rule 1: HEAD and GET are safe methods.&lt;br /&gt;
&lt;br /&gt;
Now about the Idempotent Methods. Methods are idempotent if the side-effects of N &gt; 0 identical requests is the same as for a single request. The idempotent methods are GET, HEAD, PUT and DELETE.&lt;br /&gt;
Some examples what does it mean:&lt;br /&gt;
1. PUT can be used to create a resource. Yes, I know that the best practice say that it is POST, who creates resources and in a second I'll explain why. So let's say PUT creates a resource, but if a request is duplicated for some reason, the second request must not create a new resource and return exactly the same response as the first request. It's important to understand that various HTTP intermediaries know that PUT is idempotent and for example they may apply some caching, etc. So actually POST is much safer, especially for creating resources. But pay attention: POST may be safely used also for updates and even fetching the resource! Nobody said it is only for creation. &lt;br /&gt;
2. When DELETE-ing the resource, pay attention that the second DELETE request should return the same response. So if a first response returns "200 OK", the second (third, fourth, etc) DELETE requests to the same resource also should return "200 OK". Pay attention that once the resource was deleted, the GET request to this resource should return "404 NOT FOUND", but DELETE should continue returning "200 OK".&lt;br /&gt;
&lt;br /&gt;
So Rule 2 will be: use idempotent methods correctly. If you cannot ensure that you use them correctly, use other methods and POST can be a good choice.&lt;br /&gt;
&lt;br /&gt;
Now a little about the methods that you are unlikely to implement yourself. The behavior of the HEAD, TRACE, CONNECT and OPTIONS is well defined and they are usually implemented by the infrastructure (CONNECT and TRACE by the web servers, HEAD and OPTIONS by the frameworks, like Servlets or JAX-RS). If, for some reason, you decide to implement one of these methods, make sure your do it correctly. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Summary&lt;/h2&gt;1. Don't try to map CRUD to HTTP verbs. There is no need to do it.&lt;br /&gt;
2. Create new HTTP verbs, if needed.&lt;br /&gt;
3. Use existing HTTP verbs correctly, pay special attention to the safe methods (HEAD and GET) and to the idempotent methods (HEAD, GET, PUT and DELETE).&lt;br /&gt;
4. If you are now sure which HTTP verb to choose, use POST.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/2531357266805809235/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=2531357266805809235" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/2531357266805809235?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/2531357266805809235?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/nO_K0R0ahsI/rest-best-practices-using-http-verbs.html" title="REST Best Practices: Using HTTP Verbs" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/04/rest-best-practices-using-http-verbs.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYGRXo-cSp7ImA9WhVXEUk.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-6082009844277146589</id><published>2012-04-11T14:35:00.000+03:00</published><updated>2012-04-11T14:35:24.459+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-11T14:35:24.459+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="rest-design" /><title>REST Best Practices: Use JSON</title><content type="html">Something that RESTful design does not care about, is the actual representation. The concept say that the resource can be represented in one representation or more. It does not affect the resource itself. The JAX-RS solved it very beautifully with a clear separation between the Resources and Providers.&lt;br /&gt;
&lt;br /&gt;
And then happens a real life, and you need to implement a resource and represent it somehow. The native choice of the programmers who come to the RESTful world from SOAP is XML.&lt;br /&gt;
There are several reasons for it, and the main one: they were used to xml and why change something that works? Or at least worked?&lt;br /&gt;
Wrong! You don't need to stick to something you have used to use. You can use something better. And JSON is better. Why? The main reason: it's &lt;a href="http://tarlogonjava.blogspot.com/2012/04/why-rest-or-simple-vs-easy.html"&gt;more simple&lt;/a&gt; - it has no namespaces and no attributes. It's less to write, less places to make a mistake in.&lt;br /&gt;
The compatibility issues with JSON are solved better, since you don't have xsds and you cannot fail with the validations. The new fields will be silently ignored by the old version and that's all.&lt;br /&gt;
You can always create XML out of JSON in case your client prefer to get XML. But it's not so easy to create JSON out of XML (yes, I heard of Badgerfish, but if you start your design from JSON and then add XML, you don't need Badgerfish).&lt;br /&gt;
JSON is also less verbose, which saves you the traffic, but really it's not the main reason to use it. The main reason is SIMPLICITY!&lt;br /&gt;
&lt;br /&gt;
Now a little implementation note for those of you, who use Java: Create the classes that you want to be sent/received by the resources as POJOs. Keep them simple and prefer using String as a major data type. If you need something complex, like Date, do the formatting yourself and describe it in your documentation (SimpleDateFormat will help you). Once you have a set of simple POJOs, use &lt;a href="http://jackson.codehaus.org/"&gt;Jackson&lt;/a&gt; to create/parse JSON and JAXB (integrated in Java 6+) to create/parse XML. Jackson comes with JAX-RS Providers. JAXB Providers are already included by the JAX-RS implementations. Thus in one shot you'll get both JSON and XML representations for your resources.&lt;br /&gt;
&lt;br /&gt;
Back to the representations. And what about if you cannot use JSON? Of course such a thing can happen. For example you may want to upload image and there is no need to try to fit it in JSON. It's fine. Use whatever representation you want, but AVOID CUSTOM REPRESENTATIONS! If you feel that you must invent some new serialization mechanism that was not invented before, think twice. Are you really so unique? Really? Remember, you may have different clients. Each of them will have to know your serialization mechanism, will it be simple for them? Or you'll need to create a custom library. Remember: there are a lot of different languages, technologies and platforms, and you may need to support all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Summary&lt;/h2&gt;1. Design your APIs to send/receive JSON.&lt;br /&gt;
2. So if you need XML, it can be easily added without writing a single line of code (at least with JAX-RS)&lt;br /&gt;
3. Need to send/receive something binary? Fine. But make your best to use standard formats and don't reinvent the wheel (until you feel that it's a must)&lt;br /&gt;
4. Never use Java standard serialization mechanism. If you need to serialize the Java class, read again #1 and use JSON ;)</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/6082009844277146589/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=6082009844277146589" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6082009844277146589?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6082009844277146589?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/YtjyAJL8RPc/rest-best-practices-use-json.html" title="REST Best Practices: Use JSON" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/04/rest-best-practices-use-json.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYBRXszeSp7ImA9WhVXEUk.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-6312300515502046658</id><published>2012-04-11T10:56:00.001+03:00</published><updated>2012-04-11T14:35:54.581+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-11T14:35:54.581+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="web-services" /><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="rest-design" /><title>REST Best Practices: Create a good URL</title><content type="html">REST is not a standard, therefore you are free to choose how to use it. It's very hard to say, if you do something "100% right" or "100% wrong". And still there are good RESTful APIs and bad RESTful APIs. Probably the most important part of your RESTful API are the URLs. They identify your resources. Good designed URLs make your API look good.&lt;br /&gt;
&lt;br /&gt;
And here come some practices that I personally believe are best (or just good):&lt;br /&gt;
&lt;br /&gt;
1. &lt;b&gt;URL must uniquely identify the resource&lt;/b&gt; - it should be impossible using the same URL to access two different resources based on something else (e.g. header).&lt;br /&gt;
Example: suppose we design a RESTful API for a library. Let's say the url &lt;b&gt;/books/ABC&lt;/b&gt; returns &lt;a href="http://www.amazon.com/Winnie-Pooh-A-A-Milne/dp/0525477683/ref=sr_1_7?ie=UTF8&amp;tag=tarlog-20&amp;qid=1334127714&amp;sr=8-7"&gt;Winnie the Pooh&lt;/a&gt; for a registered user. &lt;b&gt;A very BAD practice would be&lt;/b&gt;, if the unregistered user will get a &lt;a href="http://www.amazon.com/The-Modern-Kama-Sutra-Ultimate/dp/1569243093/ref=sr_1_1?s=books&amp;ie=UTF8@tag=tarlog-20&amp;qid=1334127894&amp;sr=1-1"&gt;different book&lt;/a&gt; for the same url. It should not matter who is the user, the same url should lead to the same book.&lt;br /&gt;
Now, of course our application may have security implications, so for example registered user can see the book and unregistered cannot. It's ok, return 404 NOT FOUND for unregistered user. Or eliminate the book from the book search. But NEVER return a different resource.&lt;br /&gt;
&lt;br /&gt;
2. &lt;b&gt;URL should be designed for further API changes&lt;/b&gt; - this one is kinda tricky. Suppose a registered user can add some books to a favorite list. What URL will be used?&lt;br /&gt;
Option 1: "/user/{userid}/favorites/" will return favorites list of a user. Sounds reasonable. But what happens if we decide to extend this feature and allow a user have multiple list, what will return this url now?&lt;br /&gt;
Option 2: "/user/{userid}/favorites/" will return a list of the favorites lists and "/user/{userid}/favorites/{id}" will return the specific list. Sounds reasonable. But what happens if we add a feature that allows user to share lists? Actually here we got to the point I'll discuss in the next bullet, but it's quite clear here that "/user/{userid}" should not be part of the url, right?&lt;br /&gt;
Option 3: "/favorites/" will return a list of the favorites lists and "/favorites/{id}" will return the specific list. Both "/favorites/" and "/favorites/{id}" resources will return the lists based on the user's privileges: the system administrator will see all lists, the user will see his lists the ones that were shared with him.&lt;br /&gt;
&lt;br /&gt;
3. &lt;b&gt;Security is not part of the resource identification and therefore should not be a part of the URL&lt;/b&gt; - in the previous bullet I have already described why adding a userid to the url is problematic. Let's talk about it a little bit more. First, you cannot rely "userid" present in the url in order to identify the user. You need a different form of authentication (unless you use username+password authentication and you put a password also in url, it's possible, but it's really a VERY BAD practice). Furthermore, the good api should not contain the definition of an authentication method within it at all. It should be possible to change the authentication method without changing the API (for example it quite common in the last few years to move from username+password to OAuth authentication). Basically the API should expect to receive the userid always, &lt;b&gt;but not as an integral part of an API!&lt;/b&gt; With HTTP it's quite easy to put the security related stuff in the headers, and to keep the url clean.&lt;br /&gt;
&lt;br /&gt;
4. &lt;b&gt;If you must put additional metadata on URL, put it as a query parameter&lt;/b&gt; - In general all metadata you have (like security, content-type, accept content-type) should be in headers. However, sometimes it for some technical reasons it become impossible to put it in a header, so you must use URL. It's ok, but put it after the question mark in the query parameters part. Thus it becomes "optional" part and can be easily changed or removed if not needed later.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/6312300515502046658/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=6312300515502046658" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6312300515502046658?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6312300515502046658?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/yNL9X2auzkI/rest-best-practices-create-good-url.html" title="REST Best Practices: Create a good URL" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/04/rest-best-practices-create-good-url.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYCSXsyeCp7ImA9WhVXEUk.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-4900246029653752690</id><published>2012-04-10T17:28:00.002+03:00</published><updated>2012-04-11T14:36:08.590+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-11T14:36:08.590+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="rest-design" /><title>Why REST? Or "Simple vs. Easy"</title><content type="html">This is a post that I want to write for years and cannot find the correct words. I'm fully aware that hundreds of blog posts have already fully covered this subject and still I want to write my opinion in my blog. It is my blog after all, right?&lt;br /&gt;
&lt;br /&gt;
So "Why REST?"&lt;br /&gt;
But first, I'd like to say two words. One is "simple" and the second one is "easy". Although these words sound like synonyms, actually they are not. Some simple things can be not easy. And some easy things can be not simple.&lt;br /&gt;
For example: breathing is easy for most people, you don't need to think about it. But is it simple? Can you make someone breathe, if he doesn't?&lt;br /&gt;
On contrary cleaning an apartment is simple. But is it easy? Not for me at least...&lt;br /&gt;
&lt;br /&gt;
The key point here is that simple things just work. They may not be easy to achieve, but once you do it, they work. Once you clean an apartment, you have a clean apartment. For a while at least.&lt;br /&gt;
But when something is not simple, its quite problematic even to understand how it should work. Sometimes it's easy to start (breathe for example), but what happen if something goes wrong (stop breathe for example)?&lt;br /&gt;
&lt;br /&gt;
And now back to REST. &lt;br /&gt;
&lt;b&gt;REST is simple.&lt;/b&gt; Not easy, but simple. Correct RESTful APIs are very clear, very simple to understand. They may not be easy to implement, but once implemented they work. It's quite easy to troubleshoot the RESTful APIs, you can do with with a simple HTTP Proxy (e.g. Fiddler). It ensures quite a decoupling between server and client.&lt;br /&gt;
Yes it takes time to develop a RESTful API. Yes there is no much automation around and suddenly a developer needs to develop a layer that he got generated with SOAP.&lt;br /&gt;
&lt;br /&gt;
And now to SOAP (and other APIs that are generated from wslds/custom xmls/whatever): this one is easy. Usually I can get some working API very fast. There are a lot of tools that help you. BUT, it is not simple: the tools generate a lot of code that you don't know and sometimes not very readable. The integrations become very complex (did you ever install ESB?) The versioning becomes a nightmare. And the standards don't work very well (did you ever tried to integrate Java to .NET using some complex types?)&lt;br /&gt;
&lt;br /&gt;
So the bottom line is: &lt;b&gt;REST is simple, but not easy. SOAP is easy at the beginning, but not simple.&lt;/b&gt; &lt;br /&gt;
Simple is good, specially if you continue keeping it simple.&lt;br /&gt;
And forget about easy. Nobody said that a software development should be easy.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/4900246029653752690/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=4900246029653752690" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/4900246029653752690?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/4900246029653752690?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/U814wsFbxWM/why-rest-or-simple-vs-easy.html" title="Why REST? Or &quot;Simple vs. Easy&quot;" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>7</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/04/why-rest-or-simple-vs-easy.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4BQ3ozfip7ImA9WhVQFUg.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-3991310182845935906</id><published>2012-04-04T17:49:00.000+03:00</published><updated>2012-04-04T17:49:12.486+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-04T17:49:12.486+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="putty" /><title>Changing Putty Default Settings</title><content type="html">It's trivial, I should have figure it out myself, but I suffered for many years until finally I googled for it, and voila: &lt;b&gt;To save a default setting in putty, open putty, change the setting, in "Saved Sessions" choose "Default Settings" and click "Save"&lt;/b&gt;.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/3991310182845935906/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=3991310182845935906" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/3991310182845935906?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/3991310182845935906?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/0a4j5UN1wLQ/changing-putty-default-settings.html" title="Changing Putty Default Settings" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2012/04/changing-putty-default-settings.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MCQn8zfSp7ImA9WhRQF0U.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-305353193369926005</id><published>2011-12-08T17:26:00.002+02:00</published><updated>2011-12-13T16:11:03.185+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-13T16:11:03.185+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="httpclient" /><category scheme="http://www.blogger.com/atom/ns#" term="unit-testing" /><title>Integration Testing of RESTful Application</title><content type="html">In the previous posts I have described &lt;a href="http://tarlogonjava.blogspot.com/2011/12/running-integration-test-using-with.html"&gt;how to start Jetty from code in the beginning of the unit tests&lt;/a&gt; and &lt;a href="http://tarlogonjava.blogspot.com/2011/12/running-integration-tests-using-with.html"&gt;how to initialize the in-memory HSQL database once Jetty is started&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
If you have completed the steps from these posts, you should have a running application in the beginning of your tests. And now you are ready to start the actual testing of the application.&lt;br /&gt;
&lt;br /&gt;
I believe that the best way to test RESTful API is to issue actual HTTP requests and since we have a Jetty server running, it becomes possible.&lt;br /&gt;
&lt;br /&gt;
There are a lot of HTTP Clients available in Java. The examples below use Apache HTTP Client.&lt;br /&gt;
But as always first let's add a maven dependency:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;&amp;lt;dependency&amp;gt;
         &amp;lt;groupId&amp;gt;org.apache.httpcomponents&amp;lt;/groupId&amp;gt;
         &amp;lt;artifactId&amp;gt;httpclient&amp;lt;/artifactId&amp;gt;
         &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Now some convenient static methods that can be used:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.AbstractHttpMessage;
import org.apache.http.message.BasicHeader;
...
   static HttpResponse executeGet(String url) throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet get = new HttpGet(url);
        return httpclient.execute(get);
    }

    static HttpResponse executeDelete(String url) throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        HttpDelete delete = new HttpDelete(url);
        return httpclient.execute(delete);
    }

    static HttpResponse executePost(String url, byte[] body) throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);
        post.setEntity(new ByteArrayEntity(body));
        return httpclient.execute(post);
    }

    static HttpResponse executePut(String url, byte[] body) throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPut put = new HttpPut(url);
        put.setEntity(new ByteArrayEntity(body));
        return httpclient.execute(put);
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
So your test can be something like:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;@Test
    public void testGet() throws Exception {
        HttpResponse response = executeGet(url, null, null, null);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;hr /&gt;&lt;h3&gt;Recommended Reading&lt;/h3&gt;1. &lt;a href="http://www.amazon.com/Next-Generation-Java-Testing-Advanced/dp/0321503104/?tag=tarlog-20"&gt;Next Generation Java Testing: TestNG and Advanced Concepts&lt;/a&gt;&lt;br /&gt;
2. &lt;a href="http://www.amazon.com/Apache-Maven-3-Cookbook-Srirangan/dp/1849512442/?tag=tarlog-20"&gt;Apache Maven 3 Cookbook&lt;/a&gt;&lt;br /&gt;
3. &lt;a href="http://www.amazon.com/Spring-Recipes-Problem-Solution-Gary-Mak/dp/1430224991/?tag=tarlog-20"&gt;Spring Recipes: A Problem-Solution Approach&lt;/a&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/305353193369926005/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=305353193369926005" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/305353193369926005?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/305353193369926005?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/AKJQHBSHLpU/integration-testing-of-restful.html" title="Integration Testing of RESTful Application" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/12/integration-testing-of-restful.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MMR344cSp7ImA9WhRQF0U.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-8286880515378210727</id><published>2011-12-08T10:48:00.006+02:00</published><updated>2011-12-13T16:11:26.039+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-13T16:11:26.039+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="testng" /><category scheme="http://www.blogger.com/atom/ns#" term="jetty" /><category scheme="http://www.blogger.com/atom/ns#" term="spring" /><category scheme="http://www.blogger.com/atom/ns#" term="unit-testing" /><category scheme="http://www.blogger.com/atom/ns#" term="jndi" /><category scheme="http://www.blogger.com/atom/ns#" term="maven" /><title>Automated Integration Tests Using with Jetty, Maven and Other Neat Freameworks - 2</title><content type="html">In the &lt;a href="http://tarlogonjava.blogspot.com/2011/12/running-integration-test-using-with.html"&gt;previous post&lt;/a&gt;, I have started a Jetty server in the beginning of a unit test with a configured external data-source.&lt;br /&gt;
&lt;br /&gt;
Let's talk about it a little bit more. The assumption here was that the application on a regular basis uses an external data-source that is accessed via JNDI. In general it's a good practice to keep a data-source external to the application:&lt;br /&gt;
1. It's always possible to change the data-source without touching the application - let's say a bug was found in a data-source you are using. Or it should be configured differently. If a data-source embedded into an application and such a change is required, you will probably need to release patch. If the datasource is external, it would be enough just to change/reconfigure it.&lt;br /&gt;
2. In some deployments several applications can use the same datasource. Consider a Tomcat running with several wars: quite a common case, right? If a datasoure is embedded, each war has its own data-source. Usually this would be a waste of resources and duplication of a configuration.&lt;br /&gt;
3. And finally it would be possible to change a data-source for unit tests, which is exactly our use case.&lt;br /&gt;
&lt;br /&gt;
For unit tests it's really convenient to use in-memory database. There are few databases implemented in java that provides this capability. My favorite are H2 and HSQL. In this example I have used HSQL, so here comes the jetty-ds-test.xml:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;&amp;lt;Configure id=&amp;quot;Server&amp;quot; class=&amp;quot;org.eclipse.jetty.server.Server&amp;quot;&amp;gt;
    &amp;lt;New id=&amp;quot;DSTest&amp;quot; class=&amp;quot;org.eclipse.jetty.plus.jndi.Resource&amp;quot;&amp;gt;
        &amp;lt;Arg&amp;gt;&amp;lt;/Arg&amp;gt;
        &amp;lt;Arg&amp;gt;jdbc/my_ds&amp;lt;/Arg&amp;gt;
        &amp;lt;Arg&amp;gt;
            &amp;lt;New class=&amp;quot;org.hsqldb.jdbc.JDBCDataSource&amp;quot;&amp;gt;
                &amp;lt;Set name=&amp;quot;Url&amp;quot;&amp;gt;jdbc:hsqldb:mem:test;sql.syntax_ora=true&amp;lt;/Set&amp;gt;
                &amp;lt;Set name=&amp;quot;User&amp;quot;&amp;gt;sa&amp;lt;/Set&amp;gt;
                &amp;lt;Set name=&amp;quot;Password&amp;quot;&amp;gt;sa&amp;lt;/Set&amp;gt;
            &amp;lt;/New&amp;gt;
        &amp;lt;/Arg&amp;gt;
    &amp;lt;/New&amp;gt;
&amp;lt;/Configure&amp;gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
This is configuration of HSQL in memory. Notice &lt;i&gt;sql.syntax_ora=true&lt;/i&gt;, which makes HSQL to use Oracle syntax. This is useful if you are using Oracle in production, but you want to use HSQL for unit testing or development. &lt;br /&gt;
&lt;br /&gt;
So now you have at the beginning of a unit-test you have a Jetty server running with your application connected to in-memory HSQL database via JNDI. But something is still missing. This something is a database schema: to remind you, we have just started a new database in memory and it's empty. You probably already have a script that generates schema, tables, indexes and may be some data. Now you need to run it.&lt;br /&gt;
&lt;br /&gt;
Actually there are several options how do it. One of the easiest is to use Springs's SimpleJdbcTestUtils. But first we'll need to add a dependency on spring-test in our pom.xml:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;&amp;lt;dependency&amp;gt;
         &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;
         &amp;lt;artifactId&amp;gt;spring-test&amp;lt;/artifactId&amp;gt;
         &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
         &amp;lt;version&amp;gt;${spring-version}&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
And here comes the code that runs the sql script:&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
...
    @BeforeClass(dependsOnMethods = { "startJetty" })
    public void initiateDatabase() throws Exception {       
        InitialContext initialContext = new InitialContext();
        DataSource ds = (DataSource) initialContext.lookup("jdbc/my_ds");
        SimpleJdbcTemplate simpleJdbcTemplate = new SimpleJdbcTemplate(ds);
        Resource resource = new ClassPathResource(sqlScriptFileName);
        SimpleJdbcTestUtils.executeSqlScript(simpleJdbcTemplate, resource, false);
    }
&lt;/pre&gt;&lt;/div&gt;In this snippet I load the &lt;i&gt;sqlScriptFileName&lt;/i&gt; from the classpath. Usually it's convenient to place the script in &lt;i&gt;src/test/resources&lt;/i&gt;, but if you don't like it, you can always load it from a different place by using other Resource implementations (e.g. URLResource is quite convenient).&lt;br /&gt;
&lt;br /&gt;
As I have already said in this snippet I used Spring. If you are familiar with Spring, it is probably natural to you. If you don't - don't be afraid. Only the unit tests become dependent on Spring, but the actual application did not. &lt;br /&gt;
&lt;br /&gt;
And now you are ready to start the testing.&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;h3&gt;Recommended Reading&lt;/h3&gt;1. &lt;a href="http://www.amazon.com/Next-Generation-Java-Testing-Advanced/dp/0321503104/?tag=tarlog-20"&gt;Next Generation Java Testing: TestNG and Advanced Concepts&lt;/a&gt;&lt;br /&gt;
2. &lt;a href="http://www.amazon.com/Apache-Maven-3-Cookbook-Srirangan/dp/1849512442/?tag=tarlog-20"&gt;Apache Maven 3 Cookbook&lt;/a&gt;&lt;br /&gt;
3. &lt;a href="http://www.amazon.com/Spring-Recipes-Problem-Solution-Gary-Mak/dp/1430224991/?tag=tarlog-20"&gt;Spring Recipes: A Problem-Solution Approach&lt;/a&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/8286880515378210727/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=8286880515378210727" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8286880515378210727?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8286880515378210727?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/yPcleb0dBmQ/running-integration-tests-using-with.html" title="Automated Integration Tests Using with Jetty, Maven and Other Neat Freameworks - 2" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/12/running-integration-tests-using-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0IFR3k_cCp7ImA9WhRQF0U.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-8087805693324856463</id><published>2011-12-08T10:02:00.008+02:00</published><updated>2011-12-13T16:11:56.748+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-13T16:11:56.748+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="testng" /><category scheme="http://www.blogger.com/atom/ns#" term="jetty" /><category scheme="http://www.blogger.com/atom/ns#" term="unit-testing" /><category scheme="http://www.blogger.com/atom/ns#" term="junit" /><category scheme="http://www.blogger.com/atom/ns#" term="jndi" /><category scheme="http://www.blogger.com/atom/ns#" term="maven" /><title>Automated Integration Tests Using with Jetty, Maven and Other Neat Freameworks</title><content type="html">Let's say that you have a web application (aka war) that exposes RESTful API and connects to a database. Now you want to do some automation tests (and I'm not going to describe here why actually you must have automation tests that run regularly on your API).&lt;br /&gt;
&lt;br /&gt;
One of the best solutions to do it, in my opinion, is running your application on a  Jetty server that is embedded in your unit test with some in-memory database.&lt;br /&gt;
&lt;br /&gt;
But let's do it step-by-step:&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Step1: Start Jetty from a Unit Test&lt;/h3&gt;(In this guide I have used TestNG, but I see no reason why the same functionality cannot be achieved in JUnit)&lt;br /&gt;
&lt;br /&gt;
So first we need to start Jetty in our test. But before we actually do that, we need to make sure that our Maven project contains the relevant dependencies. So first we need Jetty:&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;&amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.eclipse.jetty&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;jetty-server&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${jetty-version}&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.eclipse.jetty&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;jetty-webapp&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${jetty-version}&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.eclipse.jetty&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;jetty-jndi&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${jetty-version}&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.eclipse.jetty&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;jetty-plus&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${jetty-version}&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;i&gt;The Jetty dependencies in this guide already contains the JNDI support. It will be needed later. But if JNDI support is not required, they can be omitted. &lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
And then let's start it before the tests start:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;
import org.testng.annotations.BeforeClass;

public class MyTest {

    private static final String RESOURCES_URL = "/rs";
    private static final String CONTEXT       = "/app_context";
    private static final String DS_CONFIG     = "/jetty-ds-test.xml";
    private String              baseResourceUrl;

    @BeforeClass
    public void startJetty() throws Exception {
        Server server = new Server(0);   // see notice 1
        server.setHandler(new WebAppContext("src/main/webapp", CONTEXT)); // see notice 2

        // see notice 3
        InputStream jettyConfFile = InboxTest.class.getResourceAsStream(DS_CONFIG);
        if (jettyConfFile == null) {
            throw new FileNotFoundException(DS_CONFIG);
        }
        XmlConfiguration config = new XmlConfiguration(jettyConfFile);
        config.configure(server);

        server.start();
        
        // see notice 1
        int actualPort = server.getConnectors()[0].getLocalPort();
        baseResourceUrl = "http://localhost:" + actualPort + CONTEXT + RESOURCES_URL;
    }
&lt;/pre&gt;&lt;/div&gt;Please notice that:&lt;br /&gt;
1. Jetty is started on a random port. The actual url with the actual port is saved to baseResourceUrl to be used later by tests.&lt;br /&gt;
2. Web application context points to maven's src/main/webapp.&lt;br /&gt;
3. Jetty is started with a data source configuration. (See &lt;a href="http://tarlogonjava.blogspot.com/2011/12/runnig-jetty-from-maven-using-jndi-data.html"&gt;Runnig Jetty from Maven using JNDI Data Source&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;a href="http://tarlogonjava.blogspot.com/2011/12/running-integration-tests-using-with.html"&gt;Part 2&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;h3&gt;Recommended Reading&lt;/h3&gt;1. &lt;a href="http://www.amazon.com/Next-Generation-Java-Testing-Advanced/dp/0321503104/?tag=tarlog-20"&gt;Next Generation Java Testing: TestNG and Advanced Concepts&lt;/a&gt;&lt;br /&gt;
2. &lt;a href="http://www.amazon.com/Apache-Maven-3-Cookbook-Srirangan/dp/1849512442/?tag=tarlog-20"&gt;Apache Maven 3 Cookbook&lt;/a&gt;&lt;br /&gt;
3. &lt;a href="http://www.amazon.com/Spring-Recipes-Problem-Solution-Gary-Mak/dp/1430224991/?tag=tarlog-20"&gt;Spring Recipes: A Problem-Solution Approach&lt;/a&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/8087805693324856463/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=8087805693324856463" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8087805693324856463?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8087805693324856463?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/7wUqwcffXg0/running-integration-test-using-with.html" title="Automated Integration Tests Using with Jetty, Maven and Other Neat Freameworks" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/12/running-integration-test-using-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkAAR3wyfCp7ImA9WhNbEkg.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-4169830768797871867</id><published>2011-12-05T09:50:00.005+02:00</published><updated>2013-01-15T13:52:26.294+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-15T13:52:26.294+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="jetty" /><category scheme="http://www.blogger.com/atom/ns#" term="jndi" /><category scheme="http://www.blogger.com/atom/ns#" term="maven" /><category scheme="http://www.blogger.com/atom/ns#" term="jdbc" /><category scheme="http://www.blogger.com/atom/ns#" term="oracle" /><title>Runnig Jetty from Maven with JNDI Data Source</title><content type="html">During the development of a java web component (aka war) it can be very useful to run the application as quick as possible. Jetty provides a Maven plugin that allows running it directly from maven build or explicitly using "mvn jetty:run" from the command line.&lt;br /&gt;
&lt;br /&gt;
But what happens if the war uses external database? Especially when the datasource is defined externally to the war and accessed vie the JNDI?&lt;br /&gt;
&lt;br /&gt;
Actually the solution if quite simple:&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Step 1 - Define the Data-source&lt;/h3&gt;Create the file defining the data-source:&lt;br /&gt;
(The example below is for Oracle. See &lt;a href="http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource"&gt;this page&lt;/a&gt; for examples of the other databases.&lt;br /&gt;
&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;&amp;lt;Configure id=&amp;quot;Server&amp;quot; class=&amp;quot;org.eclipse.jetty.server.Server&amp;quot;&amp;gt;
    &amp;lt;New id=&amp;quot;DSTest&amp;quot; class=&amp;quot;org.eclipse.jetty.plus.jndi.Resource&amp;quot;&amp;gt;
        &amp;lt;Arg&amp;gt;&amp;lt;/Arg&amp;gt;
        &amp;lt;Arg&amp;gt;jdbc/my_ds&amp;lt;/Arg&amp;gt;
        &amp;lt;Arg&amp;gt;
            &amp;lt;New class=&amp;quot;oracle.jdbc.pool.OracleDataSource&amp;quot;&amp;gt;
                &amp;lt;Set name=&amp;quot;DriverType&amp;quot;&amp;gt;thin&amp;lt;/Set&amp;gt;
                &amp;lt;Set name=&amp;quot;URL&amp;quot;&amp;gt;jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=something_to_replace)))
                &amp;lt;/Set&amp;gt;
                &amp;lt;Set name=&amp;quot;User&amp;quot;&amp;gt;my_user&amp;lt;/Set&amp;gt;
                &amp;lt;Set name=&amp;quot;Password&amp;quot;&amp;gt;my_password&amp;lt;/Set&amp;gt;
                &amp;lt;Set name=&amp;quot;connectionCachingEnabled&amp;quot;&amp;gt;true&amp;lt;/Set&amp;gt;
                &amp;lt;Set name=&amp;quot;connectionCacheProperties&amp;quot;&amp;gt;
                    &amp;lt;New class=&amp;quot;java.util.Properties&amp;quot;&amp;gt;
                        &amp;lt;Call name=&amp;quot;setProperty&amp;quot;&amp;gt;
                            &amp;lt;Arg&amp;gt;MinLimit&amp;lt;/Arg&amp;gt;
                            &amp;lt;Arg&amp;gt;10&amp;lt;/Arg&amp;gt;
                        &amp;lt;/Call&amp;gt;
                        &amp;lt;Call name=&amp;quot;setProperty&amp;quot;&amp;gt;
                            &amp;lt;Arg&amp;gt;InactivityTimeout&amp;lt;/Arg&amp;gt;
                            &amp;lt;Arg&amp;gt;600&amp;lt;/Arg&amp;gt;
                        &amp;lt;/Call&amp;gt;
                    &amp;lt;/New&amp;gt;
                &amp;lt;/Set&amp;gt;
            &amp;lt;/New&amp;gt;
        &amp;lt;/Arg&amp;gt;
    &amp;lt;/New&amp;gt;
&amp;lt;/Configure&amp;gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Pay attention to "jdbc/my_ds". It's the datasource JNDI name. Make sure to put there the actual JNDI name used by your application.&lt;br /&gt;
&lt;br /&gt;
Place this file under your maven project. In my opinion the best is to place this file under &lt;b&gt;src/dev/resources&lt;/b&gt;, but basically it can be anywhere.&lt;br /&gt;
&lt;br /&gt;
To continue the example, I'll name the file: &lt;b&gt;jetty-ds-dev.xml&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Step 2 - Define the Jetty Maven Plugin&lt;/h3&gt;&lt;div style="width: 550px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;&amp;lt;build&amp;gt;
...
        &amp;lt;plugins&amp;gt;
...
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.mortbay.jetty&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;jetty-maven-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${jetty-version}&amp;lt;/version&amp;gt;
                &amp;lt;configuration&amp;gt;
                    &amp;lt;jettyConfig&amp;gt;src/dev/resources/jetty-ds-dev.xml&amp;lt;/jettyConfig&amp;gt;
                &amp;lt;/configuration&amp;gt;
                &amp;lt;dependencies&amp;gt;
                    &amp;lt;dependency&amp;gt;
                        &amp;lt;groupId&amp;gt;com.oracle&amp;lt;/groupId&amp;gt;
                        &amp;lt;artifactId&amp;gt;ojdbc14&amp;lt;/artifactId&amp;gt;
                        &amp;lt;version&amp;gt;${oracle-ojdbc-version}&amp;lt;/version&amp;gt;
                    &amp;lt;/dependency&amp;gt;
                &amp;lt;/dependencies&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Pay attention to the configuration of jetty-ds-dev.xml.&lt;br /&gt;
Also pay attention that Jetty must be able to find the relevant JDBC driver in its classpath!&lt;br /&gt;
&lt;br /&gt;
And basically that's all. Run "mvn jetty:run" and your application should work with the provided database.&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;h3&gt;Recommended Reading&lt;/h3&gt;1. &lt;a href="http://www.amazon.com/Apache-Maven-3-Cookbook-Srirangan/dp/1849512442?tag=tarlog-20"&gt;Apache Maven 3 Cookbook&lt;/a&gt;&lt;br /&gt;
2. &lt;a href="http://www.amazon.com/Continuous-Delivery-Deployment-Automation-Addison-Wesley/dp/0321601912/?tag=tarlog-20"&gt;Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation&lt;/a&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/4169830768797871867/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=4169830768797871867" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/4169830768797871867?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/4169830768797871867?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/oFYE7ES0qeE/runnig-jetty-from-maven-using-jndi-data.html" title="Runnig Jetty from Maven with JNDI Data Source" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/12/runnig-jetty-from-maven-using-jndi-data.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0cHSHY9eSp7ImA9WhdUEU4.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-6199372259684889914</id><published>2011-09-27T17:47:00.003+03:00</published><updated>2011-09-27T17:50:39.861+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-27T17:50:39.861+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="cifs" /><category scheme="http://www.blogger.com/atom/ns#" term="unix" /><title>Mount external path using cifs</title><content type="html">How to mount Windows server from Unix using Cifs:&lt;br /&gt;
&lt;div style="width: 520px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;mount -t cifs //host:port/path /mnt -o user=username,pass=password
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Don't forget to replace host, port, path, mnt, username and password.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/6199372259684889914/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=6199372259684889914" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6199372259684889914?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/6199372259684889914?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/1BujkGJ-r3w/mount-external-path-using-cifs.html" title="Mount external path using cifs" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/09/mount-external-path-using-cifs.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4EQHk8fyp7ImA9WhdUEU4.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-3936077841328241899</id><published>2011-09-26T18:25:00.006+03:00</published><updated>2011-09-27T17:48:21.777+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-27T17:48:21.777+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tomcat" /><title>Simple Batch Script to Run Tomcat</title><content type="html">Sometimes it's a good idea to separate the actual Tomcat installation from the running configuration. Actually Tomcat comes with this ability built-in:&lt;br /&gt;
&lt;pre&gt;catalina.base&lt;/pre&gt;system property defines the location of the configuration, while &lt;pre&gt;catalina.home&lt;/pre&gt;system property defines the location of the Tomcat installation.&lt;br /&gt;
And here comes the basic script that runs the Tomcat:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="width: 520px;  background-color: #d7d7d7; color: #000000; font-family: courier; font-size: 12px; text-align: left; border: #668844 1px solid; overflow: auto; padding: 4px;"&gt;&lt;pre&gt;@echo off
setlocal

SET TOMCAT_BASE=c:\work\tomcats\tomcat1
SET TOMCAT_HOME=C:\tps\apache-tomcat-7.0.16
SET TOMCAT_CLASSPATH=%TOMCAT_HOME%\bin\bootstrap.jar;%TOMCAT_HOME%\bin\tomcat-juli.jar;%JAVA_HOME%\lib\tools.jar
SET JAVA_ENDORSED_DIRS=%TOMCAT_HOME%\endorsed
SET JAVA_OPTS=
SET JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.config.file="%TOMCAT_BASE%\logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
SET JAVA_OPTS=%JAVA_OPTS% -Djava.io.tmpdir="%TOMCAT_BASE%\temp"
SET JAVA_OPTS=%JAVA_OPTS% -Dcatalina.base="%TOMCAT_BASE%" -Dcatalina.home="%TOMCAT_HOME%"
SET JAVA_OPTS=%JAVA_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%"

REM SET JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=n

%JAVA_HOME%\bin\java %JAVA_OPTS% -classpath %TOMCAT_CLASSPATH% org.apache.catalina.startup.Bootstrap start

endlocal&lt;/pre&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/3936077841328241899/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=3936077841328241899" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/3936077841328241899?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/3936077841328241899?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/-1JqVCBo388/batch-script-to-run-tomcat.html" title="Simple Batch Script to Run Tomcat" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/09/batch-script-to-run-tomcat.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0AESHs4eCp7ImA9WhRQF0U.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-8422456769482207854</id><published>2011-06-24T22:28:00.003+03:00</published><updated>2011-12-13T16:15:09.530+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-13T16:15:09.530+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="kindle" /><title>Kindle with Special Offers</title><content type="html">Amazon now sells the &lt;a href="http://www.amazon.com/gp/product/B004HFS6Z0/ref=as_li_ss_tl?ie=UTF8&amp;tag=tarlog-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399373&amp;creativeASIN=B004HFS6Z0"&gt;Kindle with Special Offers&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=&amp;l=as2&amp;o=1&amp;a=B004HFS6Z0&amp;camp=217145&amp;creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; for just $114 without 3G ($164 with 3G). It's $25 less then the original price.&lt;br /&gt;
The idea that it shows sponsored screen savers, when a Kindle is not in use.&lt;br /&gt;
&lt;br /&gt;
I'll probably buy another one.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe src="http://rcm.amazon.com/e/cm?t=tarlog-20&amp;o=1&amp;p=12&amp;l=ur1&amp;category=kindlerotating&amp;f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"&gt;&lt;/iframe&gt;</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/8422456769482207854/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=8422456769482207854" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8422456769482207854?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8422456769482207854?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/tnNlbgcWhsk/kindle-with-special-offers.html" title="Kindle with Special Offers" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/06/kindle-with-special-offers.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYCRXozfip7ImA9WhZbGUk.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-8983014335357706341</id><published>2011-05-30T14:43:00.004+03:00</published><updated>2011-06-24T22:02:44.486+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-24T22:02:44.486+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>Cookiejacking</title><content type="html">&lt;a href="http://sites.google.com/site/tentacoloviola/cookiejacking"&gt;Pretty nice vulnerability in IE&lt;/a&gt; (could reproduce it easily in IE 7)&lt;br /&gt;
&lt;br /&gt;
In short: stealing cookies in IE is pretty easy.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/8983014335357706341/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=8983014335357706341" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8983014335357706341?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/8983014335357706341?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/hg3wp0sZS7I/cookiejacking.html" title="Cookiejacking" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/05/cookiejacking.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcESHwyfip7ImA9WhZSFUU.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-455843040040367771</id><published>2011-03-31T17:38:00.001+02:00</published><updated>2011-03-31T17:40:09.296+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-31T17:40:09.296+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="javac" /><category scheme="http://www.blogger.com/atom/ns#" term="jvm" /><title>Method has the same erasure bug in javac</title><content type="html">Interesting bug in javac. Consider the two cases:&lt;br /&gt;
Case 1:&lt;br /&gt;
&lt;pre&gt;class Case1 {
    public String foo(Set&amp;lt;String&amp;gt; str) {
        return null;
    }

    public String foo(Set&amp;lt;Integer&amp;gt; str) {
        return null;
    }
}
&lt;/pre&gt;&lt;br /&gt;
Case 2:&lt;br /&gt;
&lt;pre&gt;class Case2 {
    public String foo(Set&amp;lt;String&amp;gt; str) {
        return null;
    }

    public Integer foo(Set&amp;lt;Integer&amp;gt; str) {
        return null;
    }
}
&lt;/pre&gt;&lt;br /&gt;
What do you think about them? Should Class1 compile? What about Class2?&lt;br /&gt;
In my opinion both of classes should not compile, since methods have the same erasure. In this is exactly what happens in Eclipse.&lt;br /&gt;
But, in IntelliJ the Class2 compiles just fine. And Maven also compiles the Class2 without problem.&lt;br /&gt;
So how does it happen?&lt;br /&gt;
It appears that Eclipse uses it own compiler, while Maven and IntelliJ use javac.&lt;br /&gt;
So where is the bug, in Eclipse or javac?&lt;br /&gt;
&lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719"&gt;Here&lt;/a&gt; the bug that was opened in Eclipse community.&lt;br /&gt;
And &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950"&gt;here&lt;/a&gt; the bug in Sun (or should I say Oracle?)  &lt;br /&gt;
So as you can see, both of them agree with me: the bug is in javac and not in Eclipse. Actually Sun marked it as fixed at 7(b55). Does it mean Java 7?</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/455843040040367771/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=455843040040367771" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/455843040040367771?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/455843040040367771?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/9_Iu0IT5SHg/method-has-same-erasure-bug-in-javac.html" title="Method has the same erasure bug in javac" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/03/method-has-same-erasure-bug-in-javac.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C08BRnw4eCp7ImA9WhZSE0k.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-5327667895884061022</id><published>2011-03-28T21:50:00.000+02:00</published><updated>2011-03-28T21:50:57.230+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-28T21:50:57.230+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="replace-file-plugin" /><category scheme="http://www.blogger.com/atom/ns#" term="my projects" /><category scheme="http://www.blogger.com/atom/ns#" term="maven" /><title>Maven - Hotswap Plugin</title><content type="html">For many years I was missing the following feature of Maven: In a multi-module project, when I build a single module in a jar, I want it to be installed into the running environment (app server) seamlessly. During these years I created various scripts for this tasks, why none of them lasted too long: it's very hard to create a generic script, while nongeneric scripts need to be maintained and actually each module must have had its own script. Duh.&lt;br /&gt;
&lt;br /&gt;
Thinking about it, I decided that it should be a Maven plugin, which is very simple - during the install phase, search some predefined location and hotswap the found jars. That's it. So I thought that somebody probably already thought about it and asked a &lt;a href="http://stackoverflow.com/questions/5410831/find-and-replace-a-jar-file-using-maven"&gt;question at Stackoverflow&lt;/a&gt;. I received few interesting answers, but not a simple plugin I needed.&lt;br /&gt;
&lt;br /&gt;
So I decided to implement it myself. It took me few hours, since it was my first Maven plugin, so I had some "doing it for the first time" troubles. But finally I &lt;a href="http://code.google.com/p/replace-file-plugin/"&gt;did it&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
You are welcome to use it, and as always any feedback is appreciated.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/5327667895884061022/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=5327667895884061022" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/5327667895884061022?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/5327667895884061022?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/rIQzrVPAOXc/maven-hotswap-plugin.html" title="Maven - Hotswap Plugin" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/03/maven-hotswap-plugin.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUNQHo4cSp7ImA9WhZUFk8.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-7173130343880752358</id><published>2011-03-23T16:55:00.002+02:00</published><updated>2011-06-09T15:58:11.439+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-09T15:58:11.439+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="interview" /><category scheme="http://www.blogger.com/atom/ns#" term="google" /><title>How I didn't get even a job interview in Google</title><content type="html">This is going to be a very different post and it is not going to be technical. &lt;br /&gt;
&lt;a href="http://www.youtube.com/watch?v=npjOSLCR2hE"&gt;I wish to register a complaint&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
But first some history: Once upon a time I have sent my resume to Google. I did it via the Google web site, got an automatic reply and was never contacted. You may say that sending the resume via the company web site is not effective way to find a job, and you are right. But actually I was not really looking for a job, I saw a Google advertisement on the web, and decided to apply.&lt;br /&gt;
&lt;br /&gt;
About a month ago, I got the following mail:&lt;br /&gt;
&lt;blockquote&gt;Subject: Hello from Google/Google Opportunities&lt;br /&gt;
&lt;br /&gt;
Hi Michael,&lt;br /&gt;
&lt;br /&gt;
My name is ****** ***** and I am an Engineering Recruiter for Google.  Your name was passed to me confidentially by an engineer at our Mountain View headquarters.  &lt;br /&gt;
&lt;br /&gt;
I see that you have applied, via our website, to opportunities in our offices in Israel, but nothing materialized.  If you are interested in positions in those offices I can pass your information to someone who supports that office and can make sure that you are given serious consideration for those positions.  Otherwise, I support our HQ and other offices in the US and if you are interested in a major relocation I can assist.  If you are interested in opportunities with us please send me an updated copy of your resume along with your reply.&lt;br /&gt;
&lt;br /&gt;
Best regards,&lt;br /&gt;
&lt;br /&gt;
******&lt;/blockquote&gt;&lt;br /&gt;
To tell the truth my first idea was to say "Yes! I want to come to an interview to Mountain View. Please, make sure that I fly business/first and live in a nice hotel."&lt;br /&gt;
But I'm probably too shy to ask for traveling, while I'm not actually interested in a relocation. While position in Tel-Aviv could be interesting, so I replied:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;Hi ******,&lt;br /&gt;
&lt;br /&gt;
Thank you for your mail.&lt;br /&gt;
I'm really curious to know, who is the person who passed you my name.&lt;br /&gt;
I'm asking, since I don't think that I know anyone, who works at Mountain View...&lt;br /&gt;
&lt;br /&gt;
Anyway, I'm interested in the positions at Google offices in Israel. However, if it does not succeed, I won't be available for the relocation, since *********************************.&lt;br /&gt;
&lt;br /&gt;
My updated resume is attached.&lt;br /&gt;
Thank you,&lt;br /&gt;
&lt;br /&gt;
Michael.&lt;/blockquote&gt;&lt;br /&gt;
And very quickly I received the following two mails:&lt;br /&gt;
&lt;br /&gt;
Mail 1:&lt;br /&gt;
&lt;blockquote&gt;Michael,&lt;br /&gt;
&lt;br /&gt;
Thanks for your response and for sending me your resume.  We currently have Software Engineering openings in Haifa and Tel Aviv.  I can get your resume and information over to a colleague of mine that supports those locations.   I will forward your information over today.&lt;br /&gt;
&lt;br /&gt;
The person that referred you definitely works in Mountain View, but I can't disclose their name.&lt;br /&gt;
&lt;br /&gt;
Let me know if you have any questions and hopefully something with us in Israel will work out for you.&lt;br /&gt;
&lt;br /&gt;
Best,&lt;br /&gt;
&lt;br /&gt;
******&lt;/blockquote&gt;&lt;br /&gt;
Mail 2:&lt;br /&gt;
&lt;blockquote&gt;Hi Tal,&lt;br /&gt;
&lt;br /&gt;
My name is ****** and I work for the  Google recruitment team.&lt;br /&gt;
&lt;br /&gt;
I got your info  from *********** from the USA Google Staffing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I would like to ask if you would be interested in having an open conversation about current job opportunities to see if we have anything available that may interest you?&lt;br /&gt;
&lt;br /&gt;
If you would like to discuss this further then please send me a convenient time/date and your telephone number.&lt;br /&gt;
&lt;br /&gt;
I look forward to hearing from you.&lt;br /&gt;
&lt;br /&gt;
Best Regards,&lt;br /&gt;
&lt;br /&gt;
-- &lt;br /&gt;
*************** &lt;/blockquote&gt;&lt;br /&gt;
My name is not Tal, but who cares :) So I replied with a phone number and few days later I got a phone call from the Google recruiter in Tel-Aviv. She asked me few questions about what I'm doing and what I'm interested to do and then said the following (this is not the exact quote, but this is how I remember it): "We don't invite to an interview the candidates who have such a low degree and such a low GPA, and I'm calling you only since a colleague from the USA team has recommended you. If you are interested I will send you an online programming exam and if you successfully complete it, I'll invite you to an interview."&lt;br /&gt;
&lt;br /&gt;
Few points here: I own a BA degree in a Computer Science with GPA 85. I graduated in 2004 and have 7 years of an experience. I can hardly understand the recruiter who is interested in GPA of a person, who has graduated 7 years ago.&lt;br /&gt;
Anyway, she didn't reply and didn't send me any exam. I believe she forgot about me the second the phone was disconnected. May be even a second before.&lt;br /&gt;
&lt;br /&gt;
So I do understand that she called me only because she got my resume from her colleague. The thing I don't understand: Is there such a difference between the requirements for Google in US and in Israel? I mean, I don't believe that the US recruited wrote me mail knowing that my degree is not high enough.&lt;br /&gt;
&lt;br /&gt;
Anyway, I'm pretty sure that even if I was getting to an interview, &lt;a href="http://www.youtube.com/watch?v=zP0sqRMzkwo"&gt;my chances to pass it probably are not high&lt;/a&gt;, so I didn't have any real expectations. It's just a nasty feeling that I have after this a very short recruitment process that wasn't even initiated by me.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/7173130343880752358/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=7173130343880752358" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/7173130343880752358?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/7173130343880752358?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/cdsgHXJgqec/how-i-didnt-get-even-job-interview-in.html" title="How I didn't get even a job interview in Google" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/03/how-i-didnt-get-even-job-interview-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EHQ38-fCp7ImA9WhZTE0s.&quot;"><id>tag:blogger.com,1999:blog-5239535491482352731.post-1546422924597964909</id><published>2011-03-17T15:31:00.001+02:00</published><updated>2011-03-17T15:47:12.154+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-17T15:47:12.154+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql" /><category scheme="http://www.blogger.com/atom/ns#" term="hibernate" /><title>Hibernate -  How to Insert Data During the Create/Create-drop</title><content type="html">And here comes something I was missing for years.&lt;br /&gt;
It appears that it's possible to execute additional SQLs during the Hibernates create/create-drop. It's very useful for the unit testing.&lt;br /&gt;
&lt;br /&gt;
In short: Hibernate will run "import.sql" file from the classpath.&lt;br /&gt;
&lt;br /&gt;
I found it &lt;a href="http://stackoverflow.com/questions/5338914/jpa-hibernate-default-data/5339014#5339014"&gt;here&lt;/a&gt;.</content><link rel="replies" type="application/atom+xml" href="http://tarlogonjava.blogspot.com/feeds/1546422924597964909/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=5239535491482352731&amp;postID=1546422924597964909" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/1546422924597964909?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5239535491482352731/posts/default/1546422924597964909?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/tarlogonjava/~3/2V0wnV1BdJQ/hibernate-how-to-insert-data-during.html" title="Hibernate -  How to Insert Data During the Create/Create-drop" /><author><name>Michael Elman</name><uri>https://plus.google.com/111515457561635312379</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-VxQeSIaY9hk/AAAAAAAAAAI/AAAAAAAAAAA/DCAQdUCcmkg/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://tarlogonjava.blogspot.com/2011/03/hibernate-how-to-insert-data-during.html</feedburner:origLink></entry></feed>
