facebook

Eclipse XDoclet generates an error [Closed]

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #223526 Reply

    drowell
    Member

    – System Setup ——————————-
    Operating System and version: Linux Redhat Fedora Core
    Eclipse version: 3.0.1
    Eclipse build id: 20040961125
    Fresh Eclipse install (y/n): y
    If not, was it upgraded to its current version using the update manager?
    Other installed external plugins:
    Number of plugins in the <eclipse>/plugins directory that begin with org.eclipse.pde.*:
    MyEclipse version: 3.8.3
    Eclipse JDK version: 1.4.2
    Application Server JDK version: 1.4.2
    Are there any exceptions in the Eclipse log file? None

    David Rowell
    drowell@settimogroup.com
    davidallanrowell@hotmail.com

    I have created a simple entity bean, exactly as it appears in my Eclipse 3.0 book.

    /*
    * Created on Jan 24, 2005
    *
    * TODO To change the template for this generated file go to
    * Window – Preferences – Java – Code Style – Code Templates
    */
    package com.hobsons.nafsa.model.entity.ejb;

    import java.rmi.RemoteException;

    import javax.ejb.EJBException;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    import javax.ejb.RemoveException;

    import javax.ejb.CreateException;

    /**
    * XDoclet-based CMP 2.x entity bean. This class must be declared
    * public abstract because the concrete class will
    * be implemented by the CMP providers tooling.
    *
    * To generate EJB related classes using XDoclet:
    *
    * – Add Standard EJB module to XDoclet project properties
    * – Customize XDoclet configuration
    * – Run XDoclet
    *
    * Below are the xdoclet-related tags needed for this EJB.
    *
    * @ejb.bean name=”MeetingBean”
    * display-name=”MeetingBean”
    * description=”MeetingBean EJB”
    * jndi-name=”ejb/MeetingBeanHome”
    * local-jndi-name = “ejb/MeetingBeanLocalHome”
    * type=”CMP”
    * cmp-version=”2.x”
    * view-type=”both”
    * primkey-field = “MeetingId”
    *
    * @ejb:util generate=”physical”
    *
    * @ejb:persistence table-name = “customer”
    *
    * @ejb.finder signature = “com.hobsons.nafsa.vip.ejb.MeetingBean findByMeetingId(java.lang.Integer meetingId)”
    * query = “SELECT OBJECT(c) FROM MeetingBean as c where c.MeetingId ?1″
    */
    public abstract class MeetingBean implements EntityBean {

    /** The entity context */
    private EntityContext context;

    /**
    *
    */
    public MeetingBean() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * There are zero or more ejbCreate<METHOD>(…) methods, whose signatures match
    * the signatures of the create<METHOD>(…) methods of the entity bean?s home interface.
    * The container invokes an ejbCreate<METHOD>(…) method on an entity bean instance
    * when a client invokes a matching create<METHOD>(…) method on the entity bean?s
    * home interface.<br>
    *
    * The entity bean provider?s responsibility is to initialize the instance in the ejbCreate<
    * METHOD>(…) methods from the input arguments, using the get and set accessor
    * methods, such that when the ejbCreate<METHOD>(…) method returns, the persistent
    * representation of the instance can be created. <br>
    *
    * The entity bean provider must not attempt to modify the values of cmr-fields in an ejbCreate<
    * METHOD(…) method; this should be done in the ejbPostCreate<METHOD(…) method instead.<br>
    *
    * The entity object created by the ejbCreate<METHOD> method must have a unique primary
    * key. This means that the primary key must be different from the primary keys of all the existing
    * entity objects within the same home. However, it is legal to reuse the primary key of a previously
    * removed entity object. The implementation of the bean provider?s ejbCreate<
    * METHOD>(…) methods should be coded to return a null.<br>
    *
    * An ejbCreate<METHOD>(…) method executes in the transaction context determined by
    * the transaction attribute of the matching create<METHOD>(…) method.
    * The database insert operations are performed by the container within the same
    * transaction context after the Bean Provider?s ejbCreate<METHOD>(…) method completes.
    *
    * @throws CreateException Thrown if method fails due to system-level error.
    *
    * @throws CreateException
    *
    * @ejb.create-method
    */
    public Integer ejbCreate(Integer meetingId) throws CreateException {
    setMeetingId(meetingId);
    return null;
    }

    /**
    * For each ejbCreate<METHOD>(…) method, there is a matching ejbPostCreate<
    * METHOD>(…) method that has the same input parameters but whose return type is
    * void. The container invokes the matching ejbPostCreate<METHOD>(…) method on
    * an instance after it invokes the ejbCreate<METHOD>(…) method with the same arguments.
    * The instance can discover the primary key by calling getPrimaryKey() on its
    * entity context object. <br>
    *
    * The entity object identity is available during the ejbPostCreate<METHOD>(…)
    * method. The instance may, for example, obtain the component interface of the associated entity
    * object and pass it to another enterprise bean as a method argument.<br>
    *
    * The entity Bean Provider may use the ejbPostCreate<METHOD>(…) to set the values
    * of cmr-fields to complete the initialization of the entity bean instance.
    * An ejbPostCreate<METHOD>(…) method executes in the same transaction context as
    * the previous ejbCreate<METHOD>(…) method.
    *
    * @throws CreateException Thrown if method fails due to system-level error.
    */
    public void ejbPostCreate(Integer meetingId) throws CreateException {
    }

    /**
    * Set the associated entity context. The container calls this method
    * after the instance creation. The entity bean must not attempt to
    * access its persistent state and relationships using the accessor
    * methods during this method. <br>
    *
    * The enterprise bean instance should store the reference to the context
    * object in an instance variable. <br>
    *
    * This method is called with no transaction context.
    *
    * @throws EJBException Thrown if method fails due to system-level error.
    */
    public void setEntityContext(EntityContext newContext) throws EJBException {
    context = newContext;
    }

    /**
    * Unset the associated entity context. A container invokes this method
    * before terminating the life of the instance. The entity bean must not
    * attempt to access its persistent state and relationships using the
    * accessor methods during this method. <br>
    *
    * This method is called with no transaction context.
    *
    * @throws EJBException Thrown if method fails due to system-level error.
    */
    public void unsetEntityContext() throws EJBException {
    context = null;
    }

    /* (non-Javadoc)
    * @see javax.ejb.EntityBean#ejbRemove()
    */
    public void ejbRemove()
    throws RemoveException,
    EJBException,
    RemoteException {
    // TODO Auto-generated method stub

    }

    /* (non-Javadoc)
    * @see javax.ejb.EntityBean#ejbActivate()
    */
    public void ejbActivate() throws EJBException, RemoteException {
    // TODO Auto-generated method stub

    }

    /* (non-Javadoc)
    * @see javax.ejb.EntityBean#ejbPassivate()
    */
    public void ejbPassivate() throws EJBException, RemoteException {
    // TODO Auto-generated method stub

    }

    /* (non-Javadoc)
    * @see javax.ejb.EntityBean#ejbLoad()
    */
    public void ejbLoad() throws EJBException, RemoteException {
    // TODO Auto-generated method stub

    }

    /* (non-Javadoc)
    * @see javax.ejb.EntityBean#ejbStore()
    */
    public void ejbStore() throws EJBException, RemoteException {
    // TODO Auto-generated method stub

    }

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “MeetingId”
    */
    public abstract Integer getMeetingId();
    public abstract void setMeetingId(Integer meetingid);

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “VipOrgId”
    */
    public abstract String getVipOrgId();

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “VipOrgId”
    */
    public abstract void setVipOrgId(String viporgid);

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “Subject”
    */
    public abstract String getSubject();

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “Subject”
    */
    public abstract void setSubject(String subject);

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “Date”
    */
    public abstract String getDate();

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “Date”
    */
    public abstract void setDate(String date);

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “StartMeetingTime”
    */
    public abstract String getStartMeetingTime();

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “StartMeetingTime”
    */
    public abstract void setStartMeetingTime(String startmeetingtime);

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “EndMeetingTime”
    */
    public abstract String getEndMeetingTime();

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “EndMeetingTime”
    */
    public abstract void setEndMeetingTime(String endmeetingtime);

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “Location”
    */
    public abstract String getLocation();

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “Location”
    */
    public abstract void setLocation(String location);

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “EmailId”
    */
    public abstract String getEmailId();

    /**
    * @ejb.interface-method view-type=”both”
    * @ejb.persistence column-name = “EmailId”
    */
    public abstract void setEmailId(String emailid);

    }

    When I run Xdoclet, all of the appropriate files are generated without any errors:
    Buildfile: /usr/eclipse/workspace/NAFSAEJB/xdoclet-build.xml
    N10004:
    [ejbdoclet] (XDocletMain.start 47 ) Running <remoteinterface/>
    [ejbdoclet] Generating Remote interface for ‘com.hobsons.nafsa.model.entity.ejb.MeetingBean’.
    [ejbdoclet] (XDocletMain.start 47 ) Running <localinterface/>
    [ejbdoclet] Generating Local interface for ‘com.hobsons.nafsa.model.entity.ejb.MeetingBean’.
    [ejbdoclet] (XDocletMain.start 47 ) Running <homeinterface/>
    [ejbdoclet] Generating Home interface for ‘com.hobsons.nafsa.model.entity.ejb.MeetingBean’.
    [ejbdoclet] (XDocletMain.start 47 ) Running <localhomeinterface/>
    [ejbdoclet] Generating Local Home interface for ‘com.hobsons.nafsa.model.entity.ejb.MeetingBean’.
    [ejbdoclet] (XDocletMain.start 47 ) Running <dataobject/>
    [ejbdoclet] Generating Data Object class for ‘com.hobsons.nafsa.model.entity.ejb.MeetingBean’.
    [ejbdoclet] (XDocletMain.start 47 ) Running <valueobject/>
    [ejbdoclet] (XDocletMain.start 47 ) Running <entitycmp/>
    [ejbdoclet] Generating CMP class for ‘com.hobsons.nafsa.model.entity.ejb.MeetingBean’.
    [ejbdoclet] (XDocletMain.start 47 ) Running <session/>
    [ejbdoclet] (XDocletMain.start 47 ) Running <utilobject/>
    [ejbdoclet] Generating Util class for ‘com.hobsons.nafsa.model.entity.ejb.MeetingBean’.
    [ejbdoclet] (XDocletMain.start 47 ) Running <deploymentdescriptor/>
    [ejbdoclet] Generating EJB deployment descriptor (ejb-jar.xml).
    [ejbdoclet] (XDocletMain.start 47 ) Running <jboss/>
    [ejbdoclet] Generating jboss.xml.
    [ejbdoclet] Generating jbosscmp-jdbc.xml.
    _xdoclet_generation_:
    BUILD SUCCESSFUL
    Total time: 11 seconds

    I successfully deploy to JBOSS3 and start JBoss. When I start JBOSS, the following error shows up in the console:
    08:43:57,220 ERROR [MainDeployer] could not create deployment: file:/home/jboss-3.2.6/server/default/deploy/NAFSAEJB.jar/
    org.jboss.deployment.DeploymentException: Error in ejb-jar.xml for Entity Bean MeetingBean: primkey-field MeetingId is not a cmp-field
    at org.jboss.metadata.ApplicationMetaData.importEjbJarXml(ApplicationMetaData.java:252)
    at org.jboss.metadata.XmlFileLoader.load(XmlFileLoader.java:141)
    at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:462)
    at org.jboss.deployment.MainDeployer.create(MainDeployer.java:783)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:640)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:604)
    at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
    at $Proxy8.deploy(Unknown Source)

    Is there an XDoclet configuration issue that I am missing. This simple bean should deploy properly.

    Any help is much appreciated.
    drowell@settimogroup.com

    If this is a DB related question please answer the following:

    RDBMS vendor and version:
    JDBC driver vendor and version, and access type (thin, type-2, etc):
    Connection URL:
    Eclipse error logs related to com.genuitec.eclipse.sqlexplorer packages:

    – Message Body ——————————-

    #223551 Reply

    Riyad Kalla
    Member

    From the XDoclet site, it looks like you might be missing an @ejb.persistence tag on your PK method:
    http://xdoclet.sourceforge.net/xdoclet/tags/ejb-tags.html#@ejb_persistence__0__1_

    #223706 Reply

    drowell
    Member

    That was the problem. Thanks for the help and for the XDoclet link

    #223709 Reply

    Riyad Kalla
    Member

    no problem, glad it helped.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Eclipse XDoclet generates an error [Closed]

You must be logged in to post in the forum log in