Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Hi all,

 below is a sample on how to use maven2 together with xdoclet plugin for generating

an EJB 2.1 webservices.

The code uses jboss WebServices implementation, and i have deployed successfully this code

on jboss 4.0.3 and 4.0.4.GA, although with some small tweak on jboss..

I'll let users see how it goes and if you have any problem please mail me back

at mmistroni@gmail.com  

Here i post only EJB source code and relevant part of pom.xml because project is confidential.

 Here's EJB code

----

Code Block
/**

 * @ejb.bean

 *        name="TServiceSession"

 *        view-type="service-endpoint"

 *        local-jndi-name="mm/ws/ejb/TranslationServiceSessionLocalHome"

 *

 *

 * @ejb.interface

 *                generate="service-endpoint"

 *                service-endpoint-class="com.mm.webservices.TranslationService"

 *

 * @wsee.port-component name="TranslationServicePort"

 *

 *   here i show some ejb ref, in case you need to

*

 * @ejb.ejb-ref

 *            ejb-name="SiteTransmissionType"

 *            ref-name="ejb/SiteTransmissionTypeLocalHome"

 *

 * @jboss.ejb-local-ref

 *             ref-name="SiteTransmissionTypeLocalHome"

 *             jndi-name="mytests/SiteTransmissionTypeLocalHome"

 *

 */

public class TServiceSessionBean implements javax.ejb.SessionBean {



     /**

     * @ejb.create-method

     */

    public void ejbCreate() throws javax.ejb.CreateException {
    }
    /*\*
     * ejbActivate
     \*/
    public void ejbActivate() {    } }

    /**

     * ejbPassivate

     */

    public void ejbPassivate() {
    }
    /*\*
     * ejbRemove
     \*/
    public void ejbRemove() {    } }

    /**

     * @ejb.interface-method view-type="all"

     *

     *

     * Receives a transmission from

     * client

     * @param siteRef

     * @param interfaceType

     * @return

     * @throws TranslationServiceException

     */

    public Transmission receiveTransmission(String SiteRef,

                                                                int interfaceType)

                                                      throws TranslationServiceException {



     ..... MORE CODE HERE .....

}

and here's pom.xml i am using.
In the same pom.xml i am also generating a client for my webservice, but due to xdoclet limitation

when invoking it in multiprojects, i had to write an ant task in order to generate client

Here's pom.xml

********************************

Code Block
<plugins>

      <plugin>

        <groupId>org.codehaus.mojo</groupId>

        <artifactId>xdoclet-maven-plugin</artifactId>

        <executions>

          <execution>

            <id>generateSources</id>

            <phase>generate-sources</phase>

            <goals>

              <goal>xdoclet</goal>

            </goals>

            <configuration>

              <tasks>

                <ejbdoclet destDir="${project.build.directory}/generated-sources/xdoclet"
                                excludedTags="@author,@version"
                                ejbSpec="2.1">
                                dir="ejbModule"
                                includes="**/*Bean.java" />
                 <homeinterface destDir="${project.build.directory}/generated-sources/xdoclet">
                <localhomeinterface destDir="${project.build.directory}/generated-sources/xdoclet"/>
                <deploymentdescriptor destDir="${project.build.outputDirectory}/META-INF"
                                                useIDs="true"/>
                                                destDir="${project.build.outputDirectory}/META-INF"/>

                <jboss version="4.0"

                        destDir="${project.build.outputDirectory}/META-INF"
                        dataSource="${mw.dataSource}"
                        datasourceMapping="Hypersonic SQL"
                        createTable="true"
                        removeTable="true"/>         </ejbdoclet>
          </tasks>
         </configuration>
       </execution>

     </executions>
      </plugin>

          <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
             <execution>
              <id>antTask</id>
              <phase>process-classes</phase>
              <goals>
              <goal>run</goal>
              </goals>
              <configuration>
               <tasks>
          <taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools">
              <classpath refid="maven.dependency.classpath"/>

                  <classpath>
                      <fileset dir="${jboss.libdir}\client">
                    <include name="activation.jar"/>
                    <include name="javassist.jar"/>
                    <include name="jboss-common-client.jar"/>
                    <include name="jbossretro-rt.jar"/>
                    <include name="jboss-backport-concurrent.jar"/>
                    <include name="jbossws-client.jar"/>
                    <include name="jboss-xml-binding.jar"/>
                    <include name="concurrent.jar"/>
                    <include name="log4j.jar"/>
                    <include name="mail.jar"/>
                    <include name="wsdl4j.jar"/>

                </fileset>
                <fileset dir="${jboss.libdir}\lib\endorsed">
                    <include name="*.jar"/>
                </fileset>

            </classpath>
            </taskdef>
            <taskdef name="wsclient" classname="org.jboss.ws.tools.ant.wstools">
            <classpath>
                <fileset dir="${jboss.libdir}\client">
                    <include name="activation.jar"/>
                    <include name="javassist.jar"/>
                    <include name="jboss-common-client.jar"/>
                    <include name="jbossretro-rt.jar"/>
                    <include name="jboss-backport-concurrent.jar"/>
                    <include name="jbossws-client.jar"/>
                    <include name="jboss-xml-binding.jar"/>
                    <include name="concurrent.jar"/>
                    <include name="log4j.jar"/>
                    <include name="mail.jar"/>
                    <include name="wsdl4j.jar"/>
                </fileset>
                <fileset dir="${jboss.libdir}\lib\endorsed">
                    <include name="*.jar"/>
                </fileset>

            </classpath>
            </taskdef>
                <echo message="**** copying resources ******"/>
                <copy toDir="${project.build.outputDirectory}/resources">
                           <fileset dir="ejbModule/resources"/>
              </copy>

                <echo message="********** Running jboss ws **************"/>
          <wstools dest="${project.build.outputDirectory}/META-INF"
                      config="${workspace.dir}/mware/${myproject}/jboss/wstools-messenger-config.xml"/>

                  <wstools dest="${project.build.outputDirectory}/META-INF"
                      config="${workspace.dir}/mware/${myproject}/jboss/wstools-translation-config.xml"/>


          <copy toDir="${basedir}/client">
              <fileset dir="${project.build.outputDirectory}/META-INF">
                  <include name="**/*mapping.xml"/>
              </fileset>
              <fileset dir="${project.build.outputDirectory}/META-INF/wsdl">
                  <include name="**/*.wsdl"/>
              </fileset>
          </copy>
          <copy toDir="../mwclient/src/main/resources">
            <fileset dir="${project.build.outputDirectory}/META-INF">
                <include name="**/*mapping.xml"/>
            </fileset>
            <fileset dir="${project.build.outputDirectory}/META-INF/wsdl">
                <include name="**/*.wsdl"/>
            </fileset>
          </copy>

          <echo message="********** Generating client.. **************"/>
          <wsclient dest="mwclient/src/main/java"
                   config="${workspace.dir}/mware/${myproject}/client/wstools-messenger-client-config.xml"/>
          <wsclient dest="mwclient/src/main/java"
                    config="${workspace.dir}/mware/${myproject}/client/wstools-translation-client-config.xml"/>

         </tasks>
              </configuration>
             </execution>
           </executions>

     </plugin>



----and below is one of the wstool*config i am using, in case you need it

*************************************************

<configuration xmlns="http://www.jboss.org/jbossws-tools">



    <wsdl-java file="${myProject}/client/MessengerService.wsdl">

            <mapping file="mss-mapping.xml"/>

    </wsdl-java>



</configuration>



 As yoiu have noticed , i first generate the config file using wstools


         <echo message="********* Running jboss ws *************"/>

          <wstools dest="${project.build.outputDirectory}/META-INF"
                      config="${workspace.dir}/mware/${myProject}/jboss/wstools-messenger-config.xml"/>


 then i copy it into the 'client directory

              <copy toDir="${basedir}/client">

              <fileset dir="${project.build.outputDirectory}/META-INF">

                  <include name="**/*mapping.xml"/>

              </fileset>

              <fileset dir="${project.build.outputDirectory}/META-INF/wsdl">

                  <include name="**/*.wsdl"/>

              </fileset>

          </copy>

  And then i generate the client artifact



<echo message="********* Generating client.. *************"/>

          <wsclient dest="mwclient/src/main/java"
                   config="${workspace.dir}/mware/ngenMiddleware/client/wstools-messenger-client-config.xml"/>

My directory structure (if you are interested in generating client) is

mware
!___ my project (all ejbs here) |__ client |__ src/main/java

!_____mwclient 

I hope you can get along well with this sample....

i'd post whole project,but since it is confidential i had to break it down..so i m expecting that you might have a problem in generating client artifact...due to directory structure......
the EJB par twill work fine though..

If you find any problems, mail me privately at mmistroni@gmail.comEnjoy!! Marco

PS sorry for my poor wiki-editing skills