| Author |
The return type of an ejbCreate(...) method must be the entity bean's primary key typ
|
Clinton Morrison
Greenhorn
Joined: Jun 28, 2007
Posts: 24
|
|
I am trying to deploy an simple entity bean to JBoss 4.2 and receive the error below. I am not sure where I am going wrong? Thanks in advance Clinton The return type of an ejbCreate(...) method must be the entity bean's primary key type. 15:17:30,064 ERROR [MainDeployer] Could not create deployment: file:/C:/jboss-4.2.2.GA/server/default/deploy/SimpleBean.jar/ org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages. ejb-jar.xml sample <entity > <description><![CDATA[Description for Simple]]></description> <display-name>Name for Simple</display-name> <ejb-name>Simple</ejb-name> <home>simplebean.interfaces.SimpleHome</home> <remote>simplebean.interfaces.Simple</remote> <local-home>simplebean.interfaces.SimpleLocalHome</local-home> <local>simplebean.interfaces.SimpleLocal</local> <ejb-class>simplebean.ejb.SimpleCMP</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>simplebean.interfaces.SimplePK</prim-key-class> <reentrant>False</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>Simple</abstract-schema-name> <cmp-field > <description><![CDATA[]]></description> <field-name>id</field-name> </cmp-field> <cmp-field > <description><![CDATA[]]></description> <field-name>name</field-name> </cmp-field> <!-- Write a file named ejb-finders-SimpleBean.xml if you want to define extra finders. --> </entity> SimpleBean sample public String ejbCreate() throws CreateException { this.setId(SimpleUtil.generateGUID(this)); return null; } jboss.xml sample <entity> <ejb-name>Simple</ejb-name> <jndi-name>ejb/Simple</jndi-name> <local-jndi-name>SimpleLocal</local-jndi-name> <method-attributes></method-attributes> </entity>
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
|
Hint: is String the type of your PK?
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
Clinton Morrison
Greenhorn
Joined: Jun 28, 2007
Posts: 24
|
|
Thanks the jar is now deploying. I created a client below. However when I run the client I get the following error. I am using JBoss 4.2. Thanks Clinton Error Exception in thread "main" java.lang.ClassCastException at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229) Class package simplebean.client; import java.rmi.RemoteException; import java.util.Properties; import javax.ejb.CreateException; import javax.ejb.EJBException; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import simplebean.interfaces.Simple; import simplebean.interfaces.SimpleHome; /** * @author owner * */ public class SimpleBeanClient { Properties properties; public SimpleBeanClient() { properties = new Properties(); properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); properties.put("java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces"); properties.put("java.naming.provider.url", "jnp://localhost:1099"); properties.put("jnp.disableDiscovery", "true"); } public static void main(String[] args) { SimpleBeanClient beanClient = new SimpleBeanClient(); beanClient.createBean(); } public void createBean() throws EJBException { try { InitialContext context = new InitialContext(properties); Object object = context.lookup("ejb/SimpleBeanHome"); SimpleHome simpleHome = (SimpleHome) PortableRemoteObject.narrow( object, SimpleHome.class); Simple simple = simpleHome.create(); simple.setName("Gunter"); System.out.println(simple.getId()); System.out.println(simple.getName()); } catch (NamingException e) { throw new EJBException(e); } catch (RemoteException e) { throw new EJBException(e); } catch (CreateException e) { throw new EJBException(e); } } }
|
 |
 |
|
|
subject: The return type of an ejbCreate(...) method must be the entity bean's primary key typ
|
|
|