For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 1 reply, 1 voice, and was last updated 20 years, 8 months ago by
leosoto.
-
AuthorPosts
-
leosotoMemberHi!
I’ve been trying to develop a simple CMP-beans-based with Myeclipse + WAS6.0. I’ve followed the detailed WS instructions and a very basic CMP2.0 tutorial.
To begin, I’ve tried to deploy a very simple EJB, with two properties: id and name. Here comes the code:
package test.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; import test.interfaces.TestUtil; /** * 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="Test" * display-name="Name for Test" * description="Description for Test" * jndi-name="ejb/Test" * local-jndi-name="ejb/TestLocal" * type="CMP" * cmp-version="2.x" * view-type="both" * @ejb.util generate="physical" * @ejb.persistence table-name="test" */ public abstract class TestBean implements EntityBean { /** The entity context */ private EntityContext context; /** * @ejb.interface-method view-type="both" * @ejb.persistence column-name="id" * @ejb.pk-field * * @return El id */ public abstract String getId(); /** * @ejb.interface-method view-type="both" * * @param id El id */ public abstract void setId(String id); /** * @ejb.interface-method view-type="both" * @ejb.persistence column-name="nombre" * * @return El nombre */ public abstract String getNombre(); /** * @ejb.interface-method view-type="both" * * @param nombre El nombre */ public abstract void setNombre(String nombre); public TestBean() { 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 String ejbCreate() throws CreateException { setId(TestUtil.generateGUID(this)); 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() 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; } public void ejbRemove() throws RemoveException, EJBException, RemoteException { // TODO Auto-generated method stub } public void ejbActivate() throws EJBException, RemoteException { // TODO Auto-generated method stub } public void ejbPassivate() throws EJBException, RemoteException { // TODO Auto-generated method stub } public void ejbLoad() throws EJBException, RemoteException { // TODO Auto-generated method stub } public void ejbStore() throws EJBException, RemoteException { // TODO Auto-generated method stub } }I have configured xdoclet to use the websphere subtask, set the JNDI name for the database (that has a test table with two varchars) and the destdir.
Next, xdoclet ran fine, ‘pseudo-deploying’ via myeclipse also ran fine. But when manually deploying the EAR into WAS I’ve got the following error:
@log wrote:
[15-12-05 12:31:40:231 CLST] 00000086 SystemOut O ADMA6012I: Exception in run com.ibm.websphere.management.exception.AdminException: ADMA0063E: An error occurred in EJB deployment – [ejbModule/test/ejb/ConcreteTest_6251d7dc.java(123): The return type is incompatible with TestBean.ejbCreate()]
[15-12-05 12:31:40:234 CLST] 00000086 SystemOut O Exception: com.ibm.etools.ejbdeploy.EJBDeploymentException: Error executing EJBDeploy
[15-12-05 12:31:40:291 CLST] 00000086 SystemOut O com.ibm.etools.ejbdeploy.EJBDeploymentException: Error executing EJBDeploy
at com.ibm.etools.ejbdeploy.EJBDeploy.execute(EJBDeploy.java:229)
at com.ibm.ejs.util.deployment.deploywrapper.DeployUtil$1.run(DeployUtil.java:235)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ejs.util.deployment.deploywrapper.DeployUtil.deployModule(DeployUtil.java:230)
at com.ibm.ejs.util.deployment.deploywrapper.DeployUtil.deploy(DeployUtil.java:83)
at com.ibm.ws.management.application.task.DeployEJBTask.performTask(DeployEJBTask.java:336)
at com.ibm.ws.management.application.SchedulerImpl.run(SchedulerImpl.java:250)
at java.lang.Thread.run(Thread.java:568)And I have no idea about what is the return type refered by the error message. 🙁
Before in the log are some warnings that may help:
@log wrote:
15-12-05 12:30:17:958 CLST] 00000087 DataSourceFor W ADMA0091E: El recurso com.ibm.ejs.models.base.bindings.ejbbnd.impl.EnterpriseBeanBindingImpl@7b1bcf7 (jndiName: ejb/Test, ejbName: null) definido en el URI META-INF/ibm-ejb-jar-bnd.xmi para el módulo TestEAREJB.jar no es válido. El recurso tiene una referencia cruzada com.ibm.etools.ejb.impl.EntityImpl(null) que no puede resolverse.
[15-12-05 12:30:18:336 CLST] 00000087 DataSourceFor W ADMA0091E: El recurso com.ibm.ejs.models.base.bindings.ejbbnd.impl.EnterpriseBeanBindingImpl@7b1bcf7 (jndiName: ejb/Test, ejbName: null) definido en el URI META-INF/ibm-ejb-jar-bnd.xmi para el módulo TestEAREJB.jar no es válido. El recurso tiene una referencia cruzada com.ibm.etools.ejb.impl.EntityImpl(null) que no puede resolverse.
[15-12-05 12:30:18:414 CLST] 00000087 DataSourceFor W ADMA0091E: El recurso com.ibm.ejs.models.base.bindings.ejbbnd.impl.EnterpriseBeanBindingImpl@7b1bcf7 (jndiName: ejb/Test, ejbName: null) definido en el URI META-INF/ibm-ejb-jar-bnd.xmi para el módulo TestEAREJB.jar no es válido. El recurso tiene una referencia cruzada com.ibm.etools.ejb.impl.EntityImpl(null) que no puede resolverse.
[15-12-05 12:30:18:500 CLST] 00000087 DataSourceFor W ADMA0091E: El recurso com.ibm.ejs.models.base.bindings.ejbbnd.impl.EnterpriseBeanBindingImpl@7b1bcf7 (jndiName: ejb/Test, ejbName: null) definido en el URI META-INF/ibm-ejb-jar-bnd.xmi para el módulo TestEAREJB.jar no es válido. El recurso tiene una referencia cruzada com.ibm.etools.ejb.impl.EntityImpl(null) que no puede resolversThanks in advance!
December 15, 2005 at 12:54 pm #243150
leosotoMemberAuto.reply:
Removing @ejb.pk-field from the id getter and adding a pk-field attribute to @ejb.bean solved the problem.
-
AuthorPosts
