DeploymentOnExternalTomcatforNB6

Contents


Configuring an External Tomcat Server for Deployment

Introduction

In NetBeans 5.5 and 5.5.1, users deploying their Visual Web applications on the bundled Tomcat did not have to configure the server environment for their applications to deploy successfully. With the release of Tomcat 6, additional configuration steps would be required. This guide will show a step-by-step process on how to configure both the Tomcat 5.5 and 6.0 server environments, so that Web applications created in the NetBeans 6.0 IDE can deploy successfully.

Pre-requisites


Configuring Tomcat

J2EE 1.4 Projects

This section applies to NetBeans version 5.5, 5.5.1 and 6 (M9 Preview).

Although there are no extra steps required for J2EE 1.4 projects, it should be noted that if you are planning to deploy projects on certain Tomcat versions you need to make sure that the path at which you create your project should not have any spaces in it. For eg. It should be something like this: C:\projects\myTomcatProject rather than this C:\My Documents\My projects\project. Affected Tomcat versions include:

  • Tomact 5.5.20 to 5.5.23. (Should be fixed for Tomcat 5.5.24 and higher)
  • Tomcat 6.0.10 and below. (Fixed in Tomcat 6.0.13 and higher)

The reason behind this is because of a Tomcat bug introduced since version 5.5.20 due to which the server is unable to find jar files inside the Project.war/WEB-INF/lib/ folder if the project path contains spaces even though they may exist .

Since Netbeans uses in place deployment the deployed war file is placed where the project was created. As a result even if the Tomcat installation directory is placed at a path with no spaces you will still encounter problems unless the project itself is created at a path without spaces.

More information regarding this bug can be found right here : http://www.mail-archive.com/users@myfaces.apache.org/msg37427.html


Java EE 5 Projects

Note: This section applies to NetBeans 6.0 (M9 Preview).

This section is for users who are creating Java EE 5 applications on Tomcat 6. Tomcat versions 5.5.x and lower do not implement any or all of the Java EE 5 specification. Consequently the IDE does not allow Java EE 5 applications to be built on versions of Tomcat lower than Tomcat 6. It should also be mentioned here that Tomcat 6 implements only a subset (Servlet/JSP) of the full Java EE 5 specifications and thus is not a full Java EE5 server.


There are 2 ways through which you can successfully deploy Java EE 5 projects on Tomcat 6. The first one requires you to add the required libraries into your project and the other one requires you to add libraries to the server so that multiple web applications can use them.


A. Add Missing Libraries to your Project:


1. Since Java EE 5 uses JavaServer Faces 1.2 specification you need to download Sun's JSF 1.2 implementation.

2. Extract the contents of the zip file at a convenient location.

3. Next, in the IDE goto the Tools->Libraries menu item and select New Library...

4. Type "JSF1.2" as the Library Name and click OK.

5. With "JSF1.2" selected among the list of libraries click on Add JAR/Folder and browse to the location where you extracted the JSF RI and in the /jsf-1.2/lib/ folder, select the following 2 jar files :

  • jsf-api.jar
  • jsf-impl.jar

Select OK to add the new library as shown below. File:Library Dialog

6. Now Create a Java EE 5 project with target server set to Tomcat 6 and using the Visual Web JSF framework.

Note: Please make sure that if you are using Tomcat 6 versions 6.0.10 and below you need to create a project at a path which has no spaces in it. For more information on why you have to do this read the J2EE 1.4 section above. Tomcat 6.0.13 and subsequent versions do not require this since the bug has been fixed.


7. Once created the IDE will show source file errors in your source package as well as in Page1.java file as shown below. To resolve these errors we need to add the JSF1.2 library into the project. Expand your project node, right click on the Libraries folder and select Add Library... Select the recently created JSF1.2 library and add it to your project. The IDE will now scan the newly added library to resolve JSF references. File:Source File errors for Page1.java

8. Next we need to add the JavaServer Pages Standard Template Library to our project. Right click on your project and select properties. Select the Build->Packaging node and click on Add Library... Add the JSTL 1.1 library and specify the Path in WAR as WEB-INF/lib as shown below. Hit enter and then OK. We did not add this library to the libraries folder since we don't need it at compile time only at deployment. File:Adding JSTL1.1 Library

9. Now restart your IDE. Once IDE is restarted your recently created project should show no source file errors and you should be able to deploy your application without any problems.


B. Add Missing Libraries to the Server:

The following steps are usefull when you are planning to deploy multiple Java EE5 applications on the same Tomcat 6 server. Adding the missing libraries to the Tomcat lib folder allows these libraries to be shared among multiple applications, consequently saving space.

1. Download the binary distribution of Jakarta's implementation of the JavaServer Pages Standard Tag Library (JSTL) from: http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi

2. Extract the contents of the downloaded zip file. Once unzipped open this folder /jakarta-taglibs-standard-1.1.2/lib/ and copy these 2 jar files:

  • standard.jar
  • jstl.jar

3. Paste these 2 files in the lib folder of your Tomcat installation directory: This would be: /$TOMCAT/lib/

4. Since Java EE5 uses JavaServer Faces 1.2 specification you need to download Sun's JSF 1.2 implementation. These steps are necessary since currently Netbeans does not load the required JSF jars in an external Tomcat server.

5. Extract the zip file and copy all the files from the /jsf-1.2/lib/ folder and paste them in your Tomcat lib folder:

  • For Tomcat 6 this would be: /$TOMCAT/lib/

Be sure you copy all the files from the jsf lib folder. These include all the jar files as well as the dtds and tlds.

6. Now Create a Java EE 5 project with target server set to Tomcat 6 and using the Visual Web JSF framework.

Note: Please make sure that if you are using Tomcat 6 versions 6.0.10 and below you need to create a project at a path which has no spaces in it. For more information on why you have to do this read the J2EE 1.4 section above. Tomcat 6.0.13 and subsequent versions do not require this since the bug has been fixed.


Please note that if you create a Java EE 5 project on Tomcat 6 before going through the steps outlined above you will see source file errors in your java files and you won't be able to work with the design view. In case you follow these steps after creating a project you will have to restart the IDE for the Project to index those jars. If you are still seeing source file errors you might have to create a new project altogether.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo