Deploying your First Custom Web Application
The WSO2 Application Server supports Apache Tomcat based Web application deployment. All you need to do is to bundle your Web application as a .war
archive with all your Web application related resources and all third-party libraries, and then deploy the archive. This sample demonstrates how you can get started quickly with WSO2 Application Server, by deploying your custom web application.
Using Maven
Apache Maven 3 is recommended to build the samples.
Follow the steps given below before you build and run the sample.
Remove the following parent POM reference from the
pom.xml
file, which is stored in the<AS_HOME>\samples\
directory.<parent> <groupId>org.wso2.appserver</groupId> <artifactId>wso2appserver-samples-parent</artifactId> <version>5.2.1</version> </parent>
Note that this step is necessary because of a known issue, which will be fixed in AS 6.0.0.
As shown below, add the
<version>
and<groupid>
elements to the samepom.xml
file, after the parent element which you commented out in the first step.<groupId>org.wso2.appserver</groupId> <version>5.2.1</version>
Open the pom.xml for the HelloWorldWebapp sample from
<AS_HOME>/samples/HelloWorldWebapp/
directory and add the following repository details.<repositories> <repository> <id>wso2-nexus</id> <name>WSO2 internal Repository</name> <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url> <releases> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> <checksumPolicy>ignore</checksumPolicy> </releases> </repository> </repositories>
Go to the
<AS_HOME>/samples/pom.xml
file and copy the value given for the<javax.servlet.jsp.version>
property. Then, add this version value to the<AS_HOME>/samples/HelloWorldWebapp/pom.xml
file, as shown below.<dependencies> <dependency> <groupId>org.eclipse.equinox</groupId> <artifactId>javax.servlet.jsp</artifactId> <version>2.2.0.v201112011158</version> </dependency> </dependencies>
To build and run the sample:
- Open the maven
pom.xml
file, which is in the base directory of the sample (i.e.,<PRODUCT_HOME>\samples\HelloWorldWebapp
). Build the demo and create a WAR file using the following command.
mvn clean install
This will create the sample webapp WAR file (wso2appserver-samples-hello-webapp-1.0.war file) and copy it to<AS_HOME>/repository/deployment/server/webapps/
directory.- Start the WSO2 Application Server by following the instructions in Running the Product.
- You can now deploy the WAR file you created in step 2 above, using the management console as detailed here.
Using Apache Ant
You can find the sample discussed here in the <AS_HOME>/samples/HelloWorldWebapp
directory.
The steps are as follows:
- Run the WSO2 Application Server. For instructions see, Running the Product.
In a command prompt, switch to the samples directory.
For example, in Windows:cd <AS_HOME>\samples\HelloWorldWebapp
Enter the following command:
ant
This will copy the sample webapp (wso2appserver-samples-hello-webapp-1.0.war file) in to <AS_HOME>/repository/deployment/server/webapps/ directory. If you log into the Application Server, you will see the deployed webapp on the running applications window.