EJB3.0 simple entity bean for customer example...

Can anyone provide a simple step by step instruction on how to start my application of a customer entity bean. like i could add / delete an entry to mySQL DB, i will use Sun as my appserver. im a newbie to ejb. i want to start with that CUSTOMER bean can anybody help pls ? thx! tata-yang

hello batzee i already have my appserver running
and found out that he place my EJBSample under Enterprise Application.
and with these modules inside:
-EJBsampleSun-ejb.jar      EJBModule      
-EJBsampleSun-war.war WebModule
my appserver has:
EJBsampleSun      true      ${com.sun.aas.instanceRoot}/applications/j2ee-apps/EJBsampleSun      Redeploy
inside my application:
1. ejbsamplesun-ejb/src/conf/persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="EJBsampleSun-ejbPU" transaction-type="JTA">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<jta-data-source>jdbc/mySample_dbo</jta-data-source> //question: i have db in mysql named mySample_dbo with customer as my table did i declare it right?
<properties>
</properties>
</persistence-unit>
</persistence>
================
2. ejbsamplesun-ejb/src/java/ph/icomm/customer.class
package myejb.ph;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.*;
@Entity
@Table(name="Customer")
public class Customer implements Serializable {
private int id;
private String name;
private String email;
private String phone;
@Id
@Column(name="ID")
public int getId() {
return id;
public void setId(int pk) {
id = pk;
@Column(name="Name")
public String getName() {
return name;
public void setName(String n) {
name = n;
@Column(name="Email")
public String getEmail() {
return email;
public void setEmail(String e) {
email = e;
@Column(name="Phone")
public String getPhone() {
return phone;
public void setPhone(String p) {
name = p;
================
3. ejbsamplesun-war/src/java/web/postcustomer.class
// and here is my servlet
//simply trying to fetch the data in my customer table with ID = 11
package web;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import ph.icomm.Customer;
import web.PostCustomer;
public class PostCustomer extends HttpServlet {
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
/* TODO output your page here*/
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet PostCustomer</title>");
out.println("</head>");
out.println("<body>");
try {
Customer pCustomer = new Customer();
pCustomer.setId(new Integer("11"));
out.println("Customer Name is"+pCustomer.getName());
out.println("<br>");
out.println("Customer Id is:"+pCustomer.getId());
out.println("<br>");
out.println("Customer Email is:"+pCustomer.getEmail());
out.println("<br>");
out.println("Customer Phone is:"+pCustomer.getPhone());
} catch(Exception e) {
System.out.println("I am inside Exception");
out.println("<h1>Servlet PostCustomer at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
out.close();
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Returns a short description of the servlet.
public String getServletInfo() {
return "Short description";
// </editor-fold>
Now, is this complete ejb3.0 already? coz if ill try to RUN this project it give this error:
Deploying application in domain failed; Deployment Error -- null
C:\Inetpub\wwwroot\myfolder\_Project\EJBsampleSun\EJBsampleSun-ejb\nbproject\build-impl.xml:312: Deployment error:
The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 1 second)
This is quite a long post but have to make sure ill get your kind help and assistance. Thanks!
tata-yang

Similar Messages

  • Can anyone describe using entity beans for persitance in Software Architect

    Can anyone describe using entity beans for persitance in Software Architecture you built for a product?

    Although this forum is supposed to help you gain knowledge on entity beans, its not a free rider that's supposed regurgitate everyone's knowledge to you.
    Read something first and then clarify your thoughts with this forum.

  • Error when deploying a simple Entity bean (EJB3) on Glassfich or Sun AS

    Hi,
    After some problems when deploying complex EJB3 Entity bean on GlassFich with a MySQL connector, I have made a simple entity.
    (test with Glassfish and Sun AS with same result)
    With netbean 5.5 => New EJB Module
    File->New->Persistence Unit (and use default values)
    Persistence.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
      <persistence-unit name="test" transaction-type="JTA">
       <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
        <jta-data-source>jdbc/sample</jta-data-source>
        <properties>
          <property name="toplink.ddl-generation" value="create-tables"/>
        </properties>
      </persistence-unit>
    </persistence>File->New->Entity Class
    EntityTest.java
    package test;
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    @Entity
    public class EntityTest implements Serializable
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        /** Creates a new instance of EntityTest */
        public EntityTest()
        public Long getId()
            return id;
        public void setId(Long id)
            this.id = id;
        public String toString()
            //TODO change toString() implementation to return a better display name
            return "" + this.id;
    }Build of project work fine but when I try to deploy (with the 2 servers), I have the error :
    Exception occured in J2EEC Phase
    com.sun.enterprise.deployment.backend.IASDeploymentException: Deployment Error -- null
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:790)
    at java.util.HashMap$KeyIterator.next(HashMap.java:823)
    at com.sun.enterprise.deployment.backend.EjbModuleDeployer.generatePolicy(EjbModuleDeployer.java:203)
    at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:171)
    at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
    at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
    at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
    at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)

    Yes, the problem is that the ejb-jar must contain at least one ejb component. It's a common misconception that Java Persistence API Entity classes are ejb components but they are NOT. The Java Persistence API was developed within the EJB 3.0 JSR and works very well with EJB but the entity classes themselves are not full-fledged ejb components.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Entity bean for shared acces without database access

    Hi all,
    I would like to create an entity bean to store data common for all application users. This bean does not have to have a database link, it should only keep data in memory until no user left.
    Is it possible ? And if yes, how ?
    I have already created a session bean that works but only keep data for one users session, and I have created an entity bean but it seems that it requires a database link.
    Thanks
    Sylvain

    Sylvain,
    I am assuming that you are using webdynpro for this.
    You have a provision to use 'Dictionary' objects to handle CRUD operations in webdynpro and also at EJB level.
    I can suggest you to handle this scenario in two ways.
    1) If you are trying to perform the persistance at Webdynpro level, You can create the dictionary object straightaway in the webdynpro component.
    2) If you are trying to perform persistance at EJB level using entity bean, I suggest you to maintain/create a dictionary object using your NWDS and access that Dictionary object at your entity bean using dictionary by packagename. Ofcourse you may have to write the CRUD operations code by urself.
    I hope that this information would be most useful.

  • JDBC or Entity Beans for Read-Only Data?

    Entity beans are way to slow on pulling the amount of data I need. What are the cons of just using JDBC? Is this bad programming?
    One query pulls about 700 rows from 6 different tables taking up to 20 seconds. The same call using JDBC takes 2 seconds. What is the proper thing to do?

    One query pulls about 700 rows from 6 different
    tables taking up to 20 seconds. The same call using
    JDBC takes 2 seconds. What is the proper thing to do?JDBC. Entity beans are not really suited for data across multiple tables. This can be best done with plain SQL +JDBC.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Simple Entity Bean JWS fails: Connection has already been created in this tx context

    I am new to Weblogic Workshop 8.1, and trying to create an EntityBean from a pre-existing
    database table.
    I get an error that indicates the JWS is using the default cgPool rather then
    my new pool for some transaction.
    I added my database (DB2) pool and data source, and then created an entity bean
    using "New Entity Bean from database table.
    I then wrapped this Entity Bean in a control and generated a JWS.
    When I run the JWS and execute FindByPrimaryKey, I get the following error:
    Submitted at Friday, April 2, 2004 11:07:30 AM CST
    <error>
    <faultcode>JWSError</faultcode>
    <faultstring>Couldn't get connection:
    java.sql.SQLException: Connection has already been created in this tx context
    for pool named cgPool. Illegal attempt to create connection from another pool:
    ATGW_POOL
    java.sql.SQLException: Connection has already been created in this tx context
    for pool named cgPool. Illegal attempt to create connection from another pool:
    ATGW_POOL
    at weblogic.jdbc.jts.Driver.getExistingConnection(Driver.java:410)
    at weblogic.jdbc.jts.Driver.connect(Driver.java:141)

    I am new to Weblogic Workshop 8.1, and trying to create an EntityBean from a pre-existing
    database table.
    I get an error that indicates the JWS is using the default cgPool rather then
    my new pool for some transaction.
    I added my database (DB2) pool and data source, and then created an entity bean
    using "New Entity Bean from database table.
    I then wrapped this Entity Bean in a control and generated a JWS.
    When I run the JWS and execute FindByPrimaryKey, I get the following error:
    Submitted at Friday, April 2, 2004 11:07:30 AM CST
    <error>
    <faultcode>JWSError</faultcode>
    <faultstring>Couldn't get connection:
    java.sql.SQLException: Connection has already been created in this tx context
    for pool named cgPool. Illegal attempt to create connection from another pool:
    ATGW_POOL
    java.sql.SQLException: Connection has already been created in this tx context
    for pool named cgPool. Illegal attempt to create connection from another pool:
    ATGW_POOL
    at weblogic.jdbc.jts.Driver.getExistingConnection(Driver.java:410)
    at weblogic.jdbc.jts.Driver.connect(Driver.java:141)

  • SOS problem using one Entity bean for editing records. please help me

    Hello
    I have one great problem using one entity bean 2.1 and i am working with this problem several days and i dont solve it.
    i am using this jb 2.1 for add new records to one oracle database and for editing records.
    I have one great problem for editing records
    I have one objets that is as one of my database table. (PersonaObj.java)
         //personaObj.java
         public class PersonaObj implements Serializable{
              private Integer id_persona; //this ishte database table autonumeric
              private java.lang.String nombre;
              now the set/get methods.
         One field of this objets (bean) is the primary key of the table, and this field is one part of the pk from the entity bean.
         From one session bean i call the entity bena passing the objet
         into the entity bean (interface) i have one methods:
              public getPersona getT56aaat04();
         public void setPersona(PersonaObj obj);
         into the entitybean bean i have:
         public PersonaEntityPK ejbCreate(PersonaObj obj) throws CreateException {
              this.setT56aaat04(obj);
              public abstract Integer getId_persona();
         public abstract void setId_persona(Integer Id_persona);
         public abstract java.lang.String getNombre();
         public abstract void setNombre(java.lang.String Nombre);
         public PersonaObj getPersona() {
              PersonaObj obj = new PersonaObj();
              obj.setId_persona(getId_persona());
              obj.setNombre(getNombre());
              return obj;
         public void setPersona(PersonaObj obj) {
              setId_persona(obj.getId_persona());
              setNombre(obj.getNombre());
    But i have one graet problem.
    adding new record to the database i runs well but if i want to edit one recor appears this error:
    => Error <=
    java.rmi.RemoteException: EJB Exception: ; nested exception is: javax.ejb.EJBException: EJB Exception: : java.lang.IllegalStateException:[EJB:010144]The setXXX method for a primary key field may only be called during ejbCreate.
    at PersonasEJB_a43o8n__WebLogic_CMP_RDBMS.setId_persona(PersonasEntityEJB_a43o8n__WebLogic_CMP_RDBMS.java:328)
    at PersonasEntityBean.setPersona(PersonasEntityBean.java:114)
    at PersonasEntityEJB_a43o8n_ELOImpl.setPersona(PersonasEntityEJB_a43o8n_ELOImpl.java:45)
    at PersonasSessionBean.editarPersona(PersonasSessionBean.java:849)
    at PersonasSessionBean_bszo9t_EOImpl.editarPersona(PersonasSessionBean_bszo9t_EOImpl.java:208)
    at PersonasSessionBean_bszo9t_EOImpl_WLSkel.invoke(Unknown Source)
    into the session bean i make this (the session recibes one PersonaObj obj):
    T56aContactosEntityLocal personaLocal ;
                   try {
                        personaLocal = personaHome.findByPrimaryKey(new T56aContactosEntityPK(obj.getId_a04()));
                        T56aaat04Obj objTmp = new T56aaat04Obj();
                        objTmp.setAp1_a04(obj.getAp1_a04());
                        objTmp.setEstado_a04("false");
                        personaLocal.setT56aaat04(obj);
    Please can you help me to solve this problem?

    Hello Werner,
    The mappings seem to be alright at a first glance.
    Have you tried out un- and redeploying your application? Sometimes values appear to be cached in the server. So if you have deployed the application before you entered DB_BANK as alias this might solve the problem...
    BR
    Daniel

  • CAN'T LOOKUP SIMPLE ENTITY BEAN : ''JAVAX.NAMING.NAMINGEXCEPTION: LOOKUP ERROR''

    Hello, we were forwarded to this forum from TAR section of Metalink. We are facing a problem with JDev-RC2/OC4J-9.0.3 and seems that we are hitting Bug 2276197. The BUG is marked as internal and therefore we can't see it. So, it's not clear where the problem is, if in JDev or OC4J or both ?
    Testcase Step-by-step:
    1. Invoke JDeveloper 9.0.3.815
    2. Create a workspace & a project.
    3. Create an default Container-managed Entity Beans frim Tables.
    4. Create Sample Java Client with "Connect to OC4J Embedded in Jdeveloper" and run it, it gives above error.
    You can download a testcase that is part of TAR-2125538.995, that we opened on Metalink.
    Please help. Thanks in advance.

    Hi Radim,
    Personally, I have played a little with JDeveloper, but I am not
    actively using it for my development -- I prefer to do most things
    myself. True, the JDeveloper wizards do a lot of the work for you,
    but at least (with my way), when something goes wrong, I have a
    better idea of where to look.
    So I can't help you much on the JDeveloper side, but an app is an
    app regardless of how you develop it, so I'll offer a list of things
    to check (just in case you haven't already done so :-).
    I haven't looked at your test case, but from your description, I
    assume you have a standalone java client. Again, I assume JDeveloper
    handles the details for you (and it may be doing it wrong -- as
    you suggest), but the way you do your JNDI lookup depends on the
    type of client you use. For a standalone java client (that is also
    deployed to OC4J), your "initial context factory" class should be:
    com.evermind.server.ApplicationClientInitialContextFactory
    and your "provider URL" should be:
    ormi://<host>/<app-name>
    where <host> is the name of the computer where OC4J is running
    (you can also use "localhost") and <app-name> is the name given
    to your application at deployment time. Again, JDeveloper handles
    the deployment, but the "app-name" should also appear in the
    "server.xml" configuration file which is usually located in the
    "config" subdirectory of the OC4J home directory.
    The lookup string for your entity bean should be the "logical"
    name, meaning the name of your bean prefixed with "java:comp/env".
    Again, I guess JDeveloper handles the bean name part for you,
    but the bean name appears in the "ejb-jar.xml" file under the
    "ejb-name" element.
    So if you've already checked all of the above, then please excuse
    me for not telling you anything you don't already know.
    Good Luck,
    Avi.

  • Entity bean for more than one table

    Can an entity bean represent more than one phyical table in the database? (i.e. span tables) If so, how is it coded up?

    Yes, probably either using BMP entity beans, or creating a database view of the two tables.
    However, the actual implementation depends a lot on your database and EJB container. Since I didn't see any details of these in your post, I suggest you research the documentation for both your EJB container and database.
    [Of-course, I'm assuming that you are already using a database and EJB container :-]
    Are you familiar with the following Web sites:
    http://java.sun.com/j2ee/tutorial/1_3-fcs/
    http://www.theserverside.com
    Have you read the specification?
    http://java.sun.com/j2ee/download.html
    Hope this helps.
    Good Luck,
    Avi.

  • Deploying Entity Bean Managed Persistant Example.

    Here is my error after running the client:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException; nested exception is:
    javax.transaction.RollbackException
    at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:170)
    at javax.rmi.CORBA.Util.mapSystemException(Util.java:65)
    at Test1HomeStub.create(Unknown Source)
    at Test1Client.main(Unknown Source)
    Here is the J2EE Verification error (allthough it deploys sucessfully I get this error for all the
    tuitorial examples)
    Error: [ ejb/SimpleTest1 ] class [ Test1Home ] cannot be found within this jar [ app-client-ic.jar ].
    For [ app-client-ic.jar ]
    Error: [ ejb/SimpleTest1 ] class [ Test1 ] cannot be found within this jar [ app-client-ic.jar ].
    I have edited the SavingsAccount example so it has only got one table, two fields and a couple of methods. Here is the code:
    create.sql
    drop table test1;
    create table test1
    (id varchar(3) constraint pk_test1 primary key,
    firstname varchar(24) );
    exit;
    Test!Bean.java
    import java.sql.*;
    import javax.sql.*;
    import java.util.*;
    import javax.ejb.*;
    import javax.naming.*;
    public class Test1Bean implements EntityBean {
    private final static String dbName = "java:comp/env/jdbc/Test1DB";
    private String id;
    private String firstName;
    private EntityContext context;
    private Connection con;
    public String getFirstName() {
    return firstName;
    public String ejbCreate(String id, String firstName) throws CreateException {
    try {
    insertRow(id, firstName);
    } catch (Exception ex) {
    throw new EJBException("ejbCreate: " + ex.getMessage());
    this.id = id;
    this.firstName = firstName;
    return id;
    public String ejbFindByPrimaryKey(String primaryKey)
    throws FinderException {
    boolean result;
    try {
    result = selectByPrimaryKey(primaryKey);
    } catch (Exception ex) {
    throw new EJBException("ejbFindByPrimaryKey: " + ex.getMessage());
    if (result) {
    return primaryKey;
    } else {
    throw new ObjectNotFoundException("Row for id " + primaryKey +
    " not found.");
    public void ejbRemove() {
    try {
    deleteRow(id);
    } catch (Exception ex) {
    throw new EJBException("ejbRemove: " + ex.getMessage());
    public void setEntityContext(EntityContext context) {
    this.context = context;
    public void unsetEntityContext() {
    public void ejbActivate() {
    id = (String) context.getPrimaryKey();
    public void ejbPassivate() {
    id = null;
    public void ejbLoad() {
    try {
    loadRow();
    } catch (Exception ex) {
    throw new EJBException("ejbLoad: " + ex.getMessage());
    public void ejbStore() {
    try {
    storeRow();
    } catch (Exception ex) {
    throw new EJBException("ejbStore: " + ex.getMessage());
    public void ejbPostCreate(String id, String firstName) {
    /*********************** Database Routines *************************/
    private void makeConnection() {
    try {
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup(dbName);
    con = ds.getConnection();
    } catch (Exception ex) {
    throw new EJBException("Unable to connect to database. " +
    ex.getMessage());
    private void releaseConnection() {
    try {
    con.close();
    } catch (SQLException ex) {
    throw new EJBException("releaseConnection: " + ex.getMessage());
    private void insertRow(String id, String firstName) throws SQLException {
    makeConnection();
    String insertStatement =
    "insert into test1 values ( ? , ? )";
    PreparedStatement prepStmt = con.prepareStatement(insertStatement);
    prepStmt.setString(1, id);
    prepStmt.setString(2, firstName);
    prepStmt.executeUpdate();
    prepStmt.close();
    releaseConnection();
    private void deleteRow(String id) throws SQLException {
    makeConnection();
    String deleteStatement = "delete from test1 where id = ? ";
    PreparedStatement prepStmt = con.prepareStatement(deleteStatement);
    prepStmt.setString(1, id);
    prepStmt.executeUpdate();
    prepStmt.close();
    releaseConnection();
    private boolean selectByPrimaryKey(String primaryKey)
    throws SQLException {
    makeConnection();
    String selectStatement =
    "select id " + "from test1 where id = ? ";
    PreparedStatement prepStmt = con.prepareStatement(selectStatement);
    prepStmt.setString(1, primaryKey);
    ResultSet rs = prepStmt.executeQuery();
    boolean result = rs.next();
    prepStmt.close();
    releaseConnection();
    return result;
    private void loadRow() throws SQLException {
    makeConnection();
    String selectStatement =
    "select firstname from test1 where id = ? ";
    PreparedStatement prepStmt = con.prepareStatement(selectStatement);
    prepStmt.setString(1, this.id);
    ResultSet rs = prepStmt.executeQuery();
    if (rs.next()) {
    this.firstName = rs.getString(1);
    prepStmt.close();
    } else {
    prepStmt.close();
    throw new NoSuchEntityException("Row for id " + id +
    " not found in database.");
    releaseConnection();
    private void storeRow() throws SQLException {
    makeConnection();
    String updateStatement =
    "update test1 set firstname = ? where id = ?";
    PreparedStatement prepStmt = con.prepareStatement(updateStatement);
    prepStmt.setString(1, firstName);
    prepStmt.setString(4, id);
    int rowCount = prepStmt.executeUpdate();
    prepStmt.close();
    if (rowCount == 0) {
    throw new EJBException("Storing row for id " + id + " failed.");
    releaseConnection();
    // Test1Bean
    Test1Client
    import java.util.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    public class Test1Client {
    public static void main(String[] args) {
    try {
    Context initial = new InitialContext();
    Object objref =
    initial.lookup("java:comp/env/ejb/SimpleTest1");
    Test1Home home =
    (Test1Home) PortableRemoteObject.narrow(objref,
    Test1Home.class);
    Test1 duke =
    home.create("123", "Duke");
    duke = home.findByPrimaryKey("123");
    System.out.println(duke.getFirstName());
    System.exit(0);
    catch (Exception ex)
    System.err.println("Caught an exception.");
    ex.printStackTrace();
    Test1Home.jav
    import java.rmi.RemoteException;
    import javax.ejb.*;
    public interface Test1Home extends EJBHome {
    public Test1 create(String id, String firstName) throws RemoteException, CreateException;
    public Test1 findByPrimaryKey(String id)
    throws FinderException, RemoteException;
    Test1.java
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface Test1 extends EJBObject {
    public String getFirstName() throws RemoteException;
    application.xml (Test1App.ear)
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
    <description>Application description</description>
    <display-name>Test1App</display-name>
    <module>
    <java>app-client-ic.jar</java>
    </module>
    <module>
    <ejb>ejb-jar-ic.jar</ejb>
    </module>
    </application>
    sun-application.xml (Test1App.ear)
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-application PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.0 J2EE Application 1.4//EN" "http://www.sun.com/software/appserver/dtds/sun-application_1_4-0.dtd">
    <sun-application>
    <pass-by-reference>false</pass-by-reference>
    </sun-application>
    ejb-jar.xml (in ejb-jar-ic.jar)
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
    <display-name>Test1JAR</display-name>
    <enterprise-beans>
    <entity>
    <ejb-name>Test1Bean</ejb-name>
    <home>Test1Home</home>
    <remote>Test1</remote>
    <ejb-class>Test1Bean</ejb-class>
    <persistence-type>Bean</persistence-type>
    <prim-key-class>java.lang.String</prim-key-class>
    <reentrant>true</reentrant>
    <resource-ref>
    <res-ref-name>jdbc/Test1DB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    <security-identity>
    <use-caller-identity/>
    </security-identity>
    </entity>
    </enterprise-beans>
    <assembly-descriptor>
    <method-permission>
    <unchecked/>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Home</method-intf>
    <method-name>remove</method-name>
    <method-params>
    <method-param>java.lang.Object</method-param>
    </method-params>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Home</method-intf>
    <method-name>getHomeHandle</method-name>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>isIdentical</method-name>
    <method-params>
    <method-param>javax.ejb.EJBObject</method-param>
    </method-params>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>getFirstName</method-name>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Home</method-intf>
    <method-name>findByPrimaryKey</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Home</method-intf>
    <method-name>remove</method-name>
    <method-params>
    <method-param>javax.ejb.Handle</method-param>
    </method-params>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>getHandle</method-name>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Home</method-intf>
    <method-name>create</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    <method-param>java.lang.String</method-param>
    </method-params>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Home</method-intf>
    <method-name>getEJBMetaData</method-name>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>getPrimaryKey</method-name>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>remove</method-name>
    </method>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>getEJBHome</method-name>
    </method>
    </method-permission>
    <container-transaction>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>remove</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <method>
    <ejb-name>Test1Bean</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>getFirstName</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    sun-ejb-jar.xml (in ejb-jar-ic.jar )
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.0 EJB 2.1//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-0.dtd">
    <sun-ejb-jar>
    <enterprise-beans>
    <name>Test1JAR</name>
    <ejb>
    <ejb-name>Test1Bean</ejb-name>
    <jndi-name>Test1Bean</jndi-name>
    <resource-ref>
    <res-ref-name>jdbc/Test1DB</res-ref-name>
    <jndi-name>jdbc/ejbTutorialDB</jndi-name>
    </resource-ref>
    </ejb>
    </enterprise-beans>
    </sun-ejb-jar>
    application-client.xml ( in app-client-ic.jar)
    <?xml version="1.0" encoding="UTF-8"?>
    <application-client xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd"><display-name>Test1Client</display-name>
    <ejb-ref>
    <ejb-ref-name>ejb/SimpleTest1</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <home>Test1Home</home>
    <remote>Test1</remote>
    </ejb-ref>
    </application-client>
    sun-application-client.xml ( in app-client-ic.jar)
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-application-client PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.0 Application Client 1.4//EN" "http://www.sun.com/software/appserver/dtds/sun-application-client_1_4-0.dtd">
    <sun-application-client>
    <ejb-ref>
    <ejb-ref-name>ejb/SimpleTest1</ejb-ref-name>
    <jndi-name>Test1Bean</jndi-name>
    </ejb-ref>
    </sun-application-client>
    This is adapted from the Savings Account example. I couldn't get it to work either
    from the source provided though it did work with the provided ear. I have been
    comparing the difference in setting but can see anything.
    I have been able to build and deploy all the other examples in the tutorial but I am somehow
    stuck on ejbs.
    Help would be much appreciated.
    cheers,
    paul

    Just had a look at the client jar. The one generated by the Savings Account provided ear has got a shorter ejb-jar.xml. It doesn't have the functions specified like the one in its ear file.
    Another difference thet the Manifest.mf files for my client jar do not have as many paths specified
    as my test client jar. Don't know why. I am suspecting that maybe there is a slight configuration problem in my j2ee setup. Though I am not sure waht or what to look for. I hope this little bit of
    extra info helps.
    cheers,
    paul.

  • How to design a EJB session beans for a example ERP case study?

    Hello to everyone,
    We have a huge dilemma on how to organize our Beans to support the use case in an information system such as ERP.
    In the use case user after logded in selecting one of the organization and specific sector that works for. (Background logic check relations between user and organizations, user rights, organization states ets.) After the selection of organizations and sectors, users all the time working with these parameters calling different modules of ERP systems and different activities.
    According to the logic of things, to keep certain parameters we should use a Stateful Beans.
    On the other hand, becouse of performance reasons and our need to open a business logic with a service (REST) we woud like to use Stateless Beans. But it is not acceptable to us every time we send the selected organization and the sector.
    It would be ideal if they could are using an Stateless Beans and that they can somehow to access something like "SessionContext in Web applications", where the logged user kept details of the selected parameters.
    We studied many tutorials, but all are based on simple examples, which do not cover our case.
    Are there any best practice recommendations on how to solve the problems of a similar type?

    user13404668 wrote:
    But it is not acceptable to us every time we send the selected organization and the sector.
    Why is that ? Its a perfectly valid pattern when using SLSB.
    regards,
    ram.

  • CMP Entity Beans with custom finders an primary key class

    Hi everybody.
    I've got a Entity with a primary key class and a custom finder. I've defined
    the finder into the xml file like iPlanet's documentation say, but, when I
    try to run the aplication I get the following error:
    Exception: SERVLET-run_failed: Failed in running template:
    /PruebaGI/PruebaGI/pruebagi.jsp, java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    Exception Stack Trace:
    java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    at
    com.netscape.server.servlet.servletrunner.AppInfo.popWebAppDescriptor(Unknow
    n Source)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJsp
    Compiler(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    (Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    RestrictOutput(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(U
    nknown Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479).
    Could anybody help my? I need to resolve this question quickly.
    Thx
    ..

    Hi Juan,
    Sounds like you've defined either a java.lang.String where it should have
    said Java.util.Vector (or the other way around) in the part of the
    deployment descriptor that defines your custom finder method parameter.
    Regards,
    Raymond
    "Juan Jos� Ayuso" <[email protected]> wrote in message
    news:[email protected]...
    Hi everybody.
    I've got a Entity with a primary key class and a custom finder. I'vedefined
    the finder into the xml file like iPlanet's documentation say, but, when I
    try to run the aplication I get the following error:
    Exception: SERVLET-run_failed: Failed in running template:
    /PruebaGI/PruebaGI/pruebagi.jsp, java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    Exception Stack Trace:
    java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    at
    com.netscape.server.servlet.servletrunner.AppInfo.popWebAppDescriptor(Unknow
    n Source)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    atcom.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJsp
    Compiler(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    (Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    RestrictOutput(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(U
    nknown Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    atcom.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479).
    Could anybody help my? I need to resolve this question quickly.
    Thx

  • Global Variable in entity beans

    Dear Friends,
    For example let us think that we have an entity bean for Customer.
    and we created an instance of that bean for customer A and then for customer B.
    So will the global variables in Customer bean be shared across Customer A and Customer B or will there be seperate instances for both Customers.
    Thanking You,
    Chamal.

    Your concepts seem to be a little messed up.
    For entity bean, remember the following:
    1. each object/instance of entity bean represents a record in a database
    2. when a client looks up an entity bean (typcially by using findByPrimaryKey method on home object), the record from database is searched and its values are stored in Entity Beans variables (this is probably what you mean by Global Variable. But thats an incorrect terminology in Java/J2EE. Class attribute is the correct word)
    3. In step 2, you fetched a record and that record is represented by a java object, which is nothing but entity bean.
    4. Now if you make changes to this java object, these changes will persist in the database. That is the essence of entity bean.
    5. If you use the home object's findByPrimaryKey method and look for the same record, no new object will be created. The 2 remote objects will point to the same entity bean on the server.
    6. If yo use the home object's findByPrimaryKey method and look for another record/customer, a new object will be created on the server. This new entity bean will map to the new record.
    Note taht the attribtues of CustomerA and customerB will never be shared.
    hope that helps

  • Can't deploy Simple 2.0 CMP Entity Bean into Sun One Server 7

    Dear all:
    I use JBuilder9 + SunOne Plug-in to
    build a Simple Entity Bean, but I can't
    deploy it into SunOne 7 Server that return
    error message:
    Deployment Error -- Error while running ejbc -- Fatal Error from EJB Compiler -- -- Error while processing CMP beans.
    But I use JBuilder9 + JBoss 3.x Plug-in
    that corrent run on JBoss 3.2 RC
    All code are generated by JBuilder9 EJB Designer
    and only have PK finder.
    Our deploy description flile are:
    ejb-jar.xml=============================
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <display-name>Enterprise1</display-name>
    <ejb-name>Enterprise1</ejb-name>
    <home>untitled1.Enterprise1RemoteHome</home>
    <remote>untitled1.Enterprise1Remote</remote>
    <local-home>untitled1.Enterprise1Home</local-home>
    <local>untitled1.Enterprise1</local>
    <ejb-class>untitled1.Enterprise1Bean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>untitled1.Enterprise1PK</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>Enterprise1</abstract-schema-name>
    <cmp-field>
    <field-name>inDate</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>sndSeq</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>msgSnd</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>msgRcv</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>brkId</field-name>
    </cmp-field>
    </entity>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>Enterprise1</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    =================================
    sun-ejb-jar.xml=====================
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN' 'http://www.sun.com/software/sunone/appserver/dtds/sun-ejb-jar_2_0-0.dtd'>
    <sun-ejb-jar>
    <enterprise-beans>
    <ejb>
    <ejb-name>Enterprise1</ejb-name>
    <jndi-name>Enterprise1Remote</jndi-name>
    </ejb>
    <pm-descriptors>
    <pm-descriptor>
    <pm-identifier>IPLANET</pm-identifier>
    <pm-version>1.0</pm-version>
    <pm-class-generator>com.iplanet.ias.persistence.internal.ejb.ejbc.JDOCodeGenerator</pm-class-generator>
    <pm-mapping-factory>com.iplanet.ias.cmp.NullFactory</pm-mapping-factory>
    </pm-descriptor>
    <pm-inuse>
    <pm-identifier>IPLANET</pm-identifier>
    <pm-version>1.0</pm-version>
    </pm-inuse>
    </pm-descriptors>
    <cmp-resource>
    <jndi-name>jdo/sample-cmp</jndi-name>
    <default-resource-principal>
    <name>mv01</name>
    <password>mv01</password>
    </default-resource-principal>
    </cmp-resource>
    </enterprise-beans>
    </sun-ejb-jar>
    ===========================
    sun-cmp-mappings.xml===============
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-cmp-mappings PUBLIC '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 OR Mapping //EN' 'http://www.sun.com/software/sunone/appserver/dtds/sun-cmp-mapping_1_0.dtd'>
    <sun-cmp-mappings>
    <sun-cmp-mapping>
    <schema>META-INF/mySchema</schema>
    <entity-mapping>
    <ejb-name>Enterprise1</ejb-name>
    <table-name>TSE_MSG_T</table-name>
    <cmp-field-mapping>
    <field-name>inDate</field-name>
    <column-name>INDATE</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>sndSeq</field-name>
    <column-name>SNDSEQ</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>msgSnd</field-name>
    <column-name>MSGSND</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>msgRcv</field-name>
    <column-name>MSGRCV</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>brkId</field-name>
    <column-name>BRKID</column-name>
    </cmp-field-mapping>
    </entity-mapping>
    </sun-cmp-mapping>
    </sun-cmp-mappings>
    =========================

    I remember getting errors like that. The only thing I see is in the map file. When I
    did mine I used TABLENAME.CMPFIELD to map columns to CMP attributes.
    TSE_MSG_T.INDATE
    TSE_MSG_T.SNDSEQ
    for column names in the sun-cmp-mappings.xml file.
    For any other errors set the logging for server1 or which one you are using to "finest".
    Try the deploy, shut down the server, and when you view the log, start at the bottom
    and keep scrolling up to the top of each stack trace and you should get a more
    specific error explanation at about the 3rd or 4th stack trace.

  • EJB Entity beans ,JDBC Stored procedures

    Hi ,
    I am new to EJB and i have some general questions
    ---Every table in an existing database is an entity bean for my application?
    --- how do i define the queries in the entity bean ? (With PreparedStatement ?)
    ---The persistent fields,the ejbmethods,constructors, the table relationships, the prepared statements and stored procedures, are defined in the entity beans ?
    --- how do i define the primary Keys in an Entity Bean !!! I will use EJB 2.1 and BMP
    thanks in advance ...

    Sandeep...
    I have dblinks going all over the place. What you are talking about is a clustered or distributed database. That is the future (or present ) of large databases. My code is set up because an 'architecture' is not yet available in the database itself to support the concepts I've posted to Steve in other threads.
    I fully believe that we'll eventually have BC4J ( or something like it ) directly in the database. I fully believe that the database will load balance these across a cluster of databases, within the database structure itself. For example... there is NOTHING to stop the JVM from deciding that it needs to load balance and submit the thread to a remote machine for processing... independent of creating a "middle tier" outside the database.
    I believed that client-server model was flawed for most (not all) applications in the 80's. Looking at the "application tier" model I have the same feeling that we're creating an overly complex scheme at the wrong layer... just pushed back one stage so that we have to rewrite everything...
    If you go back to the megalithic server design ( or cluster of servers ) with a thin thin front end... just why is the middle tier needed under the scenario I've outlined?
    As such, stored procedures/triggers be they in java or pl/sql seems best bet to me... seeing's how a call spec to java or a pl/sql wrapper is transparent to the caller using jdbc or any other future technology.
    grin Way outside the scope of the universe today... I see it as inevitable.
    null

Maybe you are looking for

  • Temporarily offline for maintenance.

    DW8, XP, check in, check out enabled. Customer updated the site from her local files. I downloaded everything to update my files. I updated the library item which is on each template page. Made changes to each template page. Updated the site, library

  • File content to database scenario

    Hi All,         I am doing file content conversion to database scenario.         In this scenario i got the following problem. Error during database connection to the database URL 'jdbc:mysql://ibxi:3306/javatest' using the JDBC driver 'org.gjt.mm.my

  • 3.0 German Translation issues

    Hello, as said in other threads the German translation of "Export" is still "Unload" also Extras -> Voreinstellungen -> Datenbank -> DDL-Optionen -> Comma sep... * "Right Enclosure in Data is Doubled" is not translated Extras -> Voreinstellungen -> D

  • No order was found for delivery 0000014019 /000100

    Hi All, Iamloading the data for my delivery ZODS from 2lis_12_vcitm from PSA , but getting the following error : No order was found for delivery 0000014019 /000100 . Can any body help me out. Regrds..

  • Re-Install Lost Plugins such as Particle World?

    Hi everyone, while deleting unwanted plugins and files from my computer, I accidentally deleted all the cycore plugins and effects, such as particle world, which all come with After Effects CS4. I was too dumb to go through my trash before I emptied