How to fix the Tomcat 7 private instance and Eclipse integration error in Ubuntu

The first step as part of my journey in learning Spring MVC was to create a private instance of Tomcat 7. The procedure I had followed is documented as part of my earlier post: How to setup multiple instances of Tomcat 7 in Ubuntu.

The next step was to setup Eclipse to recognize the Tomcat 7 private instance.

A new server instance can be registered in Eclipse using Window -> preferences -> Server -> Runtime Environments menu.

But, when I try add the private Tomcat 7 instance, Eclipse reports that it could not identify the version of the Tomcat and refuses to register the instance.

Following the suggestions by David Edwards at askubuntu.com for a problem not directly linked to my problem, solved the Eclipse-Tomcat7-private-instance-integration issue.

The solution suggested by David Edwards was to create a link for the lib and bootstrap.jar library in the private instance folder.

Due to missing fix for the bug-297675 in the tomcat7-user package, the tomcat7-instance-create script fails to setup everything as required by Eclipse when executed.

The part of the solution that I followed can be divided into two steps.

Step 1: Create a link to the lib folder and the bootstrap.jar file located at /usr/share/tomcat7 in the tomcat7 private instance directory.

ln -s /usr/share/tomcat7/lib ~/Workspace/github/springapp/tomcat//lib
ln -s /usr/share/tomcat7/bin/bootstrap.jar ~/Workspace/github/springapp/tomcat/bin/bootstrap.jar

In addition, I also had to create a link to /usr/share/tomcat7/bin/tomcat-juli.jar.

ln -s /usr/share/tomcat7/bin/tomcat-juli.jar ~/Workspace/github/springapp/tomcat/bin/tomcat-juli.jar

Note: ~/Workspace/github/springapp/tomcat is my Tomcat 7 private instance folder created using tomcat7-intance-create script.

Step 2: Either download the catalina.policy file from code repository or from within the general Tomcat 7 instance configuration folder. For instance:

# If you opt for downloading the file - replace 'precise' with the right name of your Ubuntu release.
curl http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/precise/tomcat7/precise/download/head:/catalina.policy-20110521092527-dk8tcyjy21h8eu9h-1652/catalina.policy > ~/Workspace/github/springapp/tomcat/conf/catalina.policy

Note: Make sure that you are downloading the latest version of http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/precise/tomcat7/precise/view/head:/conf/catalina.policy file.

Eclipse should be able to recognize the version of Tomcat without issues.

Meanwhile, shutdown and restart the private instance using the commands:

settipalli@settipalli-ubuntu:~/Workspace/github/springapp/tomcat$ ./bin/shutdown.sh

# Followed by:
settipalli@settipalli-ubuntu:~/Workspace/github/springapp/tomcat$ ./bin/startup.sh

References:
1.How to setup multiple instances of Tomcat 7 in Ubuntu
2.Unknown version of Tomcat was specified with tomcat-7.0.42
3.Tomcat and Eclipse Integration Error : “Unknown version of Tomcat was specified.”
4.Cannot start tomcat after installing a private instance
5.Tomcat 7 and Eclipse integration getting error
6.Configure TOMCAT in Eclipse
7.Eclipse Community Forums – Can’t add a new Tomcat 7 Server
8.Eclipse 4.2 (Juno) ‘Cannot create a server using the selected type’ in Tomcat 7
9.Eclipse can’t find catalina.policy and bootstrap.jar where it expects them
10.Man page of tomcat7-instance-create

How did I install Zen-Coding in Eclipse?

As I have started creating an AngularJS-ExpressJS-NodeJS-Redis-Couchbase project, I like to utilize the power of Zen Coding1 in Eclipse.

Zen Coding allows for quicker development of HTML, XML, CSS files using custom abbreviations instead of writing all the tags. For example, the below snippet would result in a well formatted basic HTML 5 document structure to be created in your editor.

html:5

Output:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

</body>
</html>

On similar lines:

header+(div#container>div#sidebar+div#content>div#row>div#col-md-6+div#col-md-6)+footer

Would result in:

<header></header>
<div id="container">
    <div id="sidebar"></div>
    <div id="content">
        <div id="row">
            <div id="col-md-6"></div>
            <div id="col-md-6"></div>
        </div>
    </div>
</div>
<footer></footer>

Zen-Coding has been renamed as by its author – Sergey Chikuyonok2 as Emmet3 and can be downloaded form the github location https://github.com/emmetio/emmet.

Tutsplus has a good video tutorial on Zen-Coding4, which is worth a watch. Its about 5 minutes in length.

A quick review of the excellent Emmet documentation5 would provide a better insight into the substantial benefits of using Zen-Coding.

Zen-Coding plugin is available for many offline text editors that can be installed in your machine.

Many of the online services such as JSFiddle adn JS Bin also have support for Zen-Coding facility.

To install Zen-Coding (Emmet) in Eclipse, I tried downloading it from Eclipse-Marketplace – and it failed.

The below approch worked for me:
– Open Install New Software... within the Help menu in Eclipse IDE.
– Paste: http://emmet.io/eclipse/updates/ within the text-box after Work with: label.
– Wait for Eclipes to download the available software information and select Emmet from the displayed list.
– Click the Next button and follow the screens. Finally restart Eclipse for the changes to take effect.


References:

How do I install Eclipse Juno in Ubuntu 12.04?

There are numerous articles on the Internet where the mechanism to be followed to install Eclipse Juno in Ubuntu is well explained. This article is a reminder to myself on the commands that were used to install Eclipse Juno in my Ubuntu 12.04 machine.

# Download the Eclipse Juno package from http://www.eclipse.org/downloads/.
# I usually prefer the 'Eclipse Classic' package out of habit but feel free to grab the one that fits
# your requirement.

# As an example, let me download the 64-bit Ubuntu tar.gz image.
root@labs:~$ cd ~/Downloads
root@labs:~$ wget http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.2.1-201209141800/eclipse-SDK-4.2.1-linux-gtk-x86_64.tar.gz

# Untar the package. Example:
root@labs:~$ tar -zxvf eclipse-SDK-4.2.1-linux-gtk-x86_64.tar.gz

# The net result would be a folder named "eclipse". Lets copy it to /opt.
root@labs:~$ sudo mv "eclipse" /opt

# Lets add a link to the executable - "/opt/eclipse/eclipse" in /usr/bin for easier access.
root@labs:~$ ln -s "/opt/eclipse/eclipse" /usr/bin/eclipse

# Lets create a icon in the Unity Dashboard for convenience.

# Reference: https://ksearch.wordpress.com/2012/10/25/how-do-i-install-sublime-text-2-in-ubuntu-12-04/
# Fire up a text editor. I am using vim here. But, any text editor would do.
root@labs:~$ sudo vim /usr/share/applications/eclipse.desktop

# Add the below content to /usr/share/applications/eclipse.desktop and save it.

  [Desktop Entry]
  Version=1.0
  Name=Eclipse
  
  Exec=eclipse
  Terminal=false
  Icon=/opt/eclipse/icon.xpm
  Type=Application
  Categories=IDE;Development
  X-Ayatana-Desktop-Shortcuts=NewWindow

  [NewWindow Shortcut Group]
  Name=New Window
  Exec=eclipse
  TargetEnvironment=Unity

# All done.


References:

How to enable Pthread support in Eclipse CDT IDE?

Eclipse is a wonderful open source integrated development environment. It was primarily created to support Java development but was later extended to support other programming languages.

To support programming in other languages, plugins were created as an add-on to the core Eclipse IDE. One such plugin emerged out of the Eclipse CDT project. The term ‘CDT’ stands for ‘C/C++ Development Tooling’. As the name implies, it provides a full functional integrated development environment based on the core Eclipse platform to assist in the development of projects in C and C++ programming language.’

This post describes how to update the configuration of the Eclipse CDT IDE to support successful compilation of C/C++ projects that utilize the ‘Pthread’ library.

Continue reading “How to enable Pthread support in Eclipse CDT IDE?”