• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

The return type of an ejbCreate(...) method must be the entity bean's primary key typ

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hint: is String the type of your PK?
 
Clinton Morrison
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
}
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic