Saturday, March 17, 2012

Ant target to start axis2 server

Here i will describe how to write ant target to start apache axis2 server directly from your "build.xml" file without calling any shell script file. For this purpose we use "org.apache.axis2.transport.SimpleAxis2Server" class and pass it few arguments to tell it about our configuration files and service folder path.

First let us add locations to class path.
(here the ${axis-homerefers to the root of your apache axis2 directory.)



<path id="axis-classpath">
 <pathelement location="${axis-home}"/>
 <pathelement location="${axis-home}/conf"/>
 <pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
 <fileset dir="${axis-home}/lib">
  <include name="*.jar"/>
 </fileset>
</path>

with adding those paths to the class path let us write ant target to start axis2 server like below.


<target name="start-axis">
 <java classname="org.apache.axis2.transport.SimpleAxis2Server" fork="true">
  <classpath refid="axis-classpath" /> 
  <jvmarg value="-Djava.endorsed.dirs=${axis-home}/lib/endorsed;${env.JAVA_HOME}/jre/lib/endorsed;${env.JAVA_HOME}/lib/endorsed" />
  <arg line="-repo ${axis-home}/repository"/>
  <arg line="-conf ${axis-home}/conf/axis2.xml"/>
 </java>
</target>


Here we pass a jvm argument stating all the endorsed folder paths and two runtime arguments which are the location for service repository and path to axis configuration file.

1 comment:

  1. I sincerely hope that you did not send me the link of this blog expecting me to be a regular reviewer !!! :P

    ReplyDelete