Discussions

EJB programming & troubleshooting: XDoclet and EJB Configuration ?

  1. XDoclet and EJB Configuration ? (4 messages)

    Hi everyone:

         I don't know whether anyone have done this successfully.But I can't create any interface code using XDoclet ! I write a simple SessionBean according to onjava's example.But it can't work. My code is:

    <?xml version="1.0"?>

    <project name="lyopro" default="build" basedir=".">
       <property name="src" location="${basedir}/src"/>
       <property name="xdoclet.dir" location="../Xdoclet/lib"/>
       <target name="init">
          <mkdir dir="build"/>
       </target>
       <target name="build" depends="init">
          <taskdef name="ejbdoclet" classname="xdoclet.modules.ejb.EjbDocletTask">
    <classpath>
    <fileset dir="${xdoclet.dir}" includes="*.jar"/>
    </classpath>
          </taskdef>
    <ejbdoclet destdir="${src}" ejbspec="2.0">
    <fileset dir="${src}">
    <include name="*.java"/>
    </fileset>
    <remoteinterface/>
    <homeinterface/>
    <deploymentdescriptor destdir="build/ejb/MATA-INF"/>
    </ejbdoclet>
       </target>
    </project>

    my EJB code is:

    package lyo.hotmail;

    import javax.ejb.*;

    /*
    * @ejb.bean name="logonBean"
    * type="Stateless"
    * view-type="both"
    * jndi-name="lyo/logon"
    */
    public class TestBean implements SessionBean
    {
    SessionContext sc=null;
    private String name=null;
            public void setSessionContext(SessionContext cs){}
    /*
    * @ejb.create-method
    */
            public void create(){}
    public void ejbCreate(){}
    public void ejbRemove(){}
    public void ejbLoad(){}
    public void ejbStore(){}
    public void ejbPassivate(){}
    public void ejbActivate(){}
            
    /*
    * @ejb.interface-method view-type="remote"
    */
    public void setName(String name){
    this.name=name;
    }
    /*
    * @ejb.interface-method view-type="remote"
    */
    public String getName(){
    return this.name;
    }

    }
    I can't get any home or remote interface file after I run it!
    WHy?
    Help me! :(
  2. Hi you can use maven:genapp to generate you a template EJB.
  3. I want to use Ant[ Go to top ]

    Thank you for your reply:

       But what I want to know is how to do this using ant. Is there any error in my code or build.xml ?
  4. I want to use Ant[ Go to top ]

    Not sure if you missed this or not

    <deploymentdescriptor destdir="build/ejb/MATA-INF"/>

    should be
    <deploymentdescriptor destdir="build/ejb/META-INF"/>
  5. ejb-jar.xml is created by xdoclet but there is not any content about my ejb in it.
    ejb-jar.xml
    [code]
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

    <ejb-jar >

       <description><![CDATA[No Description.]]></description>
       <display-name>Generated by XDoclet</display-name>

       <enterprise-beans>

          <!-- Session Beans -->
         <!--
           To add session beans that you have deployment descriptor info for, add
           a file to your XDoclet merge directory called session-beans.xml that contains
           the <session></session> markup for those beans.
         -->

          <!-- Entity Beans -->
         <!--
           To add entity beans that you have deployment descriptor info for, add
           a file to your XDoclet merge directory called entity-beans.xml that contains
           the <entity></entity> markup for those beans.
         -->

          <!-- Message Driven Beans -->
         <!--
           To add message driven beans that you have deployment descriptor info for, add
           a file to your XDoclet merge directory called message-driven-beans.xml that contains
           the <message-driven></message-driven> markup for those beans.
         -->

       </enterprise-beans>

       <!-- Relationships -->

       <!-- Assembly Descriptor -->
       <assembly-descriptor >
         <!--
           To add additional assembly descriptor info here, add a file to your
           XDoclet merge directory called assembly-descriptor.xml that contains
           the <assembly-descriptor></assembly-descriptor> markup.
         -->

       <!-- transactions -->

       <!-- finder transactions -->
       </assembly-descriptor>

    </ejb-jar>
    [/code]

    Why? I change xdoclet to 1.1,1.0 and ant to 1.5 but it remain can't do this property. :(