tag:blogger.com,1999:blog-78643202024-03-13T07:59:17.837-07:00Vj's Random PostsUnknownnoreply@blogger.comBlogger47125tag:blogger.com,1999:blog-7864320.post-25377869838411831182014-02-17T20:11:00.000-08:002014-02-17T20:11:01.620-08:00AWS deployment with Boto and Fabric, and a sample Django website<div dir="ltr" style="text-align: left;" trbidi="on">
A few months back, I was trying to deploy a simple Django website to AWS and had to write a few python scripts using the boto and fabric frameworks. I am sharing the scripts on github in case any developers are looking for some sample code. The scripts can be found at <a href="https://github.com/vijaypm/MyFirstAWS">https://github.com/vijaypm/MyFirstAWS</a><br />
<br />
Note: And, if anyone is looking for a sample Django website, you can find one at <a href="https://github.com/vijaypm/MyPhotoSite">https://github.com/vijaypm/MyPhotoSite</a><br />
<br /></div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-7864320.post-28585344742642060802014-02-17T20:05:00.003-08:002014-02-17T20:06:38.375-08:00Web app development with Jersey and JSON<div dir="ltr" style="text-align: left;" trbidi="on">
Over the last few days, I have been trying to create a simple Jersey based web app for my Google glass. I have been frustrated to find that there is no single tutorial or book or document that explains how to create a simple Jersey app that accepts JSON, is unit tested through the Jersey test framework and can be deployed as a war in a traditional servlet container.<br />
After several hours of searching through stackoverflow and reading very confusing jersey documentation, I finally managed to create a working app. I have now uploaded the source code to github with the hope that I might be able to save a few hours for my fellow developers who want to experiment with Jersey. Note: I have done a lot of traditional servlet development but this is my first jersey app.<br />
<br />
You can find the app at <a href="https://github.com/vijaypm/samplejerseyjson">https://github.com/vijaypm/samplejerseyjson</a> <br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-6179833325402063872012-06-06T09:10:00.001-07:002012-06-06T09:10:21.650-07:00Ensure Password Rules for JPasswordField input<div dir="ltr" style="text-align: left;" trbidi="on">
Java's standard regular expression classes like Pattern and Matcher only support CharSequence which includes String and StringBuffer but not char[]. And, for security reasons, it is important to never convert a password into a String. It is advisable to keep the password in a char array. So, how do you enforce password rules on a char array. The below code is a sample of how you will need to implement password rules:
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> public static boolean isPasswordPatternValid(char[] password) {
if (password == null || password.length < 8) {
return false;
}
boolean hasDigit = false;
boolean hasLower = false;
boolean hasUpper = false;
boolean hasSpecial = false;
char[] specialChars = new char[] {'~','@','#','$','%','^','&','*','(',')'};
for (int i = 0; i < password.length; i++) {
if (!hasDigit && Character.isDigit(password[i])) {
hasDigit = true;
continue;
}
if (!hasLower && Character.isLowerCase(password[i])) {
hasLower = true;
continue;
}
if (!hasUpper && Character.isUpperCase(password[i])) {
hasUpper = true;
continue;
}
if (!hasSpecial) {
for (int j = 0; j < specialChars.length; j++) {
if (password[i] == specialChars[j]) {
hasSpecial = true;
break;
}
}
}
}
return true;
}
</code></pre>
<br /></div>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-7864320.post-8513285572009635372012-06-05T09:22:00.003-07:002012-06-05T09:22:32.081-07:00JDialog with Multiple Input Fields<div dir="ltr" style="text-align: left;" trbidi="on">
The below code displays password fields in a dialog window. The window is disposed when any of the buttons are clicked. If you want to prevent the dialog from closing if the entries are invalid, you will need to create custom dialog windows. An example of custom dialog is given below:
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
//STANDARD JDialog code
final JPasswordField oldPassword = new JPasswordField();
final JPasswordField newPassword = new JPasswordField();
final JPasswordField confirmNewPassword = new JPasswordField();
final JComponent[] inputs = new JComponent[] {
new JLabel("Old Password:"),
oldPassword,
new JLabel("New Password:"),
newPassword,
new JLabel("Confirm New Password:"),
confirmNewPassword
};
int result = JOptionPane.showConfirmDialog(null, inputs, "Change Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
System.out.println("Old Password:" + new String(oldPassword.getPassword()));
System.out.println("New Password:" + new String(newPassword.getPassword()));
System.out.println("Confirm New Password:" + new String(confirmNewPassword.getPassword()));
if(result == JOptionPane.OK_OPTION){
if (!KeyManager.isPasswordPatternValid(oldPassword.getPassword())
|| !KeyManager.isPasswordPatternValid(newPassword.getPassword())) {
JOptionPane.showMessageDialog (null, KeyManager.passwordPatternRules, "Invalid Password", JOptionPane.ERROR_MESSAGE);
return;
}
if (!KeyManager.isPasswordReentryMatch(newPassword.getPassword(), confirmNewPassword.getPassword())) {
JOptionPane.showMessageDialog (null, "Passwords do not match!", "Password Mismatch", JOptionPane.ERROR_MESSAGE);
return;
}
KeyManager.changePassword(oldPassword.getPassword(), newPassword.getPassword());
return;
} else {
return;
}
</code></pre>
<br />
The following code is custom code that prevents the password entry dialog window from being closed if there are are errors.
<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
//CUSTOM JDialog code
final JPasswordField oldPassword = new JPasswordField();
final JPasswordField newPassword = new JPasswordField();
final JPasswordField confirmNewPassword = new JPasswordField();
final JComponent[] inputs = new JComponent[] {
new JLabel("Old Password:"),
oldPassword,
new JLabel("New Password:"),
newPassword,
new JLabel("Confirm New Password:"),
confirmNewPassword
};
final JOptionPane jop = new JOptionPane(inputs,
JOptionPane.WARNING_MESSAGE,
JOptionPane.OK_CANCEL_OPTION);
final JDialog dialog = new JDialog(parentFrame, "Re-Enter Password:");
dialog.setContentPane(jop);
dialog.setVisible(true);
jop.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
Object value = jop.getValue();
if (value == JOptionPane.UNINITIALIZED_VALUE) {
return;
}
jop.setValue(JOptionPane.UNINITIALIZED_VALUE);
if (((Integer)value).intValue() == JOptionPane.CANCEL_OPTION ) {
dialog.setVisible(false);
return;
}
if (dialog.isVisible()
&& (e.getSource() == jop)
&& (prop.equals(JOptionPane.VALUE_PROPERTY))) {
if (!KeyManager.isPasswordPatternValid(oldPassword.getPassword())
|| !KeyManager.isPasswordPatternValid(newPassword.getPassword())) {
JOptionPane.showMessageDialog (null, KeyManager.passwordPatternRules, "Invalid Password", JOptionPane.ERROR_MESSAGE);
return;
}
if (!KeyManager.isPasswordReentryMatch(newPassword.getPassword(), confirmNewPassword.getPassword())) {
JOptionPane.showMessageDialog (null, "Passwords do not match!", "Password Mismatch", JOptionPane.ERROR_MESSAGE);
return;
}
KeyManager.changePassword(oldPassword.getPassword(), newPassword.getPassword());
dialog.setVisible(false);
return;
}
}
});
</code></pre>
<code style="color: black; word-wrap: normal;">
</code></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-60218242680618168592012-05-30T08:36:00.001-07:002012-05-30T08:59:38.485-07:00Convert char[] array to byte[] array in Java<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
I have spent a few hours trying to convert a char[] returned by a JPasswordField into a byte[] that I can encrypt in Java. Here is the conversion code that I finally came up with :<br />
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> public void testArrayConversionJapanese() {
String hello = new String("こんにちは世界");
char[] charArray = hello.toCharArray();
byte[] byteArray = new byte[charArray.length*2];
for (int i=0; i < charArray.length; i++) {
byteArray[i*2] = (byte) ((charArray[i] & 0xFF00) >> 8);
byteArray[i*2+1] = (byte) (charArray[i] & 0x00FF);
}
char[] chars2 = new char[byteArray.length/2];
for(int i=0; i < chars2.length; i++) {
//bytes must be & with 0x00FF to convert negative values into unsigned positive values
chars2[i] = (char) (((byteArray[i*2]&0x00FF) << 8) + (byteArray[i*2+1]&0x00FF));
}
String hello2 = new String(chars2);
assertEquals(hello, hello2);
}
</code></pre>
As you can see above, I have used basic array and shift operations for the conversion. This is much more efficient than using java.lang.Character, String and Byte classes to do the conversions.</div>
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7864320.post-69797841164879267902012-05-29T19:49:00.000-07:002012-05-30T08:49:53.188-07:00NoClassDefFoundError in Eclipse after upgrade<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: left;">
Sometimes when you open a project for the first time after upgrading your Eclipse IDE, you may find that the project does not run. All the classes and package structure look fine in the Package Explorer but the application fails to run with a NoClassDefFoundError. Even your JUnits fail with the NoClassDefFoundError and the stacktrace usually looks like this:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> Exception in thread "main" java.lang.NoClassDefFoundError: com/vj/test/javatext/TestByteCharConversion
Caused by: java.lang.ClassNotFoundException: com.vj.test.javatext.TestByteCharConversion
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: com.vj.test.javatext.TestByteCharConversion. Program will exit.
</code></pre>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
The root cause of this could be builders that your project depends upon but are no longer available in the upgraded version of Eclipse. For example, you may have AspectJ code that depends on the AJDT plugin being available in Eclipse. You can confirm this by opening Project -> Properties -> Builders. If you find any "Missing builder" entries, download the appropriate plugins from the Eclipse Marketplace. This should solve your problems. Here is a sample screenshot.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxoxzIJD6WUFtOpINPior2aP2hiVyoWNO4J0jkYBpEw74GnhYmg-ubrcoUFVgYYeNMCYiEYp1mUc47cvDQ01s8w08uiJh-vx77hsPwK-D-6XLvi870Y0uzD1HADAfNwAYkIhLUPw/s1600/MissingBuilder.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxoxzIJD6WUFtOpINPior2aP2hiVyoWNO4J0jkYBpEw74GnhYmg-ubrcoUFVgYYeNMCYiEYp1mUc47cvDQ01s8w08uiJh-vx77hsPwK-D-6XLvi870Y0uzD1HADAfNwAYkIhLUPw/s320/MissingBuilder.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Hope this post helped you. </div>
<br /></div>
<meta content='DESCRIPTION HERE' name='eclipse upgrade issue'/>
<meta content='KEYWORDS HERE' name='noclassdeffounderror eclipse upgrade'/>
<meta content='AUTHOR NAME HERE' name='vijay mariadassou'/>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-80615784842852803852012-03-18T13:46:00.001-07:002012-03-18T13:46:39.446-07:00A shout out to Barnes & Noble<div><p>B&N, you should allow your customers to buy online and pick up in your stores. I love the experience in your stores and, the prices and choices on your site. Putting the two together you can reduce your shipping costs, generate more traffic for your stores, improve my experience and help you beat the crap out of Amazon.<br>
I am sure you know this already but I am writing this post as one more voice pushing you forward.</p>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-17901742193844551862011-11-25T18:17:00.001-08:002011-11-25T18:17:40.789-08:00Shame on you Coke!Coke's arctic campaign is a sham. They make you buy multi-pack bottles or cans and make note of some stupid code printed on an obscure part of the packaging to match just 1$. Shame on you coke!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-84829082437306472212011-06-07T23:11:00.001-07:002011-06-07T23:11:24.541-07:00Why buying a BMW is irresponsible and selfish?<div>I love the beauty and power of the BMW. But, I have never been able to justify owning one myself and here's why:
<ol>
<li>It is a gas guzzler that is harmful to the climate and to all the societies that are exploited for energy.</li>
<li>It is expensive. Buying one diverts valuable funds from the hundreds and thousands of charitable causes around the globe.</li>
<li>Its powerful engine is wasted driving within the paltry speed limits of most roads and highways. A fuel efficient, inexpensive Honda or Toyota is good enough.</li>
</ol>
Oh, well. Selfishness is core to human nature. I'll just continue cursing every time I see a BMW owner.</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7864320.post-55329155552656119892011-04-07T12:05:00.001-07:002011-04-07T12:11:02.353-07:00Mera neta chor hai - I support Anna Hazare<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRwCxBftWFZBskDAyUEKHVfakErtAf1YXC8u6t6dukg8qg7ovfmXKlOTmSkI_ZUB1kOwm-xOsN4R3LOSvESZb7kpaVerZd7XWmyAcITkmLgp1B-18LYR1ItVHviU4HgKkNK_91bQ/s1600/meranetachorhai.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"><img border="0" height="82" width="82" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRwCxBftWFZBskDAyUEKHVfakErtAf1YXC8u6t6dukg8qg7ovfmXKlOTmSkI_ZUB1kOwm-xOsN4R3LOSvESZb7kpaVerZd7XWmyAcITkmLgp1B-18LYR1ItVHviU4HgKkNK_91bQ/s400/meranetachorhai.png" /></a></div><br />
Mera neta chor hai - I support Anna HazareUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-68688437543261606142011-01-09T11:27:00.000-08:002011-01-09T11:36:26.675-08:00Yahoo's amazing audio player<script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>Yahoo has an amazing <a href="http://mediaplayer.yahoo.com/">audio player</a> that can be embedded into your website to support the playback of audio files linked on your site. This is an amazingly simple way to embed MP3 songs on your site without having to deal with any of your own javascript mess.<br />
<br />
Click on the link or play button below to see the player in action:<br />
<a href="http://download.tamilwire.com/songs/__K_O_By_Movies/Keladi%20Kanmani/Mannil%20Indha...%20-%20TamilWire.com.mp3">SPB - Keladi Kanmani - Mannil Indha (Courtesy: TamilWire.com) </a><br />
<br />
Thank you, Yahoo!<br />
<br />
CiaoUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-1799462709569606332011-01-07T09:02:00.000-08:002011-01-07T09:02:36.597-08:00Finger drawing on my Droid XThanks to an awesome app called <a href="http://market.android.com/details?id=com.dansl.Drawer">Draw(er) on Android</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNRLE8UIGjYV012xCIavZoglNB9gn2n6mfPitotgfuYhyCPa0WEnWnti9dHEepGluydXlYYdEwz62qp3LnzSbyTG3UgHDDJ7LXPcEal94jHSNEp9i_LYSNUik89-R1k_jqtSf6gg/s1600/1294302906999.jpg" imageanchor="1" style=""><img border="0" height="225" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNRLE8UIGjYV012xCIavZoglNB9gn2n6mfPitotgfuYhyCPa0WEnWnti9dHEepGluydXlYYdEwz62qp3LnzSbyTG3UgHDDJ7LXPcEal94jHSNEp9i_LYSNUik89-R1k_jqtSf6gg/s400/1294302906999.jpg" /></a></div>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-7864320.post-70544086902544277402011-01-05T09:07:00.001-08:002011-01-05T09:11:44.723-08:00Inside the mind of Julian AssangeGo to the source at <a href="http://www.visualnews.com/2010/12/07/inside-the-mind-of-wikileaks-founder-julian-assange-infographic/">Visual News</a><br />
<br />
<a href="http://www.visualnews.com/2010/12/07/inside-the-mind-of-wikileaks-founder-julian-assange-infographic/"><img src="http://visualnews.columnfivemedia.netdna-cdn.com/wp-content/uploads/2010/12/VN-ASSANGE-BRAIN.png" alt="Inside the Mind of Wikileaks Founder Julian Assange (Infographic)" title="Inside the Mind of Wikileaks Founder Julian Assange (Infographic)" /></a><br />
Infographic by: <a href="http://www.thevisualnews.com/">TheVisualNews</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-3276796887000382412011-01-02T21:09:00.000-08:002011-01-02T21:09:38.292-08:00Eclipse Maven site issuesFollowing up on my previous posts about Maven, Eclipse on Tomcat, I ran into a a very interesting problem that I wanted to share with you so that you don't waste time like I did. <br />
<br />
<hr><h3>Running <i>'mvn site'</i> from Eclipse does not generate reports</h3><br />
<h4>Problem</h4>As I was getting ready to release my Maven project in Eclipse, I wanted to generate a project site with FAQs, javadoc and junit reports. So, I decided to use the standard 'mvn site' command. <br />
<br />
I edited my pom following the instructions at <a href="http://maven.apache.org/plugins/maven-site-plugin/">http://maven.apache.org/plugins/maven-site-plugin/</a> and <a href="http://maven.apache.org/plugins/maven-javadoc-plugin/examples/selective-javadocs-report.html">http://maven.apache.org/plugins/maven-javadoc-plugin/examples/selective-javadocs-report.html</a>. <br />
<br />
With my pom edited, I ran the mvn site command from Eclipse. The site was generated but it had no reports and no javadoc. I had no idea why this was and searched all over the Maven forums and Google but, had no luck.<br />
<br />
I then decided to fall back to the reliable command-line and presto, the site generated with all the reports and javadoc. I came to the sudden realization that Maven may not have been configured properly in Eclipse. <br />
<br />
<h4>Root Cause</h4>I found that my Eclipse Maven installation was using the default embedded version of Maven which was at 3.0. And, the changes I had made in my pom were intended for Maven 2.2. Due to incompatibility issues, my Eclipse Maven was ignoring the <i>reporting</i> tags in my pom.<br />
<br />
<h4>Solution</h4>The solution was straighforward. I just had to go to Workbench -> Preferences -> Maven -> Installations and add the path to Maven 2.2 installed on my filesystem.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimVytGMCxM9qkdqLNg2xe4tY8pu0HvkbnNCiTuC8QQWGiq_aXJyoZ3OlpQXP2MheKvUNkTWwjvZle8wiDl8rlIG4NxOx6ZvvGdOu43BC5f0oU8WP-6PbGadbD0tdUuTpZCPFd8XQ/s1600/mvn_installation.png" imageanchor="1" style=""><img border="0" height="215" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimVytGMCxM9qkdqLNg2xe4tY8pu0HvkbnNCiTuC8QQWGiq_aXJyoZ3OlpQXP2MheKvUNkTWwjvZle8wiDl8rlIG4NxOx6ZvvGdOu43BC5f0oU8WP-6PbGadbD0tdUuTpZCPFd8XQ/s400/mvn_installation.png" /></a></div><br />
<hr>I hope the above information is helpful to you and saves you some time.<br />
<br />
Ciao!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-92164566441474025422010-12-31T18:12:00.000-08:002011-01-01T09:10:13.453-08:00Maven, Eclipse and TomcatFollowing up on my previous post, I went through another frustrating experience trying to develop a webapp that was built using Maven and deployed into Tomcat through Eclipse.<br />
<br />
The challenges I ran into were as follows:<br />
<br />
<ol><li> Tomcat 6.0 supports only Java 1.5 and Servlet 2.5. But, the Java and Dynmaic Web Module facets in Eclipse pick Java 1.6 and Servlet 3.0 by default.<br />
</li>
<li> The Dynamic Web Module facet in Eclipse looks in a folder called WebContent for the web content whereas Maven maintains the web content in src/main/webapp.<br />
</li>
<li> The Dynamic Web Module facet once applied to a project cannot be modified i.e, you cannot change from 3.0 to 2.5 after you discover that your Tomcat will not support Servlet 3.0.<br />
</li>
<li> Eclipse does not provide a way to remove the Dynamic Web Module facet from your project.<br />
</li>
</ol>Before I go into the steps for integrating a Maven webapp with Eclipse and Tomcat, let me first address the challenges of modifying or removing incorrect web facets. <br />
<br />
<br />
<br />
<h3>How do I modify the Dynamic Web Module facet for my project ?</h3>In Eclipse, if you try to remove the Dynamic Web Module facet, you will get an error saying "Dynamic Web Module 2.5 cannot be uninstalled". The only way to modify the facet is to first remove it and then reapply it. To learn how to remove it, read the next section. <br />
<br />
<br />
<h3>How do I remove the Dynamic Web Module facet from my project ?</h3>Step 1. Right-click on your project in Eclipse Package Explorer and select Close Project. <br />
Step 2. Open a command-line terminal and go to your project folder. <br />
Step 3. Open the .project file in a text editor and remove the following lines: <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgdJOogiDW39i6uevrEDCUyEiFP5Vf5AUOV66cqwIcD0WQsR3bwexcLJ1B9ymaWNKlh5Y6l7vrfD7XcLNtTvpEkOOTaxo5oXzP5u-w-vSzBu444g-LgMFVRFQCJc4mVUGdx6UYfg/s1600/dot_project_web_facet.png" imageanchor="1"><img border="0" height="203" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgdJOogiDW39i6uevrEDCUyEiFP5Vf5AUOV66cqwIcD0WQsR3bwexcLJ1B9ymaWNKlh5Y6l7vrfD7XcLNtTvpEkOOTaxo5oXzP5u-w-vSzBu444g-LgMFVRFQCJc4mVUGdx6UYfg/s320/dot_project_web_facet.png" width="320" /></a></div>Step 4. Open the .classpath file and remove the following lines: <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY9vrZVYDZ6M0UBWTz55-j9JUsSqjQTrROV7SABAYEYGrLJOFOHeiajQqzoe5fRMo4mAQSxKbgDfiFH8beXWFDEg0x5HWlexnRqNd4PPCPWrqX91DQ6Lwqtvu9cN2Qd1KxQVDAdQ/s1600/dot_classpath_web_facet.png" imageanchor="1"><img border="0" height="66" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY9vrZVYDZ6M0UBWTz55-j9JUsSqjQTrROV7SABAYEYGrLJOFOHeiajQqzoe5fRMo4mAQSxKbgDfiFH8beXWFDEg0x5HWlexnRqNd4PPCPWrqX91DQ6Lwqtvu9cN2Qd1KxQVDAdQ/s320/dot_classpath_web_facet.png" width="320" /></a></div>Step 5. Go into the .settings folder and delete the following files: <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRi4PLZkIMvq6rv0Unh2XwV_lN5a4SfxOiK3CbJdHWYhWUZgW4PdM_tOuXj6t2x3MuDuvdWzVRitMiPqHtWL5vgYw704afGZZu1AP9My_lOtkvuQzmrNpp9cbh69HRsWKCXNrtnQ/s1600/dot_settings_web_facet.png" imageanchor="1"><img border="0" height="82" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRi4PLZkIMvq6rv0Unh2XwV_lN5a4SfxOiK3CbJdHWYhWUZgW4PdM_tOuXj6t2x3MuDuvdWzVRitMiPqHtWL5vgYw704afGZZu1AP9My_lOtkvuQzmrNpp9cbh69HRsWKCXNrtnQ/s320/dot_settings_web_facet.png" width="320" /></a></div>Step 6. Go back into Eclipse, right-click on your project and select Open Project Your project should now have all facets removed and should appear like a regular project. <br />
<br />
<h3>What are the steps to integrate a Maven web archetype into Eclipse Tomcat ?</h3>Step 1. I assume you already have a Maven web app in your Eclipse workspace. If not, here are some quick steps. <br />
<br />
(i) In a command-line terminal, enter the following command: <br />
<blockquote>mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp </blockquote><br />
You can find out more about this command at <a href="http://maven.apache.org/guides/mini/guide-webapp.html">Maven - Guide to Webapps</a> <br />
<br />
(ii) In Eclipse, select File -> Import ... -> Existing Maven Projects. You will be prompted to select the directory the project located on your filesystem. This should complete the Maven webapp creation in Eclipse. <br />
<br />
Step 2. Select your project in Eclipse Package Explorer and select Properties. <br />
<br />
Step 3. Select Project Facets in the Properties window and click on the "Convert to faceted form ..." link <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdNV41xHDt-fkpwbonYTkx3Zm9B-Dv_7W6ajvPV7QDyFspxxXdbvSOoWX1XkBcP1k0CEuI5fLUggX-AfYZOeGNDy0wW53rysVKhf4KSFq6WDx3Rj7-ExWFl1BziSq6AyA4Eacnaw/s1600/web_facet_1.png" imageanchor="1"><img border="0" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdNV41xHDt-fkpwbonYTkx3Zm9B-Dv_7W6ajvPV7QDyFspxxXdbvSOoWX1XkBcP1k0CEuI5fLUggX-AfYZOeGNDy0wW53rysVKhf4KSFq6WDx3Rj7-ExWFl1BziSq6AyA4Eacnaw/s320/web_facet_1.png" width="320" /></a></div><br />
Step 4. Select Java 1.5 from the list of facets. <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG-QpzP9pXSLEY65nnX34PitHhZCAt94nRK0DoTXOoCGOZun8JDkTWlAGIkZCvXNFccq2dSwWcOuOF478GiYI0ippuFTeRHmhT5O60Hdj5z6kWDdFnDy1eUYZVgHI7celI7D-Mvw/s1600/web_facet_2" imageanchor="1"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG-QpzP9pXSLEY65nnX34PitHhZCAt94nRK0DoTXOoCGOZun8JDkTWlAGIkZCvXNFccq2dSwWcOuOF478GiYI0ippuFTeRHmhT5O60Hdj5z6kWDdFnDy1eUYZVgHI7celI7D-Mvw/s320/web_facet_2" width="320" /></a></div><br />
Step 5. Select Dynamic Web Module 2.5 from the list of facets. <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSX1pctcQ2ozyw0EJQNnWrGX0IulhRlNxjkSWHDtQd5xnvhWG3rqyfirL1CCa7kixt2XDjQnFLu1r6GAq6G07HfO4-NFFi_mQMJ2lAe3_gKRCqVjg4VgYrDPlOeGlSy5iYKBs6Ng/s1600/web_facet_3" imageanchor="1"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSX1pctcQ2ozyw0EJQNnWrGX0IulhRlNxjkSWHDtQd5xnvhWG3rqyfirL1CCa7kixt2XDjQnFLu1r6GAq6G07HfO4-NFFi_mQMJ2lAe3_gKRCqVjg4VgYrDPlOeGlSy5iYKBs6Ng/s320/web_facet_3" width="320" /></a></div><br />
Step 6. Click on "Further configuration available..." link below the list of facets. <br />
<br />
Step 7. In the Modify Faceted Project window that opens, change the value in the "Content directory" field to reflect maven's target folder. <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwhbUV7CQ25WWDYIgdyEzkfdrDRloif2cGFAxi8vQPNukSUGaxmavZWxklAIMH-91y9sjEIDzeTs5ElAKiQ3e-6FF5LMBEUyUloR7BP3rK8ir7ru0pZLHp8ND0DFIX46iYbSjy_A/s1600/web_facet_4.png" imageanchor="1"><img border="0" height="245" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwhbUV7CQ25WWDYIgdyEzkfdrDRloif2cGFAxi8vQPNukSUGaxmavZWxklAIMH-91y9sjEIDzeTs5ElAKiQ3e-6FF5LMBEUyUloR7BP3rK8ir7ru0pZLHp8ND0DFIX46iYbSjy_A/s320/web_facet_4.png" width="320" /></a></div><br />
Step 8. Click OK and OK. <br />
<br />
Your project is now both a Maven project as well as an Eclipse Dynamic Web Module project. <br />
<br />
If you want to deploy to the Tomcat instance that you setup in Eclipse, just right-click your project in Package Explorer and select Run -> Run on Server. You will be prompted to select your Tomcat instance and the application will be deployed. <br />
<br />
If you need instructions on how to setup a Tomcat instance in Eclipse, refer my earlier post at <a href="http://vijaypm.blogspot.com/2010/12/tomcat-from-within-eclipse.html">Tomcat from within Eclipse</a>. <br />
<br />
If you want to deploy to an external Tomcat instance running outside of Eclipse, you can follow the instructions at <a href="http://wiki.base22.com/display/btg/How+to+create+a+Maven+web+app+and+deploy+to+Tomcat+-+fast">How to create a Maven web app and deploy to Tomcat - fast</a> <br />
<br />
If you have any other questions, just drop a comment and I will get back to you.<br />
<br />
Ciao!Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-7864320.post-73789275902900665382010-12-31T13:17:00.000-08:002010-12-31T13:18:24.336-08:00Tomcat from within EclipseI just went through a very frustrating time trying to get a Tomcat instance configurable and usable from within Eclipse. As you will realize after going through this article, the Eclipse integration for Tomcat is a very confusing integration. The problem is that Eclipse has no single wizard or form to configure a Tomcat instance. <br />
<br />
After an hour, I got my Eclipse and Tomcat integrated the way I wanted them to be. I am sharing some of the initial steps that I had to go through so that you can get a head-start with your Eclipse Tomcat integration.<br />
<br />
Step 1. Download the binary distribution of tomcat from <a href="http://tomcat.apache.org/download-60.cgi#6.0.29">Tomcat 6.0.29</a><br />
<br />
Step 2. Just unpack your download and you should be ready to go with Tomcat from the command-line.<br />
<br />
Step 3. Launch Eclipse. ( I assume you are already using Eclipse. )<br />
<br />
Step 4. Add the Tomcat server runtime environment to your Eclipse workbench. <br />
<br />
(i) Click on Window -> Preferences <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwzaGjl3WWMrDmTQMRk962nOlJ7iZ6uSGwodf9gnSEAVTRAjB63cng9B5QYXNRZ7lkAo18mV9Hf_W8TtoWW9r8lOOLlvgpvzy2_TpD2xg9erAmYRqxAzoVVS1HrliUoQ5y8kGbSw/s1600/workbench_prefs.png" imageanchor="1" style=""><img border="0" height="284" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwzaGjl3WWMrDmTQMRk962nOlJ7iZ6uSGwodf9gnSEAVTRAjB63cng9B5QYXNRZ7lkAo18mV9Hf_W8TtoWW9r8lOOLlvgpvzy2_TpD2xg9erAmYRqxAzoVVS1HrliUoQ5y8kGbSw/s320/workbench_prefs.png" /></a></div><br />
(ii) Select Server -> Runtime Environments from the preferences pane. <br />
<br />
(iii) Click Add and select Apache Tomcat v6.0 from the list. <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN_z_BuXH74zC96rFzLoNxXjURqKNVYD0Z9K4QEf1TxBDQZca5b_wU5y-SNxEzBSyyaQDmj8bGDDVj6eDpribY4XqRrz1sM4auFL9JdRZHwNf0q1D1BzGY-v0sW4PgGHVcPvxtiw/s1600/server_runtimes_1.png" imageanchor="1" style=""><img border="0" height="267" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN_z_BuXH74zC96rFzLoNxXjURqKNVYD0Z9K4QEf1TxBDQZca5b_wU5y-SNxEzBSyyaQDmj8bGDDVj6eDpribY4XqRrz1sM4auFL9JdRZHwNf0q1D1BzGY-v0sW4PgGHVcPvxtiw/s400/server_runtimes_1.png" /></a></div><br />
(iv) Click Next. <br />
<br />
(v) Set the Tomcat installation path to the location in Step 2 above. <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFciRCEN-pY_w74iVXSBFEIBktouSQ8lcU6u7JxshmIqrJxVXM8WsEeJq04Zy-fFSczCPVwGJgkEc1n4IjWxMlpw9zK1Z3K6pC1J0tzxYkEppvfZvmog4hF2_fii3pCUlY0D5_zg/s1600/server_runtimes_2.png" imageanchor="1" style=""><img border="0" height="267" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFciRCEN-pY_w74iVXSBFEIBktouSQ8lcU6u7JxshmIqrJxVXM8WsEeJq04Zy-fFSczCPVwGJgkEc1n4IjWxMlpw9zK1Z3K6pC1J0tzxYkEppvfZvmog4hF2_fii3pCUlY0D5_zg/s400/server_runtimes_2.png" /></a></div><br />
(vi) Click Finish.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Aoj5I8dhe_W045FuX3lEoDAJgRmvtAr_oeGmoR4Ucnwmu5K6REDZV5oxXO7MuWldpBt9Q7TCzRo5jHpxilBaQNZZ1WgID7iWkbC-wdPq5fANqUmGCBk4pUxN4-kS-dYhqmOLAg/s1600/server_runtimes_3.png" imageanchor="1" style=""><img border="0" height="267" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Aoj5I8dhe_W045FuX3lEoDAJgRmvtAr_oeGmoR4Ucnwmu5K6REDZV5oxXO7MuWldpBt9Q7TCzRo5jHpxilBaQNZZ1WgID7iWkbC-wdPq5fANqUmGCBk4pUxN4-kS-dYhqmOLAg/s400/server_runtimes_3.png" /></a></div><br />
Step 5. Create server instance.<br />
<br />
(i) Click on Window -> Show View -> Other<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYTylKxMA0uO7ecCxu5p6zSDLuN4u1rUpeYCMp-JI_qIQDkGES7M2XXUqenAJsl0n3vq31c2gOyVjUtpcXl6I3AuIu1MSN-qzVqlLk8A0_x3vE66ahL9qq2uiUr8QUCOp5e2QlNQ/s1600/server_view_1.png" imageanchor="1" style=""><img border="0" height="321" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYTylKxMA0uO7ecCxu5p6zSDLuN4u1rUpeYCMp-JI_qIQDkGES7M2XXUqenAJsl0n3vq31c2gOyVjUtpcXl6I3AuIu1MSN-qzVqlLk8A0_x3vE66ahL9qq2uiUr8QUCOp5e2QlNQ/s400/server_view_1.png" /></a></div><br />
(ii) Select Servers from the list of Views.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihK09uVd1k8LpyLymcH7PcdZWzAoGsEcmZv4MWYU-67Po1qKMfyyTXzXuYIgONAT9QNuQlxwea_6-Y0MzAVRWVVLQnqOH7QasX4iI-Ji1d3m9cVZty6AZ2kMVTZmEq2UXoCGveZQ/s1600/server_view_2.png" imageanchor="1" style=""><img border="0" height="320" width="274" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihK09uVd1k8LpyLymcH7PcdZWzAoGsEcmZv4MWYU-67Po1qKMfyyTXzXuYIgONAT9QNuQlxwea_6-Y0MzAVRWVVLQnqOH7QasX4iI-Ji1d3m9cVZty6AZ2kMVTZmEq2UXoCGveZQ/s320/server_view_2.png" /></a></div><br />
(iii) Click OK.<br />
<br />
(iv) In the Server view, right-click and select New -> Server.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuP-OCY5feHvNuBhvrvewqiGAr4tTOqXslqaBxcqlR5eH4wI6Rb4_Pq4thfs9r61F-faE0jmvQCZ60_URXUNIHhAy9m4zZsEAIEbib47PaQM7JV6af4tEVYQWWzwkGGI897_h4Dg/s1600/add_server_1.png" imageanchor="1" style=""><img border="0" height="88" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuP-OCY5feHvNuBhvrvewqiGAr4tTOqXslqaBxcqlR5eH4wI6Rb4_Pq4thfs9r61F-faE0jmvQCZ60_URXUNIHhAy9m4zZsEAIEbib47PaQM7JV6af4tEVYQWWzwkGGI897_h4Dg/s400/add_server_1.png" /></a></div><br />
(v) Select Tomcat v6.0 Server from the list. Provide a name and select the runtime environment created in Step 4 above.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2EGialRJi0SnItO7aVlZy0e5uB-JD321kFePbdEOGoUFNAgADUsmn-FJy8J5sYKn1LntZMSbB32ttkcr7wN_o_IplBIbgnUWlP8h6_F2A26JDCQcvbHljkfqGVCwsTsvou1G41g/s1600/add_server_2+.png" imageanchor="1" style=""><img border="0" height="354" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2EGialRJi0SnItO7aVlZy0e5uB-JD321kFePbdEOGoUFNAgADUsmn-FJy8J5sYKn1LntZMSbB32ttkcr7wN_o_IplBIbgnUWlP8h6_F2A26JDCQcvbHljkfqGVCwsTsvou1G41g/s400/add_server_2+.png" /></a></div><br />
(vi) Click Finish<br />
<br />
Step 6. Test your Tomcat instance. <br />
<br />
(i) In the Server view, right-click the server that you just created in Step 5 above. Select Start.<br />
<br />
(ii) Open the following URL in your browser: <a href="http://localhost:8080">http://localhost:8080/</a>.<br />
<br />
(iii) You will get a "HTTP Status 404" error message and the title of the page will indicate the version of Tomcat. This should confirm that Tomcat has launched correctly.<br />
<br />
Step 7. Configure the deploy path and ports for Tomcat.<br />
<br />
(i) In the Server view, right-click the server that you just created in Step 5 above. Select Open.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-m72IqGmfJsM_FKKU1mjkhRSM2L73g7eT7s0Dh2Je0P-mTLWWx_z6xAEuB8U_5Cqg2R_eG_f0ufDbTvdxoJfea4xLvoi6-9nzNiCTUld9kOySrKLSlhrA2i5nmTCy5Wwi-A1fmQ/s1600/configure_server_1.png" imageanchor="1" style=""><img border="0" height="230" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-m72IqGmfJsM_FKKU1mjkhRSM2L73g7eT7s0Dh2Je0P-mTLWWx_z6xAEuB8U_5Cqg2R_eG_f0ufDbTvdxoJfea4xLvoi6-9nzNiCTUld9kOySrKLSlhrA2i5nmTCy5Wwi-A1fmQ/s400/configure_server_1.png" /></a></div><br />
(ii) In the server configuration view, you can modify the configuration as you wish.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmuhU2rjK9eGaEBwB-0CZMa4aRLDaW0I9jeNqVeps_2g2dzD44O20Luu34qXvFMtxfGxHkr0sVVPyiEVrH7axloUrn1PT7gfoKIznetou4Gg1ALgrK-0AGm5ih0EpvvltQWy8PIw/s1600/configure_server_2.png" imageanchor="1" style=""><img border="0" height="282" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmuhU2rjK9eGaEBwB-0CZMa4aRLDaW0I9jeNqVeps_2g2dzD44O20Luu34qXvFMtxfGxHkr0sVVPyiEVrH7axloUrn1PT7gfoKIznetou4Gg1ALgrK-0AGm5ih0EpvvltQWy8PIw/s400/configure_server_2.png" /></a></div><br />
<h3>HELP !!! <a href="http://wiki.eclipse.org/WTP_Tomcat_FAQ#If_I_start_my_Tomcat_server_and_try_to_display_Tomcat.27s_default_page.2C_why_do_I_see_a_directory_listing_or_404_error_page.3F">404 error when accessing http://localhost:8080/ </a></h3><br />
The tomcat instance that we created in the steps above comes with a ROOT webapp that has no content. You may want to deploy a proper ROOT app with the default Tomcat welcome page that we are all familiar with. I like the welcome page because it gives me quick access to the release notes and Apache's online pages for Tomcat.<br />
<br />
To get the welcome page, you must do the following :<br />
<br />
(i) Click on the "Open launch configuration" link in the server configuration view (see Step 7 above). In the Edit Configuration window that appears, switch to the Arguments tab and view the location by examining the setting for catalina.base and wtp.deploy in the "VM arguments" field.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHfXfPW-3EMHNgyaL0IgXcBwN_UQIlJQICYod5hh8DeBMBce7cIMQtf07jvIBU5smylfdyH4fHEuQWnqB2b8oaXacl1jcSHcTt3iY8bs_hoZvZs8YM7GqWzb0VpQ5LSmsxZyNaqQ/s1600/launch_configuration_1.png" imageanchor="1" style=""><img border="0" height="328" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHfXfPW-3EMHNgyaL0IgXcBwN_UQIlJQICYod5hh8DeBMBce7cIMQtf07jvIBU5smylfdyH4fHEuQWnqB2b8oaXacl1jcSHcTt3iY8bs_hoZvZs8YM7GqWzb0VpQ5LSmsxZyNaqQ/s400/launch_configuration_1.png" /></a></div><br />
(ii) Start and stop your tomcat instance. <i><b>Note: It is important that you do this step before proceeding to the next step because the wtp.deploy directory does not get created until you have started tomcat at least once.</b></i><br />
<br />
(iii) From the command-line, you can copy the ROOT application from the tomcat installation (see Step 1 above) to the eclipse tomcat server instance (see Step 5 above).<br />
<br />
<blockquote>$ cp -R ~/Apps/apache-tomcat-6.0.26/webapps/ROOT ~/workspace/personal_workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/<br />
</blockquote><br />
(iv) You should now be able to access the root app from <a href="http://localhost:8080/">http://localhost:8080/</a><br />
<br />
<h3>HELP !!! How do I configure tomcat-users.xml ? </h3><br />
In the Package Explorer view of Eclipse, you will find a new project called "Servers". Expand the project and you will see the tomcat-users.xml file.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimkWEpoWqRzk07BgPrXzYQi_XfjPI4OGFj4caEF7qs4SWcz5kwaD8lmgOyfXK2715G2PxhIa6UdvaZzHaupCX1xtbaCwWmeOkRzw9fxT1cIteYsWbK2VbVim6ecA4HvFEgtwS6Dw/s1600/edit_tomcat_users.png" imageanchor="1" style=""><img border="0" height="120" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimkWEpoWqRzk07BgPrXzYQi_XfjPI4OGFj4caEF7qs4SWcz5kwaD8lmgOyfXK2715G2PxhIa6UdvaZzHaupCX1xtbaCwWmeOkRzw9fxT1cIteYsWbK2VbVim6ecA4HvFEgtwS6Dw/s400/edit_tomcat_users.png" /></a></div><br />
<br />
I hope you have saved yourself some time with the help of the above article. Happy coding!<br />
<br />
CiaoUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-56612124300969628492010-12-24T08:50:00.001-08:002010-12-24T08:50:22.503-08:00Julian Assange interview with David Frost<object width="680" height="410" ><param name="movie" value="http://www.youtube.com/v/U6mcSXge4Qo" ></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src ="http://www.youtube.com/v/U6mcSXge4Qo" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="680" height="410"></embed></object>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-23992090590251016502010-12-21T09:32:00.000-08:002010-12-21T09:32:41.662-08:00Don't be evil!I am not a fan of large multi-billion dollar tech corporations but I am a fan of Google. Here's why:<br />
<br />
1. Google tries to balance openness with business goals. While companies like Oracle, Facebook and @9913 control every bit (pun intended) of their ecosystem, Google is still a big proponent of open standards and open source technologies, and Android is probably the best example of this. <br />
<br />
2. Google is driven by geeks and not marketing or business minded employees. There is no better example of a geeky employee than Andy Rubin who co-founded Android. Take a look at this <a href="http://twitter.com/arubin/status/27808662429">tweet from Andy</a>. Which VP of a tech company tweets a unix command ? Isn't that awesome ?<br />
<br />
3. Google invests heavily in research both internally and externally and, research is very important for the betterment of humanity. While most tech companies focus on making pretty products for the middle class in the developed world, Google continues to focus on advancements in engineering. Google's <a href="http://techcrunch.com/2010/10/09/google-car-video/">self-driving car</a>, <a href="http://research.google.com/">research group</a>, <a href="http://www.googlelabs.com/">labs</a>, <a href="http://scholar.google.com/">scholar</a> and <a href="http://www.google.com/corporate/green/index.html">green</a> all drive towards the goal of moving the human race forward.<br />
<br />
4. Google has the guts and the conviction to stop doing business in China, a country that doesn't give a <a href="http://www.pbs.org/newshour/rundown/2010/12/jailed-chinese-dissident-receives-nobel-peace-prize.html">hoot about human rights</a>. While other tech companies like <a href="http://www.reuters.com/article/idUSTOE63901220100410">Microsoft</a>, <a href="http://latimesblogs.latimes.com/technology/2010/12/facebooks-zuckerberg-visits-china.html">Facebook</a> and <a href="http://gigaom.com/apple/apple-brings-app-store-online-retail-to-china/">@9913</a> continue to court China with the intention of expanding their business empires to its 1 billion population, Google has decided to stick to principles and <a href="http://www.guardian.co.uk/world/us-embassy-cables-documents/207610">pull out of China</a>. <br />
<br />
<a href="http://en.wikipedia.org/wiki/Don%27t_be_evil">Don't be evil</a><br />
CiaoUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-43299645606031224162010-12-12T11:03:00.000-08:002010-12-12T11:05:39.165-08:00'Wikileaks: The Game'<a href="http://www.jeuxjeuxjeux.fr/jeu/ne+te+fais+pas+attraper/wikileaks.html">Game courtesy of jeuxjeuxjeux.fr</a><br />
<br />
<br />
<object width="600" height="436"><param name="movie" value="http://games.jeuxjeuxjeux.fr/data/1/4/4/14414.swf"><embed src="http://games.jeuxjeuxjeux.fr/data/1/4/4/14414.swf" width="600" height="436"></embed></object><br />
<small>Via <a href="http://www.jeuxjeuxjeux.fr">JeuxJeuxJeux.fr</a></small>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-5773295042647334502010-12-10T09:43:00.000-08:002010-12-10T09:45:05.168-08:00What happened to 'J2EE Application Servers on Desktops' ?Here is an article I wrote a long time ago (11/2004 to be precise) about J2EE Application Servers on Desktops. It is 2010 and obviously my prediction hasn't come true. While I analyze what might have gone wrong with my prediction, here is the article for your perusal. <br />
<hr><b>Nov, 2004</b><br />
<b>Summary</b><br />
This article looks at several reasons that make it feasible and often desirable to use server-based software on desktops. <br />
<br />
<h3>J2EE Application Servers on Desktops - Vijay Mariadassou</h3>Last week, I was overjoyed to read about <a href="http://news.com.com/2100-1012_3-5208998.html">IBM's plans for Web-based desktop software</a>. The software is part of <a href="http://www-306.ibm.com/software/lotus/">IBM's Lotus Workplace</a> strategy and is designed to be distributed and accessed through a Web server. The news reaffirmed my long-held belief that desktop applications will, in the not so distant future, be replaced by application server-based software. Server-based software has traditionally been confined to deployments on large enterprise servers. But, as I discuss below, there are several reasons that make it feasible and often desirable to use server-based software on desktops also.<br />
<br />
<b>Application Servers are feasible on Desktops</b><br />
<br />
The primary reason for the absence of server-based software on desktops is the resource-intensive nature of server software, also known as middleware. Traditionally, middleware were designed and built to handle large numbers of transactions typical of large organizations with huge IT infrastructures. But, as Information Technology has permeated organizations of all sizes, middleware has evolved to fit into smaller infrastructure. Middleware based on J2EE and .Net are notable in this respect.<br />
<br />
The latest breed of J2EE-based application servers like <a href="http://jboss.org/jbossas">JBoss</a> and <a href="http://geronimo.apache.org/">Geronimo</a> have highly modularized architectures based on the Java Management Extension (JMX) API that allow them to be deployed with variable sets of modules. Consequently, these servers may be deployed in resource-friendly configurations with minimal number of modules. For example, modules such as messaging (JMS) and transactions (JTS) may be removed without any adverse effects on the normal functioning of the application server. Such configurations make it possible for these servers to overcome any resource constraints.<br />
<br />
Also, most modern application servers make use of some sort of resource caching to further optimize resource usage and performance.<br />
<br />
Finally, the processing capacity of desktops has been steadily increasing. Thanks to <a href="http://en.wikipedia.org/wiki/Moore%27s_law">Moore's Law</a>, yesterday's servers are today's desktops. Modern desktops are now capable of handling the many CPU-intensive operations normally associated with application servers. And, the imminent arrival of 64-bit processors in the desktop market will go a long way in guaranteeing this capability.<br />
<br />
Thus, it is my belief that application servers are feasible on desktops and concerns about their consumption of resources are unnecessary.<br />
<br />
<b>Application Servers are desirable on Desktops</b><br />
<br />
Application server-based software is desirable for several reasons, which let us discuss below.But, before we go into the discussion, I wish to make a disclaimer. There will always be certain applications like games, music editing and animation software that are very sensitive to response times and will remain the domain of Desktop software. For such applications, Desktop software is preferable to <a href="http://en.wikipedia.org/wiki/Middleware">middleware</a>-based software because they are optimized for the operating system and the hardware hosting the software. For most other applications that are not as sensitive to response time, middleware-based software is desirable.<br />
<br />
An important advantage of using middleware-based software on the desktop will be the reduced impact of viruses in the event of an attack. The devastation caused by the current wave of virus attacks and Internet worms is attributed primarily to the monoculture (read Windows) that exists on the desktop. The choices that both commercial as well as free J2EE application server vendors provide will bring diversity to the desktop and rid it of this monoculture.<br />
<br />
In addition, middleware-based software are inherently more robust and secure than traditional Desktop software. Middleware vendors have invested millions of dollars in ensuring their middleware are scalable, reliable and secure for highly sensitive industries like the financial industry. And, software that operate within the secure environment of a middleware are likely to be less vulnerable to security attacks than those that operate out of this secure environment.<br />
<br />
Another advantage of middleware based-software is the cost advantage it offers to the vendor and, consequently, to the user. Since there is no difference between a middleware platform deployed on a desktop and that deployed on a large Enterprise Server, vendors can move their existing Enterprise applications to the desktop at no extra cost. Vendors can also leverage the huge talent pool of J2EEdevelopers available in the Enterprise Application industry to build applications for the desktop. These developers do not have to be trained on the myriad Operating System APIs.<br />
<br />
Finally, as users spend more time online, they will find it Web-based interfaces more natural to use than traditional desktop interfaces. A case in point is the growing popularity of services like Ofoto and Yahoo! Photos that are replacing the traditional photo albums on the desktop.<br />
<br />
<b>Over The Horizon</b><br />
<br />
I see IBM’s recently announced plans as foreshadowing where we can expect to see the first breed of middleware-based desktop software emerging – the workplace. Workplace software is expected to benefit the most from the security and cost advantages of middleware-based software.<br />
<hr><br />
CiaoUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-51643618626306148852010-12-05T23:56:00.000-08:002010-12-05T23:59:00.305-08:00Boycott Amazon and PayPalYou probably have heard about WikiLeaks and the cowardice of Amazon and PayPal. If not, go to <a href="http://www.suite101.com/content/wikileaks-controversy-continues---amazon-and-paypal-pull-the-plug-a317114">this link</a> for details on the appalling cowardice of these corporations. <br />
<br />
I am appalled at Amazon's lack of character. They succumbed to pressure from the political class and decided to drop WikiLeaks. I have been using Amazon for a long time now for buying everything from books to diapers and toys. But, after this latest incident, I have decided that it is not worth doing business with a company that cannot stand for freedom of speech. <br />
<br />
I am going to <a href="http://www.antiwar.com/blog/2010/12/02/daniel-ellsberg-says-boycott-amazon/">boycott Amazon</a> starting today. I have just removed all Amazon Associates widgets from my blog. I will be shopping for diapers at Costco or Walmart. I will be shopping for toys at Target or Toys R Us. I will be shopping for books at Borders and Barnes & Noble. I will be shopping for a Nook or Sony e-Reader. I will be switching to Google App Engine.<br />
<br />
Also, starting today I have decided to stop using PayPal. I have just initiated the transfer of all my money out of my PayPal account and will be removing my bank account from PayPal once the transfer is complete.<br />
<br />
Shame on you Amazon ! Shame on you PayPal !<br />
<br />
P.S.: I am very proud of Google for standing up for freedom and pulling out of China. Go Google ! Go Android !Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7864320.post-62123742773376589682010-12-03T09:03:00.000-08:002011-01-01T11:55:41.762-08:00Write and read locks in JavaHere's a crude but very transparent way of doing the locking. Note the below code assumes that the implementer will ensure by design that there are <b>NO concurrent writers</b> but concurrent readers i.e., only a single thread will write but multiple threads could read.<br />
<br />
<blockquote>int _readers = 0;<br />
boolean _writeWaiting = false;<br />
<br />
writeMethod() {<br />
<br />
_writeWaiting = true;<br />
boolean canWrite = false;<br />
<br />
while (!canWrite) {<br />
<br />
synchronized (lock) {<br />
<br />
canWrite = _readers > 0 ? false : true;<br />
if (canWrite) {<br />
_writeWaiting = false;<br />
writeToFile;<br />
}<br />
}<br />
}<br />
}<br />
<br />
readMethod() {<br />
<br />
while (_writeWaiting) {<br />
sleep;<br />
}<br />
<br />
synchronized (lock) {<br />
_readers++;<br />
}<br />
<br />
readFile;<br />
<br />
synchronized (lock) {<br />
_readers--;<br />
}<br />
}<br />
</blockquote><br />
The following code uses Java 1.5 APIs and is a lot more efficient than the above pseudocode. But, it is very opaque. If your JVM implementation has a bug ( and JVMs do have bugs ), the below code could be very tricky to validate and debug.<br />
<br />
<blockquote>static ReentrantReadWriteLock _rwl = new ReentrantReadWriteLock();<br />
<br />
writeMethod() {<br />
<br />
rwl.writeLock().lock();<br />
writeToFile();<br />
rwl.writeLock().unlock();<br />
<br />
}<br />
<br />
readMethod() {<br />
<br />
rwl.readLock().lock();<br />
readFromFile();<br />
rwl.readLock().unlock();<br />
<br />
}<br />
</blockquote><br />
<b><i>Update to post:</i></b> Edit made on Jan 1, 2011 to clarify the beginning paragraph of this article.Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7864320.post-33788535070897894532010-11-16T08:36:00.000-08:002011-01-18T08:53:36.823-08:00Why I dropped off Facebook ?Recently, I decided to drop off Facebook and deleted all my relationships on the site. Here are some of the reasons why I decided to get out of Facebook :<br />
<br />
1. Facebook doesn't care for my privacy. They keep changing privacy settings and make it my (the user's) problem to go fix the settings. I have better things to do in life than deal with this crap. Take a look at how Facebook has been encroaching on your privacy <a href="http://www.eff.org/deeplinks/2010/04/facebook-timeline">http://www.eff.org/deeplinks/2010/04/facebook-timeline</a><br />
<br />
2. Facebook is neither public nor private. It's somewhere in between and that makes me really nervous. Facebook's walled garden makes it private to the rest of the world but within the garden everything is public. <a href="http://techcrunch.com/2010/09/20/facebook-not-now-follow/">http://techcrunch.com/2010/09/20/facebook-not-now-follow/</a><br />
<br />
3. Facebook is like a big black hole. They don't let you export your contacts or posts; they make it almost impossible to move away from Facebook; they suck you into their hole.<br />
<br />
4. Facebook doesn't give a hoot about your relationships. You treat your friends, colleagues, family and acquaintances all the same. But, in reality they are not the same. There are special people and not so special people. ( <a href="http://www.youtube.com/watch?v=nrlSkU0TFLs">http://www.youtube.com/watch?v=nrlSkU0TFLs</a> )<br />
<br />
5. Facebook is boring. I am sorry to all my friends on Facebook but this huffingtonpost post sums it up <a href="http://www.huffingtonpost.com/andy-ostroy/i-hate-facebook_b_178867.html">http://www.huffingtonpost.com/andy-ostroy/i-hate-facebook_b_178867.html</a><br />
<br />
6. Facebook is a monopolistic social information empire and, monopolies and empires are never good for society. <br />
<br />
In conclusion, I am going to stay away from Facebook and stick to <a href="http://twitter.com/vmdassou">Twitter(public)</a> and Email(private).<br />
<br />
Ciao.<br />
<br />
<b><i>Update 1:</i></b> What a coincidence that I wrote this blog on <a href="http://www.newsweek.com/video/2010/11/17/who-needs-500-facebook-friends.html">"National Unfriend Day"</a>.<br />
<br />
<b><i>Update 2:</i></b> Debt collectors utilize Facebook to embarrass those who owe. <a href="http://www.wtsp.com/news/mostpop/story.aspx?storyid=156762">Read more...</a><br />
<br />
<b><i>Update 3:</i></b> Dec 1, 2010: <a href="http://www.thinq.co.uk/2010/11/30/facebooks-button-tracking-you/">Facebook's 'Like This' button is tracking you Whether you click it or not</a>. Another reason to hate facebook.<br />
<br />
<b><i>Update 4:</i></b> Jan 18, 2011: Another example of why Facebook can be dangerous to your privacy online. <a href="http://tinyurl.com/4d56wnd">Man Mines Facebook For Security Questions, Nabs Nude Photos From Email</a><br />
<br />
<b><i>Update 5:</i></b> Jan 18, 2011: Facebook has done it again; they don't give a sh** about your privacy. <a href="http://tinyurl.com/6kdbdfz">Third-party apps now have access to your address and phone number</a>.Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7864320.post-3186898509610558502010-11-10T08:07:00.000-08:002010-12-05T23:35:07.741-08:00The Pain and Benefits of Critical Thinking and DriveAs is standard procedure in Corporate America, I had my annual performance review done by my manager. During the year, I had performed well on all fronts except on my relationships with some of my peers. I had done an excellent job of delivering business critical projects and managed a large, very successful team of engineers. But, my relations with some of my peers did not pan out well during the year.<br />
<br />
My poor relations with my peers has been the only sore point during the year. I attribute this to my low tolerance for mediocre work and poorly designed engineering solutions. One of the key reasons for my success has been my ability to do quick critical analysis of business and engineering problems, work aggressively on solutions and drive them to a closure. But, this critical analysis and aggressiveness has cost me my relationships.<br />
<br />
This coming year, I intend to take better care of my relationships. Critical thinking and drive is very important in the world's largest technology startup. But, these same qualities hurt people's feelings. No one likes to hear that their designs or implementations have flaws. No one likes to hear that they are not moving fast enough. <br />
<br />
A colleague of mine (yes, I do have good relationships with some of my peers just not with everyone) has advised me to read The Power of Now: A Guide to Spiritual Enlightenment by Eckhart Tolle. <br />
<br />
I hope to read the book during the holidays and will post a review here.<br />
<br />
Ciao<br />
<br />
<b><i>Update 1:</i></b> Dec 5, 2010: Boycott Amazon for dropping WikiLeaks and not standing up for freedom. Removed Amazon book information from my website and closed my Amazon Associates account.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7864320.post-82613733269282666932010-10-07T07:48:00.000-07:002010-10-07T08:31:41.797-07:00Social Enterprise for technical documentationDocumentation is an onerous task that very few engineers (read geeks) will willingly do. It requires discipline, patience and time to prepare readable and usable documents. Traditional use of documentation tools like a WIKI or CMS place constraints on the documenter to follow style and structure guidelines that may make sense to management but absolutely no sense to geeks. <br /><br />A lot of technical documentation is often created and lost on whiteboards and cubicle shout-outs. Such documentation rarely gets captured on a traditional document site due to the constraints outlined above.<br /><br />I propose using Twitter and Moblog in the enterprise as a facilitator for documentation. Most geeks today have smartphones and are comfortable writing short text messages and taking pictures or videos on their cellphones. Here's how I envision using Twitter and Moblog for documentation:<br />1. Whenever there is a whiteboarding session, the engineers take pictures and upload to the internal Moblog/Twitter site. And, when there is a shout-out they tweet their brains out and dump them onto an enterprise twitter site. Even better, they start the shout-out on Twitter.<br />2. People within the organization can start following the tweeters and mobloggers that they trust and rely upon.<br />3. We could even throw in some Facebook "Like" or Digg "Digg It" features for followers to rate the posts.<br />4. Based on the number of followers and ratings each engineer has, a professional documentation team could port the posts of the most followed engineers into a traditional documentation system.<br /><br />The process outlined above can be extended to communicating project status and team huddles instead of emails in overflowing inboxes. <br /><br />Here are some links to explore if you think this post makes sense..<br /><a href="http://moblog.net/home/">Moblog:camera phone mobile blogging community</a><br /><a href="http://twitter.com/vmdassou">Yours truly on Twitter</a><br /><a href="http://www.web-strategist.com/blog/2008/09/08/list-of-enterprise-microblogging-tools-twitter-for-the-intranet/">List of Enterprise Microblogging Tools</a><br /><a href="http://status.net/>StatusNet: open source microblogging platform</a><br /><br />Cheers.Unknownnoreply@blogger.com0