Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Monday, February 17, 2014

Things you should know using eclipse and Tomcat


  1. You should stop Tomcat service when you want to test your jsp within eclipse as you will run Tomcat within eclipse.
  2. Eclipse doesn't always display everything. It should copy all files from the project folder to a Tomcat work directory, but it doesn't! It tends to “lose” CSS files and images. This means that, except for a quick check of simple features, you might do what I do and use Tomcat externally. To see the output of the test project outside Eclipse, first of all, stop the “internal” Tomcat by rightclicking it under the Servers tab of the Workbench and selecting Stop. Then, start the Tomcat service in Windows. Right-click the test-project folder as you did to launch it within Eclipse, but this time select Export WAR File. When the WAR Export screen appears, the only thing you have to do is browse to select the destination, which should be %CATALINA_HOME%\webapps\test.war, and click Finish. In a browser, type http://localhost:8080/test to see the output of the project. This works because, as I showed to you at the end of the previous section, Tomcat automatically expands all WAR files it discovers in its webapps folder, without any need to restart it. And because by default Tomcat looks for index.html, index.htm, and index.jsp. If you want, you can change the default by adding the following element to the body of the web-app element of web.xml: <welcome-file-list>
                           <welcome-file>whatever.jsp</welcome-file>
                  </welcome-file-list>
  3. You can export WAR file to Tomcat folder, you also can import WAR file to eclipse workplace.

Wednesday, February 12, 2014

Deploy eclipse web project to Tomcat


1. Export web project to WAR file.






















2. Go to Tomcat Manager page, select WAR file and click "Deploy" button.














Sunday, February 9, 2014

Installing the BIRT Viewer in Tomcat


BIRT POJO Viewer

Starting with the release of BIRT 3.7 the Viewer has been changed to be POJO based. All required BIRT plugins are now in the WEB-INF/lib folder of the Viewer, and the WEB-INF/platform directory has been removed. The Viewer should continue to operate as in previous versions of BIRT. More information about this change is available in the BIRT 3.7 Migration Guide.

Using Tomcat

This page explains how to deploy the BIRT viewer to a Java EE container. We'll useApache Tomcat, since it is open source and readily available. The same concepts, perhaps with different details, apply to other app servers. These instructions assume you'll install Tomcat on your own machine using the default port number of 8080.

Install the Viewer

Deploy the BIRT Viewer application. Follow these steps:
  • Download the zip file with the BIRT report engine runtime. The file is named birt-runtime-version#.zip.
  • Unzip the file in a staging area.
  • Look under the birt-runtime- directory and locate the "Web Viewer Example" directory.
  • Copy the Web Viewer Example directory to the webapps directory of your Tomcat installation. For ease of reference, rename the directory to "birt-viewer".
  • Stop, then restart Tomcat.
  • Display the Tomcat manager application to check that the viewer is deployed:http://localhost:8080/manager/html.
  • Verify that birt-viewer is listed as an application, then click on the birt-viewer link.
  • A page confirming that the BIRT viewer has been installed should be displayed. Click on the link labeled "View Example" to confirm that your installation is working properly.
  • The BIRT Viewer requires that cookies be enabled.
If you choose to put the Viewer into some other location, you'll need to use a context entry within the server.xml file to indicate the deployment location. See Tomcat documentation for details.

Install your JDBC Drivers

Add the jar files for your JDBC drivers to the Viewer. Copy the driver the following directory:

BIRT JDBC Driver Location Note:

    If you are installing BIRT 2 series the driver needs to be copied to birt-viewer\WEB-INF\platform\plugins\org.eclipse.birt.report.data.oda.jdbc\drivers directory.
    If you are installing BIRT 3.7 or higher, the jdbc driver should be placed in the WebViewer's classpath (eg WEB-INF/lib).

Testing a More Complex Report

We'll test the viewer further using one of the example reports created for the "Classic Models" database. Note that Classic Models database is included in the birt runtime distribution so no further set-up is required. Follow these steps:

Monday, February 3, 2014

How to test your web project in Eclipse

Before you can test your web project, you need to define a new server. Once you define a new server, your eclipse will generate a new server project automatically:
























Change Tomcat default home screen

Tomcat default home screen is located on C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\index.jsp. In order to keep all the default functions you should copy the ROOT folder and change its name to "home", then delete everything in ROOT folder and copy your own files into this folder.





















After this modification you can browse the original home screen by typing:
http://localhost:8080/home

The conf\web.xml file define what kind of file can be the start up screen.
















So you can create a index.jsp, index.htm or index.html file as your startup screen.

Friday, January 31, 2014

Install Tomcat on Mac OS X

Install Tomcat on Mac OS X

The most simple way is:

  1. Download Tomcat .zip file from internet, unzip it and then rename it to "Tomcat".
  2. Copy "Tomcat" folder to /Library or other folder.
  3. run terminal, execute the following commands:
    cd /Library/Tomcat/bin
    chmod +x startup.sh

    chmod +x shutdown.sh
    chmod +x catalina.sh
    chmod +x setclasspath.sh
    chmod +x bootstrap.jar
    chmod +x tomcat-jni.jar
  4. Run Tomcat by enter the below command:
    ./startup.sh


Other way from internet is as below:

(Original link: https://code.google.com/p/gbif-providertoolkit/wiki/TomcatInstallationMacOSX)

Table of Contents

  • Install Tomcat on Mac OS X
  • Table of Contents
    • Prerequisites
    • Steps
      • 1) Download Tomcat 6.x
      • 2) Install Tomcat 6.x
      • 3) Edit the Tomcat Configuration
      • 4) Run Tomcat
      • 5) Test Tomcat
      • 6) Shut down Tomcat
      • 7) Running Tomcat as a service daemon
      • 8) References
This tutorial explains how to install the Apache Tomcat 6.0.x on Mac OS X 10.5 or 10.6. This document is not tested to work with other versions of Tomcat or Java. For complete details, please consult the specific documentation for those software installations.
This tutorial is for now 'partially' tested with Tomcat 7.

Prerequisites

Following are the conditions assumed to be true in order to follow this tutorial.
1) The client version of OS X 10.5.8 Leopard or OS X 10.6 Snow Leopard. If you're running Server version of Mac OS X 10.5 or 10.6, Tomcat is pre-installed.
2) The latest security upgrades.
3) JAVA 5 or JAVA 6 Framework installed.
4) Logged in as an administrator.

Steps

1) Download Tomcat 6.x

Download the latest stable Tomcat 6 Binary Distribution Core (tar.gz) release from http://tomcat.apache.org/download-60.cgi. This should put a file of the form apache-tomcat-6.x.x.tar.gz (or apache-tomcat-6.x.x.tar if you download with Safari) into your Downloads folder.

2) Install Tomcat 6.x

Open the Terminal application to get a command prompt. The commands that follow assume that the Bourne Again SHell (bash) is in use. You can find out which shell you are using by typing the following and then hitting the ENTER key in the Terminal's command prompt:
echo $SHELL
All versions of OS X later than 10.3 use bash as the default shell. If the result echo command does not end in "/bash", you can change the default shell by using the System Preferences Accounts pane. If the pane is locked, unlock it. Control Click on your account name and a contextual menu will appear. Click on Advanced Options. You will then be presented with a dialog where you can change the default login shell to whatever you want. Select "bin/bash".
Change into the Library directory:
cd /Library
Create the Tomcat directory:
mkdir Tomcat
Set the owner of the Tomcat directory, where username should be the login name under which Tomcat will run:
chown username Tomcat
Set the group for the Tomcat directory to admin:
chgrp admin Tomcat
Change into the newly created Tomcat directory:
cd Tomcat
If the downloaded file was not already unzipped, unpack and unzip it into the Tomcat directory:
tar -xvzf ~/Downloads/apache-tomcat-6.x.x.tar.gz
Otherwise unpack the tar file:
tar -xvf ~/Downloads/apache-tomcat-6.0.x.tar
Create a Home symbolic link that points to the Tomcat directory:
ln -sfhv apache-tomcat-6.x.x Home

3) Edit the Tomcat Configuration

You will need to add a name and password to the tomcat-users.xml configuration file to access the Tomcat management and administration programs. Execute the following commands in Terminal:
Change into the Tomcat configuration directory:
cd Home/conf
Edit the tomcat-users.xml file. This example shows the command to edit using nano:
nano tomcat-users.xml
In the file, add the two lines below into the file above the line that says </tomcat-users> and outside of any comments (delimited with <!-- and-->). Substitute the name you want as the admin's username for "admin" and enter a password for that user to log in to the Tomcat Manager in place of "password".
<role rolename="manager"/>
<user username="admin" password="password" roles="standard,manager,admin"/>
If you're setting up Tomcat 7, the role is defined differently:
<user username="admin" password="password" roles="manager-gui"/>
In Tomcat 7, role names are automatically created.
Save the tomcat-users.xml file and exit from the editor.

4) Run Tomcat

Execute the following commands in Terminal: Change into the directory where Tomcat startup scripts are located
cd ../bin
Remove all of the scripts ending with .bat.
rm *.bat
Execute the Tomcat startup script:
./startup.sh
Check the Tomcat error log for errors:
less ../logs/catalina.out
If there are no error messages in the log files, then the installation has been completed successfully and Tomcat is running. There should be an informational message similar to the following near the end of the log file:
INFO: Server startup in 2412 ms
Under some circumstances the startup scripts do not execute because the execute permission has not been set. If this is the case you can change the execute permission to the scripts by typing the following:
cd ../bin
chmod 750 *.sh
This signifies read, write, and execute permissions for the owner, read and execute permissions for the group, and no permissions for others.

5) Test Tomcat

If Tomcat is running successfully following step 4, above, you should be able to see the Tomcat Welcome page at the following URL:

6) Shut down Tomcat

To shut down Tomcat type the following from the ./bin directory where Tomcat was installed (/Library/Tomcat/Home following the steps on this page):
./shutdown.sh

7) Running Tomcat as a service daemon

Mac OS X introduced launchd as the system-wide service management framework when Mac OS X 10.4 Tiger was released. Since then lanuchd succeeded traditional cron job management as the preferred way of daemonise system services on Mac OS X.
With the previous setup, to start up Tomcat while booting:
1. Create a script as [Tomcat home]/bin/tomcat-launchd.sh to start Tomcat as a non-daemonised process:
#!/bin/sh
#
# Wrapper for running Tomcat under launchd
# Required because launchd needs a non-daemonizing process
function shutdown()
{
        $CATALINA_HOME/bin/shutdown.sh
        /bin/rm $CATALINA_PID}
function wait_for_death()
{
        while /bin/kill -0 $1 2> /dev/null ; do
                sleep 2 
        done
}
export CATALINA_PID=$CATALINA_HOME/logs/tomcat.pid
$CATALINA_HOME/bin/startup.sh
trap shutdown QUIT ABRT KILL ALRM TERM TSTP
sleep 2
wait_for_death `cat $CATALINA_PID`
2. Create a launchd plist at /Library/LaunchDaemons/org.apache.tomcat.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>org.apache.tomcat</string>
        <key>Disabled</key>
        <false/>
        <key>OnDemand</key>
        <false/>
        <key>RunAtLoad</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
                <string>/Library/Tomcat/bin/tomcat-launchd.sh</string>
        </array>
        <key>EnvironmentVariables</key>
        <dict>
                <key>CATALINA_HOME</key>
                <string>/Library/Tomcat</string>
                <key>JAVA_OPTS</key>
                <string>-Djava.awt.headless=true</string>
        </dict>
        <key>StandardErrorPath</key>
        <string>/Library/Tomcat/logs/tomcat-launchd.stderr</string>
        <key>StandardOutPath</key>
        <string>/Library/Tomcat/logs/tomcat-launchd.stdout</string>
        <key>UserName</key>
        <string>_appserver</string>
</dict>
</plist>
3. Load the launchd process by
$ sudo launchctl load /Library/LaunchDaemons/org.apache.tomcat.plist
You can replace the load subcommand as unloadstopstart to remove Tomcat from startup processes, stop or start it, respectively.
Please also note that, the sample launchd plist assume the service will run as the user _appserver, which is predefined on Mac OS X for running app services. So you'll have to make sure the Tomcat directories and IPT data directories are owned, writable and executable by_appserver. Or, please refer to this page.

8) References

For more thorough descriptions of Tomcat configuration on Mac OS X, also consult these sources: