Following is the Quick Start Guide for using Maven 2 for the Web Service
(1) Download Maven 2 from http://maven.apache.org/download.html by selecting proper file for your machine platform
(2) Unpack the archive, eg: tar zxvf maven-2.0.tar.gz or unzip maven-2.0.zip. A directory called "maven-2.0" will be created.
(3) Add the bin directory to your PATH, eg: export PATH=/usr/local/maven-2.0/bin:$PATH or set PATH="c:\program files\maven-2.0\bin";%PATH%
(4) Make sure JAVA_HOME is set to the location of your JDK
(5) Run "mvn --version" to verify that it is correctly installed
(6) Now create Web application project by running following command
mvn archetype:create -DgroupId=example1 -DartifactId=portlet1 -DarchetypeArtifactId=maven-archetype-webapp
This command will create a new project called "portlet1" specifically for web application
(7) create folder "java" under portlet1/src/main and put all the .java files under this folder
(8) To compile the java file you may need some jar files. you can specify the jar files in pom.xml file located under portlet1 directory. when you specify particular jar file in pom.xml file, during compilation it will search that file first in http://www.ibiblio.org/maven2/(ibiblio repository). If that file is not available in ibiblio repository it will try to find out in local repository.
(9) If you want to specify the jar file required during compilation and available in ibiblio repository, add following lines in pom.xml file
<dependency>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<scope>compile</scope>
</dependency>
E.g If you want to specify "antlr2.7.1.jar" file in pom.xml then follow this link of ibiblio repository http://www.ibiblio.org/maven2/antlr/antlr/2.7.1/antlr-2.7.1.pom and copy following three tags from .pom file under dependency tag.
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.1</version>
(10) Another possibility is, if your required jar file is not available under ibiblio repository.you can either copy that jar file into local repository or can
create remote repository. To copy the jar file into local repository you can use following command at local repository directory(~/.m2/repository in unix).
E.g. mvn install:install-file -Dfile= jar file location -DgroupId= -DartifactId= -Dversion= -Dpackaging= jar
(11) you can create a remote repository by installing all the required jar files by using above mentioned command directly to server's/webapps(E.g tomcat server/webapps/CICC) folder and can access it via URL.
E.g http://gf8.ucs.indiana.edu:9080/CICC
(12)when you are going to use jar files from remote repository you have to mention it in pom.xml file like this
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://www.ibiblio.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://gf8.ucs.indiana.edu:9080/CICC</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
(13) When you have all the required jar files for compilation of java files then you can compile all the java files by using "mvn compile" command
(14) To create war file for this project run "mvn install" command
(15) Put war file under server's/webapps folder and restart the server
(16) To make a web service you must have all the other required files from axis folder. Copy all the required files example server-config.wsdd etc from axis folder. Restart the server. Deploy web service by command java org.apache.axis.client.Adminclient deploy.wsdd
for more details follow Axis tutorial on how to deploy a web service.
(17) restart the server. and you will be able to see the deployed web service
Monday, April 03, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment