8 Replies Latest reply on Jun 27, 2013 5:03 AM by jaikiran pai

    jboss tools - xdoclet/ejbdoclet question.

    prashant gandhi Newbie

      Hi,

      I am using eclipse Indigo 5. I have installed jboss AS 7.1.1.final and I can start/stop server incide eclipse. I have gone to eclipse marketplace and installed JBOSS TOOLS INDIGO from there. (If i go there again, i have "uninstall" option).

       

      I want to create a xdoclet/ejbdoclet now. how do i do this?

       

      Background:

      We have existing web application that uses ejb 2.0, ejbdoclets (i can see them in build.xml) and jboss 4.0.1sp1. My goal with primary knowledge in Java is to: upgrade JBOSS to 7.1.1.final, ejb 3.0 (or 3.1) and the application should still work as it works today.

       

      From internet, I understood that xdoclet / ejbdoclets are useful for creating ejb 3.0. In my build.xml I see ejbdoclets used.  Also, from internet I understood that JBOSS TOOLS (previously called: JBOSS-IDE, IDE is replaced with TOOLS) are used for creating xdoclets.

       

      So, i think i need to first understand how to use JBOSS TOOLS to create xdoclet. Then I should be creating ejb3 beans using xdoclet.

       

      Now as Wolf has mentioned that there are no EJB3.0 API available for JBOSS 4.0.1sp1, I think I will not be able to replace the beans first from ejb2 to ejb3 with existing JBOSS. Instead, I will have to simulatenously replace JBOSS from 4.0.1sp1 to 7.1.1.final and cross the hurdles as they arise.

       

      Any help is appreciated. I am using xdoclet and ejbdoclet interchangeably in above explanation, since I believe ejbdoclets are now obsoleted and xdoclet is a parent of both ejbdoclet and webdoclet. So, even though i see ejbdoclet in the current code (written back in 2004-2005), I will be using xdoclet not the ejbdoclet. Thank you.

        • 1. Re: jboss tools - xdoclet/ejbdoclet question.
          Wolf-Dieter Fink Master

          Hello again Prashant,

           

          there is no need to use XDoclet. With EJB3 you did not need to use that (javadoc)XDoclet annotations and the XDoclet tool.

          The annotations are made direct, i.e.

           

          @Stateless

          public class MyStatelessSessionBean implements MyStatelessSessionRemote { ...}

          @Remote

          public interface MyStatelessSessionRemote {}

           

          There are several examples in the JBoss Developer Framework

          • 2. Re: jboss tools - xdoclet/ejbdoclet question.
            prashant gandhi Newbie

            Thanks Wolf for a quick response.

             

            part of my build.xml looks like below:

             

            :

            :

              <target name="init-tasks">

                <taskdef

                  name="ejbdoclet"

                  classname="xdoclet.modules.ejb.EjbDocletTask"

                  classpathref="classpath"

                />    

              </target>

            :

            <target name="ejbdoclet" depends="generate-xml-wrappers, init-tasks">

                <ejbdoclet     

                   destdir="${generated.java.dir}"

                   excludedtags="@version,@author,@todo"

                   addedtags="@xdoclet-generated at ${TODAY},Copyright (c) 2004 ACNielsen.  All Rights Reserved.,@author Applied Visions Inc."

                   ejbspec="2.0">      

             

             

                   <fileset dir="${src.dir}">         

                      <include name="com/acnielsen/dtu/model/*/ejb/*Bean.java"/>

                      <exclude name="com/acnielsen/dtu/model/unixservice/**"/>

                   </fileset> 

                  

                   <packageSubstitution packages="model.jobconfigsession" substituteWith="common.interfaces" useFirst="true"/>        

                   <packageSubstitution packages="model.filelayoutsession" substituteWith="common.interfaces" useFirst="true"/> 

                   <packageSubstitution packages="model.fileservice" substituteWith="common.interfaces" useFirst="true"/> 

                   <packageSubstitution packages="model.jobservice" substituteWith="common.interfaces" useFirst="true"/> 

                   <packageSubstitution packages="model.loginservice" substituteWith="common.interfaces" useFirst="true"/>        

                   <packageSubstitution packages="model.userprofilesession" substituteWith="common.interfaces" useFirst="true"/>        

                   <packageSubstitution packages="model.validationservice" substituteWith="common.interfaces" useFirst="true"/>        

             

             

                   <remoteinterface/>

                   <homeinterface/>

                   <localinterface/>

                   <localhomeinterface/>

                  

                   <utilobject cacheHomes="true" kind="physical">

                    <packageSubstitution packages="model.jobconfigsession" substituteWith="common.util" useFirst="true"/>       

                    <packageSubstitution packages="model.filelayoutsession" substituteWith="common.util" useFirst="true"/>

                    <packageSubstitution packages="model.fileservice" substituteWith="common.util" useFirst="true"/>

                    <packageSubstitution packages="model.jobservice" substituteWith="common.util" useFirst="true"/>

                    <packageSubstitution packages="model.loginservice" substituteWith="common.util" useFirst="true"/>       

                    <packageSubstitution packages="model.userprofilesession" substituteWith="common.util" useFirst="true"/>                     

                    <packageSubstitution packages="model.validationservice" substituteWith="common.util" useFirst="true"/>                     

                   </utilobject>      

                  

                   <deploymentdescriptor destdir="${build.dir}/ejb/META-INF"/>

             

             

                   <jboss

                     version="4.0"

                     unauthenticatedPrincipal="nobody"

                     xmlencoding="UTF-8"

                     destdir="${build.ejb.dd}/META-INF"

                     validatexml="true"

                     preferredrelationmapping="relation-table"

                     mergedir="dd/merge"

                    />

                </ejbdoclet>

              </target> 

              <target name="ejbdoclet-unix" depends="init-tasks">

                <ejbdoclet     

                   destdir="${generated.java.dir}"

                   excludedtags="@version,@author,@todo"

                   addedtags="@xdoclet-generated at ${TODAY},Copyright (c) 2004 ACNielsen.  All Rights Reserved.,@author Applied Visions Inc."

                   ejbspec="2.0">      

             

             

                   <fileset dir="${src.dir}">         

                      <include name="com/acnielsen/dtu/model/unixservice/ejb/*Bean.java"/>

                   </fileset> 

                  

                   <packageSubstitution packages="model.unixservice" substituteWith="common.interfaces" useFirst="true"/> 

             

             

                   <remoteinterface/>

                   <homeinterface/>

                   <localinterface/>

                   <localhomeinterface/>

                  

                   <utilobject cacheHomes="true" kind="physical">      

                    <packageSubstitution packages="model.unixservice" substituteWith="common.util" useFirst="true"/>      

                   </utilobject>      

                  

                   <deploymentdescriptor destdir="${build.dir}/ejb-unix/META-INF"/>

             

             

                   <jboss

                     version="4.0"

                     unauthenticatedPrincipal="nobody"

                     xmlencoding="UTF-8"

                     destdir="${build.ejb-unix.dd}/META-INF"

                     validatexml="true"

                     preferredrelationmapping="relation-table"

                    />

                </ejbdoclet>

              </target>

             

            <!-- =================================================================== -->

              <!-- Compiles the source code                                            -->

              <!-- =================================================================== -->

              <target name="compile-ejb" depends="ejbdoclet, ejbdoclet-unix">

                        <javac srcdir="${src.dir}" destdir="${build.classes.dir}" includes="**" excludes="com/acnielsen/dtu/web/**, com/acnielsen/dtu/dtuwrapper/**" debug="on" deprecation="on" optimize="off" classpathref="classpath">

                          <src path="${generated.java.dir}" />

                        </javac>

              </target>

             

              <target name="compile-web">

                        <javac srcdir="${src.dir}" destdir="${build.classes.dir}" includes="com/acnielsen/dtu/web/**" debug="on" deprecation="on" optimize="off" classpathref="classpath">

                          <src path="${generated.java.dir}" />

                        </javac>

              </target>

             

            :

            :

             

             

            if I dont use xdoclet or ejbdoclet, how my build.xml would look like? you mean I can just start writing java codes without using xdoclet? (and it is legitimately simpler to do that way) -- today I am seeing in my existing java code lot of annotations being used - also lot of .java files are being created when i right click on build.xml - Run As - Ant Build (option 2) such as: JobService.java, JobServiceHome.java, JobServiceLocal.java, JobServiceLocalHome.java...

             

            How would i generate the .java files for ejb3.0 as supposed to ejb2.0 which is mentioned in build.xml ?  How can I control this?

             

            If I take the javac java compiler parts out of the build.xml, then it stops generating .java files.

             

            Your help is truly appreciated. Thanks.

            • 3. Re: jboss tools - xdoclet/ejbdoclet question.
              Wolf-Dieter Fink Master

              With ejb3 you d not need a lot of generated java files.

              I use eclipse plugins to create what is needed.

              If you have JBossTools you might create an EJB and this create remote and local interfaces.

               

              I often use the only the eclipse build-in to create an interface from the implementation class.

               

              So there are only the some extra classes and no XML descriptors

              If you need the Remote and RemoteHome EJB2 interface for compatibility reason I prefer to build that classes once with the 'old' application and put the Java files to the current sources. In this case you have the 100% compatible interface and this works with the EJB3 implementation.

               

              The persistence (Entities) must be complete refactored as the new persistence is a POJO class with JPA annotations.

              • 4. Re: jboss tools - xdoclet/ejbdoclet question.
                prashant gandhi Newbie

                Okay Wolf. Thanks a lot for all the help you are providing. I truly appreciate it. So now the final verdict from management has come.

                 

                We do not want to use XDOCLET or EJBDOCLET.

                We want to use JBOSS 6.1.0 Final - since that is considered as a stable supported release.

                We want to use EJB 3.0.

                 

                I have some basic questions to get me started.

                 

                I have Eclipse Indigo with JBOSS-eap-6.1 in my project and I can start and stop this server.  I have my existing code there which I can compile and build the .ear file. My build.xml seems to be having good amount of references to ejbdoclets. how do i get rid of them? if i remove them, rest of the code does not compile because it is depending on those targets.

                 

                Is there any tool to build the build.xml? I am seeing few things to be done in my build.xml : 1. remove ejbdoclet references, 2. make it ejb 3.0 compatible as supposed to ejb 2.0 as it reflects.

                 

                What .jar and other files/references are required if I want to create the build.xml for ejb3? in my existing build.xml i see few .jar files being referenced.

                 

                I believe building build.xml is the first step in the project. Then I have to start writing my beans. Please let me know if I am getting the sequence wrong or need anything in addition to this.  I want to create 1 simple hello world program using JBOSS 6.1, ejb3 with @local and @remote first.

                 

                For this simple task, do I need to use any jboss IDE or simple text editor of eclipse should be good enough?

                 

                Sorry for asking many questions and I again am very much thankful to you for providing assistance. 

                • 5. Re: jboss tools - xdoclet/ejbdoclet question.
                  Wolf-Dieter Fink Master

                  I think if you delete the XDoclet tasks from your build.xml and still use the 'old' sources which is not possible as the compiler will miss the former generated classes.

                   

                  If you setup a new project you need to have the JEE API classes to build a simple bean, to continue you might need other APIs for transaction, servlet etc.

                  With ant you need to manage this by yourself, create a compile and pack target collect the different classes and pack an ejb.jar, web.war and pack it into the app.ear.

                   

                  Why you don't use maven for this? You find a lot of examples on the JDF quickstart pages.

                  • 6. Re: jboss tools - xdoclet/ejbdoclet question.
                    prashant gandhi Newbie

                    We are using ant and will be using ant, so i think i will be stuck with it. We have dtu.ear (application name = dtu) which has 1 .jar and .war inside.

                    Removing simply the xdoclet (~ ejbdoclet) task from build.xml seems to be bit problematic.

                     

                    For learning perspective what is did is: I removed those ejbdoclet tasks from build.xml - Other tasks which had depends clause on these tasks, I i removed those ejbdoclet dependencies from depends. I removed all the javac lines from the subsequent tasks too (meaning no java code compilations) Then right click on build.xml - Run As - Ant Build. The build becomes successful. When I put those javac lines back, the error starts and build fails.

                     

                    Questions:

                     

                    1. Is Maven better than Eclipse even if I want to use Ant?

                    2. About your first line, I am unclear. what do we mean by still using the "old" source code? I have only 1 source code available.

                     

                    I have observed 1 thing.We are using 7-8 beans and each bean has exactly 4 .java files generated during building build.xml as explained above (or running, i should say): These 4 files are generated because of following lines in the build.xml:

                     

                           <remoteinterface/>

                           <homeinterface/>

                           <localinterface/>

                           <localhomeinterface/>

                         

                     

                    If i remove let say <remoteinterface\> line, then every bean ends up getting 3 files and the build fails because of missing .java file for remote interface - which is i believe kind of required for the application to work.

                     

                    I read few tutorials and blogs on ejb2 to ejb3 move and they are suggesting changes necessary to make (using annotations etc) which needs to go in these 4 auto generated .java files. Are these files generated due to doclets? i think if we want to move with ejb3, these .java files auto generation needs to be stopped as well and we will need to write these files ourselves with ejb3 annotations etc.

                     

                    Let me know your thoughts. Thanks.

                    • 7. Re: jboss tools - xdoclet/ejbdoclet question.
                      Wolf-Dieter Fink Master

                      You need to remove

                       

                      {code}

                        <taskdef classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="xdoclet.classpath" name="ejbdoclet" />

                        <ejbdoclet destdir="${classes.dir}" mergedir="etc/xdoclet/merge" excludedtags="@version,@author" ejbspec="2.1" force="true">

                      {code}

                       

                      from your build.xml the ejbdoclet including all sub elements.

                       

                      After that there is no generation of any source file.

                      As I said earlier you need to write the classes by hand or use eclipse or JBossTool features to generate the interfaces.

                      • 8. Re: jboss tools - xdoclet/ejbdoclet question.
                        jaikiran pai Master

                        prashant gandhi wrote:

                         

                        We want to use JBOSS 6.1.0 Final - since that is considered as a stable supported release.

                        The latest Final released version of JBoss Application Server (which has now been renamed to WildFly) is 7.1.1.Final. That's the community edition. The enterprise/paid version is EAP 6.1.0.Final