Hi,

I am new to both axis and Maven, so if there is an easier route to do what follows, advice is very welcomed.

I ran into some issues while adding a "deploy" goal to the sourceforge axis maven plugin from sourceforge
(http://maven-plugins.sourceforge.net/)


The main issue is that maven passes unspecified properties as empty strings (rather than null strings) to the ant task, this causes lots or trouble:

1) The addArgs method in AdminClientTask checks only for null strings not empty strings before adding the argument (so all unspecified properties are added!).
2) When an empty string is added, the org.apache.axis.utils.Options.isValueSet method fails, as it assumes the character array is larger than it is.


 At the end of the message I provide a sample stack trace of the problem

I am not sure how to get around this, I cannot supply default values for all properties, some conflict with others.

A minor issue, due probably to poor configuration on my part, prevents BuildExceptions from being displayed by Maven, every time there an exception is thrown by the task, Maven reports (I am using catch to get the exception)

[echo] org.apache.commons.jelly.JellyTagException: e:\.maven\cache\maven-axi
s-plugin-0.5\plugin.jelly:207:40: <axis-admin> Exception in axis-admin


 But neither the exception stack trace nor message are shown.

To get around both issues I made these simple modifications to the class (see AdminClientTask.patch)

If people are curious, attached is the plugin.jelly file (which is a modified version of the one in the maven-plugins project mentioned above).

 Again, if there are simple ways of doing this, I'd appreciate your help.

 Manuel

Sample Stack Trace
[axis-admin] java.lang.String.charAt(String.java:444)
[axis-admin] org.apache.axis.utils.Options.isValueSet(Options.java:161)
[axis-admin] org.apache.axis.utils.Options.getURL(Options.java:236)
[axis-admin] org.apache.axis.utils.Options.<init>(Options.java:65)
[axis-admin] org.apache.axis.client.AdminClient.process(AdminClient.java:280)
[axis-admin] org.apache.axis.tools.ant.axis.AdminClientTask.execute(AdminClientTask.java:277)
[axis-admin] org.apache.tools.ant.Task.perform(Task.java:341)
[axis-admin] org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:232)
[axis-admin] org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
[axis-admin] org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
[axis-admin] org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
[axis-admin] org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:145)
[axis-admin] org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
[axis-admin] org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
[axis-admin] org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
[axis-admin] org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:88)
[axis-admin] org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
[axis-admin] org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
[axis-admin] org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:79)
[axis-admin] org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:110)
[axis-admin] com.werken.werkz.Goal.fire(Goal.java:639)
[axis-admin] com.werken.werkz.Goal.attain(Goal.java:575)
[axis-admin] com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
[axis-admin] org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:634)
[axis-admin] org.apache.maven.MavenSession.attainGoals(MavenSession.java:266)
[axis-admin] org.apache.maven.cli.App.doMain(App.java:486)
[axis-admin] org.apache.maven.cli.App.main(App.java:1215)
[axis-admin] sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[axis-admin] sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[axis-admin] sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[axis-admin] java.lang.reflect.Method.invoke(Method.java:324)
[axis-admin] com.werken.forehead.Forehead.run(Forehead.java:551)
[axis-admin] com.werken.forehead.Forehead.main(Forehead.java:581)



Index: AdminClientTask.java
===================================================================
RCS file: 
/home/cvspublic/ws-axis/java/tools/org/apache/axis/tools/ant/axis/AdminClientTask.java,v
retrieving revision 1.9
diff -w -r1.9 AdminClientTask.java
221d220
< 
223,224c222,224
<         addArgs("-l", url, url != null);
<         addArgs("-h", hostname, hostname != null);
---
> 
>         addArgs("-l", url, isNotEmpty(url));
>         addArgs("-h", hostname, isNotEmpty(hostname));
226,230c226,230
<         addArgs("-s", servletPath, servletPath != null);
<         addArgs("-f", fileProtocol, fileProtocol != null);
<         addArgs("-u", username, username != null);
<         addArgs("-w", password, password != null);
<         addArgs("-t", transportChain, transportChain != null);
---
>         addArgs("-s", servletPath, isNotEmpty(servletPath));
>         addArgs("-f", fileProtocol, isNotEmpty(fileProtocol));
>         addArgs("-u", username, isNotEmpty(username));
>         addArgs("-w", password, isNotEmpty(password));
>         addArgs("-t", transportChain, isNotEmpty(transportChain));
231a232
>         log("Added arguments ....");
248d248
< 
271a272
>             log("failed to start the axis engine"+e);
279a281
>                 log(getTaskName() + " got a null response");
290a293
>             log("build exception "+e.getMessage());
292a296,299
>             StackTraceElement [] stack = e.getStackTrace();
>             log("Unknown Exception "+ e.getMessage() + "\n");
>             for(int i = 0; i < stack.length; i++)
>                 log(stack[i].toString());
343a351
>         log("addArgs argument<"+argument+"> param<"+param+"> test<"+test+">");
346a355
>             log("Added -- "+argument + " - "+param);
349a359,362
>     private boolean isNotEmpty(String s) {
>         return s != null && s.length() > 0;
>     }
> 

<?xml version="1.0" encoding="UTF-8"?>

<project
  xmlns:j="jelly:core"
  xmlns:ant="jelly:ant"
  xmlns:maven="jelly:maven"
  xmlns:u="jelly:util">

  <!-- global definitions -->
  <ant:path id="axis.classpath">
    <ant:pathelement path="${plugin.getDependencyPath('axis:axis')}"/>
    <ant:pathelement path="${plugin.getDependencyPath('axis:axis-ant')}"/>
    <ant:pathelement path="${plugin.getDependencyPath('xerces:xerces')}"/>
    <ant:pathelement path="${plugin.getDependencyPath('xerces:xercesImpl')}"/>
    <ant:pathelement path="${plugin.getDependencyPath('xml-apis')}"/>
    <ant:pathelement path="${plugin.getDependencyPath('jaxrpc')}"/>
    <ant:pathelement path="${plugin.getDependencyPath('saaj')}"/>
  </ant:path>

  <ant:taskdef classpath="${plugin.getDependencyPath('axis:axis-ant')}" resource="axis-tasks.properties" />

  <j:set var="axis.build.dir"
    value="${maven.axis.build.dir}" />

  <j:set var="axis.generated.dir"
    value="${maven.axis.generated.dir}" />

  <j:set var="axis.url"
    value="${maven.axis.url}" />
    
  <j:set var="axis.wsdd.url"
  	value="${maven.axis.wsdd.url}"/>

  <!-- ================================================================== -->
  <!-- P R E P A R E  F I L E  S Y S T E M                                -->
  <!-- ================================================================== -->
  <goal name="axis:prepare-filesystem"
    description="Create the directory structure needed.">
    <ant:mkdir dir="${axis.generated.dir}"/>
    <ant:mkdir dir="${axis.build.dir}"/>

    <!-- move generated test cases to the maven.axis.test.dir -->
    <j:if test="${maven.axis.testcase}">
      <ant:mkdir dir="${maven.axis.test.dir}"/>
    </j:if>

  </goal>

  <!-- ================================================================== -->
  <!-- A X I S                                                            -->
  <!-- ================================================================== -->
  <goal name="axis:axis" description="generate java files from wsdl definitions."
    prereqs="axis:prepare-filesystem">

    <j:catch var="ex">
      <j:set var="wsdlSource" value="${axis.url}" />
      <j:set var="wsdlPostfix" value=".wsdl" />
      <j:if test="${!wsdlSource.endsWith(wsdlPostfix)}">
        <ant:echo>find all .wsdl files in directory ${axis.url}</ant:echo>
        <!-- find all wsdl files -->
        <ant:fileScanner var="wsdlFiles">
          <ant:fileset dir="${axis.url}">
            <ant:include name="**/*.wsdl" />
          </ant:fileset>
        </ant:fileScanner>

        <!-- generate the java files for each wsdl file -->
        <j:forEach var="wsdlFile" items="${wsdlFiles.iterator()}">
          <ant:echo>generate .java files from ${wsdlFile}</ant:echo>
          <!-- wsdl2java -->
          <axis-wsdl2java
            all="${maven.axis.all}"
            output="${axis.generated.dir}"
            testcase="${maven.axis.testcase}"
            verbose="${maven.axis.verbose}"
            deployscope="${maven.axis.deployscope}"
            skeletondeploy="${maven.axis.skeletondeploy}"
            noimports="${maven.axis.noimports}"
            typemappingVersion="${maven.axis.typemappingversion}"
            serverside="${maven.axis.serverside}"
            url="${wsdlFile}">
          </axis-wsdl2java>

          <!-- mapping of namespaces to package names -->
          <u:tokenize var="urnMappings" delim=",">${maven.wsdl2java.namespaceMappings}</u:tokenize>
          <j:forEach var="urnMapping" items="${urnMappings}">
            <u:tokenize var="keyValue" delim="=">${urnMapping}</u:tokenize>
            <mapping namespace="${keyValue[0]}" package="${keyValue[1]}"/>
          </j:forEach>

        </j:forEach>
      </j:if>
      <j:if test="${wsdlSource.endsWith(wsdlPostfix)}">
        <ant:echo>generate .java files from ${axis.url}</ant:echo>
        <!-- wsdl2java -->
        <axis-wsdl2java
          all="${maven.axis.all}"
          output="${axis.generated.dir}"
          testcase="${maven.axis.testcase}"
          verbose="${maven.axis.verbose}"
          deployscope="${maven.axis.deployscope}"
          skeletondeploy="${maven.axis.skeletondeploy}"
          noimports="${maven.axis.noimports}"
          typemappingVersion="${maven.axis.typemappingversion}"
          serverside="${maven.axis.serverside}"
          url="${axis.url}">

          <!-- mapping of namespaces to package names -->
          <u:tokenize var="urnMappings" delim=",">${maven.wsdl2java.namespaceMappings}</u:tokenize>
          <j:forEach var="urnMapping" items="${urnMappings}">
            <u:tokenize var="keyValue" delim="=">${urnMapping}</u:tokenize>
            <mapping namespace="${keyValue[0]}" package="${keyValue[1]}"/>
          </j:forEach>

        </axis-wsdl2java>
      </j:if>

      <!-- move generated test cases to the maven.axis.test.dir -->
      <j:if test="${maven.axis.testcase}">
        <ant:echo>move the generated testcases to folder ${maven.axis.test.dir}</ant:echo>

        <ant:move todir="${maven.axis.test.dir}">
          <ant:fileset dir="${maven.axis.generated.dir}">
            <ant:include name="**/*TestCase*"/>
          </ant:fileset>
        </ant:move>
      </j:if>

    </j:catch>
    <j:if test="${ex != null}">
      <ant:echo>${ex}</ant:echo>
      <ant:fail message="${ex}" />
    </j:if>
  </goal>

  <!-- ================================================================== -->
  <!-- C O P Y                                                            -->
  <!-- ================================================================== -->
  <goal name="axis:copy"
    description="Copies the generated java files into a separate build directory."
    prereqs="axis:axis">

    <ant:copy todir="${axis.build.dir}">
      <ant:fileset dir="${axis.generated.dir}">

        <!-- ignore implementation classes -->
        <u:tokenize var="impls" delim=";">${maven.axis.excludes}</u:tokenize>
        <j:forEach var="impl" items="${impls.iterator()}">
          <ant:echo>exclude class ${impl}</ant:echo>
          <ant:exclude name="${impl}"/>
        </j:forEach>

      </ant:fileset>
    </ant:copy>

  </goal>

  <!-- ================================================================== -->
  <!-- C O M P I L E                                                      -->
  <!-- ================================================================== -->
  <goal name="axis:compile"
    description="Compile the generated .java files."
    prereqs="axis:copy">

    <ant:path id="axis.src.set">
      <ant:pathelement location="${maven.axis.build.dir}" />
    </ant:path>

    <ant:echo>adding ${maven.axis.generated.dir} to the maven.compile.src.set</ant:echo>
    <maven:addPath id="maven.compile.src.set" refid="axis.src.set"/>

  </goal>
  
  <!-- ================================================================== -->
  <!-- DEPLOY															  -->
  <!-- ================================================================== -->
  <goal name="axis:deploy"
  		description="Deploy all .wsdd files to Application Server">
  		
    <j:catch var="ex">
      <j:set var="wsddSource" value="${axis.wsdd.url}" />
      <j:set var="wsddPostfix" value=".wsdd" />      
      <j:if test="${!wsddSource.endsWith(wsddPostfix)}">
        <ant:echo>find all *deploy.wsdd files in directory ${wsddSource}</ant:echo>
        <!-- find all wsdd files -->
        <ant:fileScanner var="wsddFiles">
          <ant:fileset dir="${wsddSource}">
            <ant:include name="**/*deploy.wsdd" />
          </ant:fileset>
        </ant:fileScanner>
        
        <!-- generate the java files for each wsdl file -->
        <j:forEach var="wsddFile" items="${wsddFiles.iterator()}">
          <ant:echo>Register service from ${wsddFile}</ant:echo>
          <!-- axis admin -->
          <axis-admin
          	xmlFile="${wsddFile}"
          	failOnError="${maven.axis.failonerror}"
          	hostName="${maven.axis.admin.hostname}"
          	port="${maven.axis.admin.port}"
          	servletPath="${maven.axis.admin.servletpath}"
          	url="${maven.axis.admin.url}"
          	transportChain="${maven.axis.transportchain}"
          	username="${maven.axis.admin.username}"
          	password="${maven.axis.admin.password}"
          	fileProtocol="${maven.axis.fileprotocol}"
          	debug="${maven.axis.debug}">
          </axis-admin>
        </j:forEach>
      </j:if>
      
      <j:if test="${wsdlSource.endsWith(wsddPostfix)}">
        <ant:echo>generate .java files from ${wsddSource}</ant:echo>
        <!-- axis admin -->
          <axis-admin
          	xmlFile="${wsddSource}"
          	failOnError="${maven.axis.failonerror}"
          	hostName="${maven.axis.admin.hostname}"
          	port="${maven.axis.admin.port}"
          	servletPath="${maven.axis.admin.servletpath}"
          	url="${maven.axis.admin.url}"
          	transportChain="${maven.axis.transportchain}"
          	username="${maven.axis.admin.username}"
          	fileProtocol="${maven.axis.fileprotocol}"
          	debug="${maven.axis.debug}">
          </axis-admin>
      </j:if>

    </j:catch>
    <j:if test="${ex != null}">
      <ant:echo>${ex}</ant:echo>
      <ant:fail message="${ex}" />
    </j:if>
  </goal>	  		

  <!-- ================================================================== -->
  <!-- D E F A U L T  G O A L                                             -->
  <!-- ================================================================== -->
  <goal name="axis"
    description="Generate java files from wsdl definitions and compile them."
    prereqs="axis:compile"
    />

</project>

Reply via email to