1 Reply Latest reply on Nov 22, 2007 3:32 PM by Tam Mains

    Trouble building simple EJB

    Tam Mains Newbie

      Hi, just going through an example ejb and then adapting the method used to create my own bean. Trouble is when I edit the main Bean class, in this case JujitsuFacadeBean, it comes up with some parse error and starts to create an interface in the ejbModule package.

      IDE is Eclipse 3.2.
      JDK is 5.
      xdoclet is 1.2.3
      Jboss is 4.0.5.

      i followed the example as per the book. Where am I going wrong?

      Here is the errors reported in the console...

      Buildfile: /home/tam/workspace/JuJitent/.metadata/.plugins/org.eclipse.jst.j2ee.ejb.annotations.xdoclet/tempAnt.xml
      init:
      ejbdoclet:
      [ejbdoclet] (XDocletMain.start 47 ) Running <deploymentdescriptor/>
      [ejbdoclet] Generating EJB deployment descriptor (ejb-jar.xml).
      [ejbdoclet] Error parsing File /home/tam/workspace/JuJitent/JujitsuEJB/ejbModule/com/jujitsu/ejb/JujitsuFacadeBean.java:Encountered "<"[" ...
      [ejbdoclet] "." ...
      [ejbdoclet] "(" ...
      [ejbdoclet] (XDocletMain.start 47 ) Running <remoteinterface/>
      [ejbdoclet] Generating Remote interface for 'com.jujitsu.ejb.JujitsuFacadeBean'.
      [ejbdoclet] (TemplateEngine.invokeMethod 547 ) Invoking method failed: xdoclet.modules.ejb.intf.InterfaceTagsHandler.extendsFrom, line=10 of template file: jar:file:/home/tam/opt/xdoclet-1.2.3/lib/xdoclet-ejb-module-1.2.3.jar!/xdoclet/modules/ejb/intf/resources/remote.xdt
      [ejbdoclet] java.lang.reflect.InvocationTargetException
      [ejbdoclet] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [ejbdoclet] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [ejbdoclet] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [ejbdoclet] at java.lang.reflect.Method.invoke(Method.java:585)
       plus more errors...
      


      This is the code for JujitsuFacadeBean, this implements the interface JujitsuFacade whose jar file has been included in the project.
      /**
       *
       */
      package com.jujitsu.ejb;
      
      import java.rmi.RemoteException;
      import java.util.Set;
      
      import javax.ejb.EJBException;
      import javax.ejb.SessionContext;
      
      import com.jujit.model.Club;
      import com.jujit.model.Instructor;
      import com.jujit.model.Student;
      import com.jujit.services.ClubFacade;
      import com.jujit.services.JujitsuFacade;
      
      
      /**
       *
       * <!-- begin-user-doc -->
       * A generated session bean
       * <!-- end-user-doc -->
       * *
       * <!-- begin-xdoclet-definition -->
       * @ejb.bean name="JujitsuFacade"
       * description="An EJB named JujitsuFacade"
       * display-name="JujitsuFacade"
       * jndi-name="JujitsuFacade"
       * type="Stateless"
       * transaction-type="Container"
       * @ejb.transaction
       * type="Supports"
       * <!-- end-xdoclet-definition -->
       * @generated
       */
      
      public abstract class JujitsuFacadeBean implements JujitsuFacade, javax.ejb.SessionBean {
       private JujitsuFacade jujitsuFacade;
      
       /**
       * @ejb.interface-method view-type="both"
       */
       public boolean doesClubExist(String clubId){
       return jujitsuFacade.doesClubExist(clubId);
       }
      
       /**
       *@ejb.interface-method view-type="both"
       */
       public boolean createClub(Club newClub){
       return jujitsuFacade.createClub(newClub);
       }
      
       /**
       * @ejb.interface-method view-type="both"
       */
       public Instructor findInstructor(String id){
       return jujitsuFacade.findInstructor(id);
       }
      
       /**
       * @ejb.interface-method view-type="both"
       */
       public Student findStudent(String id){
       return jujitsuFacade.findStudent(id);
       }
      
      
       /**
       * @ejb.interface-method view-type="both"
       */
       public Club findClub(String id){
       return jujitsuFacade.findClub(id);
       }
      
       /**
       * @ejb.interface-method view-type="both"
       */
       public Set<Student> getStudentsForClub(String clubId){
       return jujitsuFacade.getStudentsForClub(clubId);
       }
       /**
       *
       * <!-- begin-xdoclet-definition -->
       * @ejb.create-method view-type="remote"
       * <!-- end-xdoclet-definition -->
       * @generated
       *
       * //
       */
       public void ejbCreate() {
       jujitsuFacade = ClubFacade.getJujitsuFacade();
       }
      
       /**
       *
       * <!-- begin-xdoclet-definition -->
       * @ejb.interface-method view-type="remote"
       * <!-- end-xdoclet-definition -->
       * @generated
       *
       * //TODO: Must provide implementation for bean method stub
       */
       public String foo(String param) {
       return null;
       }
      
       /* (non-Javadoc)
       * @see javax.ejb.SessionBean#ejbActivate()
       */
       public void ejbActivate() throws EJBException, RemoteException {
       // TODO Auto-generated method stub
      
       }
      
       /* (non-Javadoc)
       * @see javax.ejb.SessionBean#ejbPassivate()
       */
       public void ejbPassivate() throws EJBException, RemoteException {
       // TODO Auto-generated method stub
      
       }
      
       /* (non-Javadoc)
       * @see javax.ejb.SessionBean#ejbRemove()
       */
       public void ejbRemove() throws EJBException, RemoteException {
       // TODO Auto-generated method stub
      
       }
      
       /* (non-Javadoc)
       * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
       */
       public void setSessionContext(SessionContext arg0) throws EJBException,
       RemoteException {
       // TODO Auto-generated method stub
      
       }
      
       /**
       *
       */
       public JujitsuFacadeBean() {
       // TODO Auto-generated constructor stub
       }
      }
      

      Suprisingly the build after editing starts to assemble an interface JujitsuFacade...terribly.
      /*
       * Generated by XDoclet - Do not edit!
       */
      package com.jujitsu.ejb;
      
      /**
       * Remote interface for JujitsuFacade.
       * @generated
       * @wtp generated
       */
      public interface JujitsuFacade
       extends
      

      Thats as far as it got.

      Any help appreciated.


        • 1. Re: Trouble building simple EJB
          Tam Mains Newbie

          Have managed to figure out for myself what the problem was. Compiler compliance. I was using ejb 2.3, JBoss 4.0.5 and Java5. ejb could not handle Java5 generics and so reported correctly an error. Fix was to change compiler compliance in the Eclipse Workspace from 5 to 1.4 and the same goes for each of the Projects in the workspace. This also meant editing each class declaration using generics to the old way of casting.

          SORTED.