"Unknown entity bean class"

Hi there,
I'm learning using JPA by writing a web application example that check username and password. I use Sun Application Server 9.1 and Myeclipse to build and deloy.
I've got Runtime Exception:
Unknown entity bean class: class vn.kbnn.dtkb.system.dto.UserDTO, please verify that this class has been marked with the @Entity annotation.
Please help me because this error message is not help, my class have @Entity annotation already. Not redeploy bug also.
Here is my code:
package vn.kbnn.framework.controller;
// ... imports
public abstract class XApplicationManager implements ServletContextListener {
bq. protected static EntityManagerFactory entityManagerFactory; \\ protected static ThreadLocal<EntityManager> threadLocal; \\ protected static ServletContext servletContext; \\ protected static Logger logger;
//... contructors, setters, getters
package vn.kbnn.dtkb.controller;
//... imports
public class ApplicationManager extends XApplicationManager {
bq. public ApplicationManager() {bq. super(); \\ ApplicationManager.entityManagerFactory = Persistence.createEntityManagerFactory("vn.kbnn.dtkb.dao.JPA"); \\ ApplicationManager.threadLocal = new ThreadLocal<EntityManager>(); \\ ApplicationManager.logger = Logger.getLogger("vn.kbnn.dtkb.dao.Logger"); \\ logger.setLevel(Level.ALL);
bq. public void     contextInitialized(ServletContextEvent ce) {bq. ApplicationManager.servletContext = ce.getServletContext();
bq. public void contextDestroyed(ServletContextEvent ce) {}
package vn.kbnn.framework.dao;
//... imports
public abstract class XDAO {
bq. protected EntityManager em;
bq. public XDAO(EntityManagerFactory emf, ThreadLocal<EntityManager> threadLocal){bq. this.em = getEntityManager(_emf, _threadLocal);
     private EntityManager getEntityManager(EntityManagerFactory emf, ThreadLocal<EntityManager> threadLocal) {
bq. EntityManager manager = _threadLocal.get(); \\ if (manager == null || !manager.isOpen()) {bq. manager = _emf.createEntityManager(); \\ _threadLocal.set(manager);
          return manager;
package vn.kbnn.framework.system.dao;
//... imports
public abstract class XUserDAO extends XDAO {
bq. public XUserDAO(EntityManagerFactory emf, ThreadLocal<EntityManager> threadLocal) {bq. super(_emf, _threadLocal);
package vn.kbnn.dtkb.system.dao;
//... imports
public class UserDAO extends XUserDAO {
bq. public UserDAO(EntityManagerFactory emf, ThreadLocal<EntityManager> threadLocal) {bq. super(_emf, _threadLocal);
     public UserDTO findByPk(String _pk) throws RuntimeException {
bq. try {bq. UserDTO instance = em.find(UserDTO.class, _pk);
bq. return instance;
          } catch (RuntimeException re) {
bq. throw re;
package vn.kbnn.framework.facade;
public abstract class XFacade {
package vn.kbnn.framework.system.facade;
//... imports
bq. public abstract class XLoginFacade extends XFacade { \\ public abstract XUserDTO login(String _id, String _password) throws RuntimeException, XProfessionalException;
package vn.kbnn.dtkb.login.facade;
//... imports
public class LoginFacade extends XLoginFacade {
bq. public UserDTO login(String id, String password) throws RuntimeException, XProfessionalException{bq. UserDTO userDTO = new UserDTO(); \\ UserDAO userDAO = new UserDAO(ApplicationManager.getEntityManagerFactory(), ApplicationManager.getThreadLocal()); \\ try {bq. userDTO = userDAO.findByPk(_id);
bq. if (userDTO.getPassword() == _password) {
bq. bq. return userDTO;
bq. } else {
bq. bq. XProfessionalException xProfessionalException = new XProfessionalException("Id and password are not matched.");
bq. throw xProfessionalException;
bq. bq. }
bq. } catch (RuntimeException re){bq. throw re;
package vn.kbnn.framework.dto;
//... imports
@SuppressWarnings("serial")
@MappedSuperclass
public abstract class XDTO implements java.io.Serializable {
bq. @Id     @Column(name="pk", unique=true, nullable=false, insertable=true, updatable=false, length=8) \\ private String pk; \\ @Column(name="sid", unique=true, nullable=false, insertable=true, updatable=false, length=8) \\ private String sid;
//... constructors, setters, getters
package vn.kbnn.framework.system.dto;
//...imports
bq. @SuppressWarnings("serial") \\ @MappedSuperclass \\ public abstract class XUserDTO extends XDTO { \\ @Column(name="password", unique=false, nullable=false, insertable=true, updatable=true, length=8) \\ private String password;
//... contructors, setters, getters
package vn.kbnn.dtkb.system.dto;
*//... imports*
*@SuppressWarnings("serial")*
*@Entity*
*@Table(name = "t_User", schema = "DTKB")*
*public class UserDTO extends XUserDTO {*
bq. *public UserDTO() {*
bq. bq. super();
bq. *     }*
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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" version="1.0">
bq. <persistence-unit name="vn.kbnn.dtkb.dao.JPA" transaction-type="JTA">bq. <jta-data-source>jdbc/dtkb</jta-data-source>
     </persistence-unit>
</persistence>

I've got the same error for a long time and I still can't fix it, did you?

Similar Messages

  • IllegalArgumentException: Unknown entity bean class

    Hi. I try to make a connection with mysql database by using entity classes which i create via Netbeans' tools. But when i try to use the create method for entity persist, in the entity controller class, i get an error message like that;
    (The User class is marked with the @Entity annonation)
    java.lang.IllegalArgumentException: Unknown entity bean class: class entity.User, please verify that this class has been marked with the @Entity annotation.
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:576)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:460)
    at controller.UserJpaController.findUser(UserJpaController.java:125)
    at controller.UserJpaController.create(UserJpaController.java:43)
    at bean.UserBean.save(UserBean.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
    i use glass fish v3
    persistence.xml is automaticaly created by netbeans.
    Please help.
    Edited by: MOD on Aug 5, 2010 9:41 AM

    And this is the JPAController class which i created automaticly using Netbeans IDE tools.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package controller;
    import controller.exceptions.NonexistentEntityException;
    import controller.exceptions.PreexistingEntityException;
    import entity.User;
    import java.util.List;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import javax.persistence.Query;
    import javax.persistence.EntityNotFoundException;
    import javax.persistence.criteria.CriteriaQuery;
    import javax.persistence.criteria.Root;
    * @author PC
    public class UserJpaController {
        public UserJpaController() {
            emf = Persistence.createEntityManagerFactory("MyPersonelWebBlogPU");
        private EntityManagerFactory emf = null;
        public EntityManager getEntityManager() {
            return emf.createEntityManager();
        public void create(User user) throws PreexistingEntityException, Exception {
            EntityManager em = null;
            try {
                em = getEntityManager();
                em.getTransaction().begin();
                em.persist(user);
                em.getTransaction().commit();
            } catch (Exception ex) {
                if (findUser(user.getUsername()) != null) {
                    throw new PreexistingEntityException("User " + user + " already exists.", ex);
                throw ex;
            } finally {
                if (em != null) {
                    em.close();
        public void edit(User user) throws NonexistentEntityException, Exception {
            EntityManager em = null;
            try {
                em = getEntityManager();
                em.getTransaction().begin();
                user = em.merge(user);
                em.getTransaction().commit();
            } catch (Exception ex) {
                String msg = ex.getLocalizedMessage();
                if (msg == null || msg.length() == 0) {
                    String id = user.getUsername();
                    if (findUser(id) == null) {
                        throw new NonexistentEntityException("The user with id " + id + " no longer exists.");
                throw ex;
            } finally {
                if (em != null) {
                    em.close();
        public void destroy(String id) throws NonexistentEntityException {
            EntityManager em = null;
            try {
                em = getEntityManager();
                em.getTransaction().begin();
                User user;
                try {
                    user = em.getReference(User.class, id);
                    user.getUsername();
                } catch (EntityNotFoundException enfe) {
                    throw new NonexistentEntityException("The user with id " + id + " no longer exists.", enfe);
                em.remove(user);
                em.getTransaction().commit();
            } finally {
                if (em != null) {
                    em.close();
        public List<User> findUserEntities() {
            return findUserEntities(true, -1, -1);
        public List<User> findUserEntities(int maxResults, int firstResult) {
            return findUserEntities(false, maxResults, firstResult);
        private List<User> findUserEntities(boolean all, int maxResults, int firstResult) {
            EntityManager em = getEntityManager();
            try {
                CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
                cq.select(cq.from(User.class));
                Query q = em.createQuery(cq);
                if (!all) {
                    q.setMaxResults(maxResults);
                    q.setFirstResult(firstResult);
                return q.getResultList();
            } finally {
                em.close();
        public User findUser(String id) {
            EntityManager em = getEntityManager();
            try {
                return em.find(User.class, id);
            } finally {
                em.close();
        public int getUserCount() {
            EntityManager em = getEntityManager();
            try {
                CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
                Root<User> rt = cq.from(User.class);
                cq.select(em.getCriteriaBuilder().count(rt));
                Query q = em.createQuery(cq);
                return ((Long) q.getSingleResult()).intValue();
            } finally {
                em.close();
    }When i instantiate this JPAController class and use its create method to persist a User it gives me the error which i posted in my first message.

  • Multiple instances of the same entity bean?

    I am designing a J2EE application that is made up of a number of separate components that each have a well-defined responsibility. Each component is made up of one or more J2EE components (web clients and EJBs). I want to design the application such that it is easy in the future to deploy each component (or a group of components) on different servers. In order to do this I need to make sure that the interfaces between each component are exposed as remote interfaces (but I will use local interfaces inside each component). However, there are a number of entity beans that need to be accessed by more than one component. I am wondering how best to expose these entity beans. I believe there are a number of options:
    1. Expose remote interfaces on each of the shared entity beans. The disadvantage of this approach is that it is inefficient and that I will not be able to take advantage of container managed relationships. (I am intending to use container managed persistence.)
    2. Create a facade object (stateful session bean) for each of the entity beans which exposes a remote interface and in turn accesses the shared entity beans locally. The disadvantage of this approach is that I have to create some extra EJBs and that I cannot directly make use of container managed relationships etc from the client component.
    3. I don't know if this is an option but I am wondering whether I can deploy a copy of each shared entity bean with each application component. The advantage of this approach is that the component would access the entity locally and could make use of container managed relationships. However, I don't know what the issues are with having more than one instance (per primary-key) of an entity in the same application. I don't know whether this would cause errors of whether they would get out of sync (because different instances with the same primary key would be updated by different clients). Initially each component would be deployed in the same server but later they would be deployed in different servers. In both cases with this option each component (JAR) would have copies of the shared entity bean classes.
    Any suggestions as to the best approach and whether the last option is feasible would be much appreciated.
    Thanks.

    I think 2 beats 1. The main reason being to minimise the number of network calls. You're basically asking, are fascades a good idea? and the answer is yes.
    You can obviously do 3 in different app servers. However you'll need to configure your app servers so they can handle the fact that they're not the only ones updating the database. This is to handle concurrency as you mentioned. How you do this will depend on your app server and will affect performance, but shouldn't be a problem.
    I think you should definately decide up front what's going in different app servers, I dunno if 3 would work in the same app server.
    Why do you would want to use multiple app servers?
    Why not have everything in the same app?
    Is is just the 1 database?
    You can use clustering for scalability.

  • Deploying BMP Entity Bean with primary key calss

    Hi,
    I am using EJB 2.0 with and websphere studio 5.0 and database is sql server 2000.
    My BMP Entity bean has a primary key class.From my client I am invoking the Entity Bean by calling it's findbyprimarykey method.
    The home interface of my findbyprimarykey method returns a class of type Remote.But in the Entity Bean class,the return type is the primarykey class type.
    My problem is invoking this findbyprimarykey from the client to get the remote interface so that the other business methods of the entity bean can be called.
    The control goes into the ejbFindbyPrimaryKey but when it is returing from the Entity Bean class,it gives a remote exception (as the return type in Entity Bean class and Home interface are different for the findbyprimarykey method).
    I think that somewhere in the deployment decriptor in my websphere,i have to specify the primarykey class type,which i am missing out and hence getting the error.
    Please help me out with your advice and solution.
    Thanks
    Rahul Priyadarshi

    Hi,
    Sorry to disturb you again.
    Even my code is also almost the same....i am pasting the code below...Please go through it and let me know if I have made any mistake..
    EditVendorEntityBean.....(Bean Class)
    package code.beans.EditVendor;
    import code.beans.dataAccess.*;
    import javax.ejb.CreateException;
    import javax.ejb.RemoveException;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    import javax.ejb.EJBException;
    import javax.ejb.FinderException;
    import javax.ejb.ObjectNotFoundException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import java.sql.*;
    import javax.sql.*;
    import java.util.*;
    * Bean implementation class for Enterprise Bean: EditVendorEntity
    public class EditVendorEntityBean implements javax.ejb.EntityBean {
         private static Hashtable dataSources = new Hashtable();
         private String username;
    private int Vendor_ID;
    private int Category_Id;
    private String Category_Name;
    private String Vendor_Name;
    private String Vendor_Address1;
    private String Vendor_Address2;
    private String Contact_Name;
    private String Home_Phone;
    private String Work_Phone;
    private String email;
    private String faxno;
    private String userloginname;
    private boolean dirtyFlag = false;
    private EntityContext context;
    private static final String DS_NAME = "jdbc/spiPOPS";
    Connection con = null;
    Statement stmt = null;
    PreparedStatement st = null;
    ResultSet res = null;
         //***********************Business Methods*********************
    // Begin of Busines Methods
    public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax) {
              System.out.println("in setData where Vendor Id= "+ Vendor_ID);
                   boolean status=false;
                   boolean existing=false;
                   ArrayList cat=new ArrayList();
                   try
                        cat=getcategorylist(this.Vendor_ID);
                   catch(SQLException e)
                        System.out.println("Could not get category list");
                   System.out.println("Size of cat array -->" + cat.size() + " and string array size -->" + catname.length);
                   if(catname.length>0)
                        //Removing unwanted vendor categories for a particular vendor id
                        for(int i=0;i<cat.size();i++)
                                  existing=false;
                                  String tempdata=(String)cat.get(i);
                                  for(int j=0;j<catname.length;j++)
                                       if(tempdata.equals(catname[j]))
                                            existing=true;
                                  if(!existing)
                                       try
                                            delvencat(this.Vendor_ID,tempdata.trim());
                                       catch(SQLException e)
                                            System.out.println("Could not delete record in POPS_VENDOR_CATEGORY for -->" + tempdata);
                   //Adding new vendor categories for a particular vendor
                        try
                                  for(int i=0;i<catname.length;i++)
                                       status=false;
                                       String strcat=catname;
                                       status=checkcat(this.Vendor_ID,strcat.trim());
                                       if(!status)
                                            insertvencat(this.Vendor_ID,strcat.trim());
                        catch(SQLException e)
                                  System.out.println("Could not insert or select from POPS_VENDOR_CATEGORY table");
                   this.Vendor_Name          =vendorname;
              this.Vendor_Address1     =vendadd1;
              this.Vendor_Address2     =vendadd2;
              this.Contact_Name          =vendcontact;
              this.Work_Phone               =venoff;
              this.Home_Phone               =venres;
              this.email                    =mailid;
              this.faxno                    =venfax;
                   dirtyFlag = true;
                   System.out.println("Leaving set data method");
    public Vector getData() {
         Vector vctRec=new Vector();
         ArrayList arrdatas = new ArrayList();
         arrdatas.add(""+this.Vendor_ID);
         arrdatas.add(this.Vendor_Name);
         arrdatas.add(this.Vendor_Address1);
         arrdatas.add(this.Vendor_Address2);
         arrdatas.add(this.Contact_Name);
         arrdatas.add(this.Work_Phone);
         arrdatas.add(this.Home_Phone);
         arrdatas.add(this.email);
         arrdatas.add(this.faxno);
         vctRec.addElement(arrdatas);
         ArrayList cat=new ArrayList();
              try
              System.out.println("Calling getcategorylist from getdata with vendorid-->" + this.Vendor_ID);
              cat          = getcategorylist(this.Vendor_ID);
         catch(SQLException e)
                   System.out.println("Could not get datas for category list");
         vctRec.addElement(cat);
         ArrayList allcats=new ArrayList();
         try
                        allcats          = getallcategorylist();
              catch(SQLException e)
                        System.out.println("Could not get datas for category list");
         vctRec.addElement(allcats);
              dirtyFlag = false;
         System.out.println("Before return statement in getdata with vector size -->" + vctRec.size());
              return vctRec;
    // End of Business Methods
    //**************************Entity Bean Methods*******************************
         * ejbActivate
         public void ejbActivate() {
              Vendor_ID = Integer.parseInt((String)context.getPrimaryKey());
         System.out.println("Inside ejbActivate Vendor_ID-->"+ Vendor_ID);
         * ejbLoad
         public void ejbLoad() {
              System.out.println("Inside ejbLoad ********" );
    try {
    loadRow();
    }catch (Exception ex) {
              System.out.println("Failed in loadRow()");
    throw new EJBException("ejbLoad: " +
    ex.getMessage());
         * ejbPassivate
         public void ejbPassivate() {
         System.out.println("Inside ejbPassivate " );
    Vendor_ID = 0;
         * ejbRemove
         public void ejbRemove() throws javax.ejb.RemoveException {
              //Empty Method
         * ejbStore
         public void ejbStore() {
    System.out.println("Inside ejbStore " );
    try {
    storeRow();
    }catch (Exception ex) {
              System.out.println("Exception thrown in storeRow" + ex.getMessage());
    throw new EJBException("ejbLoad: " +
    ex.getMessage());
         * getEntityContext
         public javax.ejb.EntityContext getEntityContext() {
              return context;
         * setEntityContext
         public void setEntityContext(javax.ejb.EntityContext ctx) {
              System.out.println("Inside setEntityContext " );
    try{
         con = getConnection(DS_NAME);
         System.out.println("DB Connection Created!!");
    catch(Exception e){
    this.context = ctx;
         * unsetEntityContext
         public void unsetEntityContext() {
    System.out.println("Inside unsetEntityContext " );
    closeDbConnection(con, res, st);
    this.context = null;
         * ejbCreate
         //code.beans.EditVendor.EditVendorEntityKey
         public code.beans.EditVendor.EditVendorEntityKey ejbCreate(String vendorid)
              throws javax.ejb.CreateException {          
              return new EditVendorEntityKey(vendorid);
              //return null;
         * ejbPostCreate
         public void ejbPostCreate(String vendorid) throws javax.ejb.CreateException {
              //Empty
         * ejbFindByPrimaryKey
         //code.beans.EditVendor.EditVendorEntityKey
         public code.beans.EditVendor.EditVendorEntityKey ejbFindByPrimaryKey(
              code.beans.EditVendor.EditVendorEntityKey primaryKey)
              throws javax.ejb.FinderException {
    try {
    if(selectByPrimaryKey(Integer.parseInt(primaryKey.getVendorId()))) {
              System.out.println("Leaving the findbyprimarykey method from the entity bean");
         return primaryKey;
         //return null;
    }else {
         throw new ObjectNotFoundException
         ("Row for id " + primaryKey + " not found.");
    }catch (Exception ex) {
    throw new EJBException("EXCEPTION IN ejbFindByPrimaryKey :- " + ex.getMessage());
         /*********************** Database Utility Routines *************************/
    private boolean selectByPrimaryKey(int priKey)
    throws SQLException {
         System.out.println("inside selectByPrimaryKey for primary key " + priKey);
    String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR WHERE VENDOR_ID = " + priKey;
    System.out.println("in selectByPrimaryKey where queryString is: "+ queryStr);
              stmt = con.createStatement();
    ResultSet result = stmt.executeQuery(queryStr);
    if(!result.next()) {
    stmt.close();
         System.out.println("Did not find "+priKey);
    return false;
    else { //Found the primaryKey
    Vendor_ID = result.getInt("VENDOR_ID");
    stmt.close();
    return true;
    private void loadRow() throws SQLException {
              System.out.println("inside loadRow ...");
              stmt = con.createStatement();
              String queryStr = "SELECT VENDOR_NAME,VENDOR_ADDRESS1,VENDOR_ADDRESS2,CONTACT_NAME,HOME_PHONE,WORK_PHONE,EMAIL_ID,FAX_NO " +
                                  "FROM POPS_VENDOR WHERE VENDOR_ID=" + Vendor_ID;
              System.out.println("Inside loadRow()***********"+queryStr);
              ResultSet result = stmt.executeQuery(queryStr);
              ArrayList catadatas=new ArrayList();
         if(!result.next())
         throw new SQLException("No record for primary key" + Vendor_ID);
              this.Vendor_ID               =Vendor_ID;
                        this.Vendor_Name          =result.getString("VENDOR_NAME");
                        this.Vendor_Address1     =result.getString("VENDOR_ADDRESS1");
                        this.Vendor_Address2     =result.getString("VENDOR_ADDRESS2");
                        this.Contact_Name          =result.getString("CONTACT_NAME");
                        this.Home_Phone               =result.getString("HOME_PHONE");
                        this.Work_Phone               =result.getString("WORK_PHONE");
                        this.email                    =result.getString("EMAIL_ID");
                        this.faxno                    =result.getString("FAX_NO");
                             System.out.println("Leaving loadrow method with loaded datas for vendor -->" + Vendor_ID);
                             stmt.close();
    private ArrayList getcategorylist(int vendor) throws SQLException{
              String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID=" + vendor;
              System.out.println("Query for the cat list --> " + queryStr);
              stmt = con.createStatement();
              ResultSet result = stmt.executeQuery(queryStr);
              ArrayList catdatas=new ArrayList();
    try{
                   while(result.next())
                        catdatas.add(result.getString("VENDOR_CAT"));
              catch (SQLException e){
                   stmt.close();
                   System.out.println("Could not retrieve datas for Category list");
              stmt.close();
              System.out.println("size off array for cat -->" + catdatas.size() + " and datas ->" + catdatas);
              return catdatas;
         private ArrayList getallcategorylist() throws SQLException{
                   //String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY";
                   StringBuffer strquery=new StringBuffer(20);
                   strquery.append("SELECT DISTINCT(CATEGORY_NAME) FROM POPS_CATEGORY");
                   stmt = con.createStatement();
                   //ResultSet result = stmt.executeQuery(queryStr);
                   ResultSet result = stmt.executeQuery(strquery.toString());
                   ArrayList catdatas=new ArrayList();
                   try{
                        while(result.next())
                                  //catdatas.add(result.getString("VENDOR_CAT"));
                                  catdatas.add(result.getString("CATEGORY_NAME"));
                   catch (SQLException e){
                             stmt.close();
                             System.out.println("Could not retrieve datas for All Category list");
                   stmt.close();
                   return catdatas;
         private void delvencat(int vendor,String vencat) throws SQLException {
              int update=-1;
              stmt = con.createStatement();
              String queryStr ="DELETE FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + vencat.toUpperCase() + "'";
              System.out.println("Delete query --> " + queryStr);
              update= stmt.executeUpdate(queryStr);
              if(update!=1)
                   System.out.println("Did not find data to delete");
              stmt.close();
         private void insertvencat(int vendor,String vencat) throws SQLException {
              int update=-1;
              String queryStr ="INSERT INTO POPS_VENDOR_CATEGORY(VENDOR_ID,VENDOR_CAT)" +
                                  " VALUES(" + vendor +",'" + vencat + "')";
              System.out.println("Insert query --> " + queryStr);
              stmt = con.createStatement();
              update=stmt.executeUpdate(queryStr);
              if(update!=1)
                   System.out.println("Could not insert records in the database");
              stmt.close();
         private boolean checkcat(int vendor,String catven) throws SQLException {
              boolean datastatus=false;
              String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + catven.toUpperCase() + "'";
              stmt = con.createStatement();
              ResultSet result = stmt.executeQuery(queryStr);
              datastatus=result.next();
              stmt.close();
              return datastatus;
    private void storeRow() throws SQLException {
                   System.out.println("Inside ejb store");
         if (!dirtyFlag) {
         System.out.println("Skipping the UPDATE because object is not dirty");
         return;
         CallableStatement cs=null;
    try{
                        cs = con.prepareCall("EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                        System.out.println("\n\n SQL Statement : \n " + "EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                        cs.executeUpdate();
              catch (SQLException e){
                        cs.close();
                        System.out.     println("\n\n Error in calling stored procedure POPS_INSERT_NEW_REQUEST \n\n"+ e.getMessage() + "\n\n");
              cs.close();
              dirtyFlag = false;
         private Connection getConnection(String dbName) throws SQLException
              String configuredDataSourceName = null;
              if (dbName == null) {
                   System.out.println("Attemp to get connection failed. The requested database name is null");
              DataSource dbSource = getDataSource(dbName);
              return dbSource.getConnection();
         private DataSource getDataSource(String dbName)
              // looking from cache;
              DataSource dbSource = (DataSource) dataSources.get(dbName);
              if (dbSource == null) { //we need to find it from JNDI
                   try {
                        Context ic = new InitialContext();
                        dbSource = (DataSource) ic.lookup(dbName);
                        dataSources.put(dbName, dbSource);
                   }catch (NamingException e){
              return dbSource;
         * User calls this function to safely close an connection
         * @param connt The connection a datasource
         * @param rs The resulSet inside this connection
         * @param statement The statement associate with this connection
         private void closeDbConnection(Connection cont,ResultSet rs,Statement statement)
              if (rs != null)
              try {
                        rs.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
              if (statement != null)
                   try {
                        statement.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
              if (cont != null)
                   try {
                        cont.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
         } //closeDbConnection
    EditVendorEntity (Remote Interface)
    package code.beans.EditVendor;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    import java.util.*;
    * Remote interface for Enterprise Bean: EditVendorEntity
    public interface EditVendorEntity extends javax.ejb.EJBObject {
         public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax)
                   throws RemoteException;
    public Vector getData() throws RemoteException;
    EditVendorEntityHome (Home Interface)
    package code.beans.EditVendor;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.FinderException;
    import javax.ejb.DuplicateKeyException;
    import javax.ejb.EJBHome;
    import java.util.*;
    * Home interface for Enterprise Bean: EditVendorEntity
    public interface EditVendorEntityHome extends javax.ejb.EJBHome {
         * Creates an instance from a key for Entity Bean: EditVendorEntity
         public code.beans.EditVendor.EditVendorEntity create(String vendorid)
              throws javax.ejb.CreateException, java.rmi.RemoteException;
         * Finds an instance using a key for Entity Bean: EditVendorEntity
         public code.beans.EditVendor.EditVendorEntity findByPrimaryKey(
              code.beans.EditVendor.EditVendorEntityKey Vendor_ID)
              throws javax.ejb.FinderException, java.rmi.RemoteException;
    EditVendorEntityKey (Primary Key Class)
    package code.beans.EditVendor;
    * Key class for Entity Bean: EditVendorEntity
    public class EditVendorEntityKey implements java.io.Serializable {
         static final long serialVersionUID = 3206093459760846163L;
         public String primkey;
         * Creates an empty key for Entity Bean: EditVendorEntity
         public EditVendorEntityKey() {  }
         public EditVendorEntityKey(String primarykey) {     
              this.primkey=primarykey;
         public String getVendorId() {
    return primkey;
         * Returns true if both keys are equal.
         public boolean equals(java.lang.Object otherKey) {
              if (otherKey instanceof code.beans.EditVendor.EditVendorEntityKey) {
                   code.beans.EditVendor.EditVendorEntityKey o =
                        (code.beans.EditVendor.EditVendorEntityKey) otherKey;
                   return (primkey.equals(otherKey));
              return false;
         * Returns the hash code for the key.
         public int hashCode() {
              return (primkey.hashCode());
    Please go through and give me your comments and solution...
    Thanks in advance
    Rahul

  • Container Managed Entity Beans and Client Identifier in Oracle

    Is it possible to use Container Managed Entity Beans (EJB with CMP)
    in a way that the Oracle database sessions still know the
    individual Client Identifiers of the actual users
    (not just the Identifier of the proxy user defined in the
    Connection Pool)?
    If Yes: How?
    If No: The consequence would be that the
    technologies EJB with CMP cannot be user together with
    Oracle Virtual Private Databases (VPN) because VPN requires
    some kind of Client Identifier.
    I am grateful for any hint.
    Regards,
    Martin Siepmann
    +49 (0)163 / 7765328

    Not quite an auto-incrementing PK, but it is managed by the container. the following is from the turorial
    Generating Primary Key Values
    For some entity beans, the value of a primary key has a meaning for the business entity. For example, in an entity bean that represents a phone call to a support center, the primary key might include a time stamp that indicates when the call was received. But for other beans, the key's value is arbitrary--provided that it's unique. With container-managed persistence, these key values can be generated automatically by the EJB container. To take advantage of this feature, an entity bean must meet these requirements:
    * In the deployment descriptor, the primary key class is defined as a java.lang.Object. The primary key field is not specified.
    * In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object.
    * In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object.
    In these entity beans, the primary key values are in an internal field that only the EJB container can access. You cannot associate the primary key with a persistent field or any other instance variable. However, you can fetch the bean's primary key by invoking the getPrimaryKey method, and you can locate the bean by invoking its findByPrimaryKey method.
    Maybe that is good enough
    christina

  • Problem in deploying CMP entity bean 2.0 in J2EE 1.4

    i am trying to deploy a cmp entity bean 2.0 using j2ee1.4 deployment tool. the bean uses sql server as the database. i have successfully created a coonection pool for sql server using j2ee admin console. the entity bean class files are successfully compiled. but while deploying the entity bean i am not able to set the database settings and jndi name for the bean. can one please guide me in the deployment steps in j2ee1.4.
    mohit

    Mohit,
    We are discussing this topic in the fourm below. I'm having the same problem so feel free to join our conversation.
    ~Howard
    http://forum.java.sun.com/thread.jsp?forum=13&thread=478054

  • Problems deploying entity beans with local interfaces on Jboss?

    I'm trying to deploy a simple entity bean using local interfaces on Jboss 3.2.1 and I obtain the following exception:
    19:08:51,875 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.2.2
    Warning: The entity bean class must not be defined as abstract.
    19:08:51,875 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.4.7.1
    Warning: The primkey-field element must name a public field in the bean implemen
    tation class.
    Any idea?
    Thanks,
    Marco

    I guess you are missing <cmp-version>2.x</cmp-version> for your first warning and <primkey-field>primary key field </primkey-field> for you second warning in your ejb-jar.xml

  • Deploying entity beans with Local interfaces on Jboss

    Hi, I'm trying to deploying a simple entity bean on Jboss. The EJB has been developed with Local Interfaces because then I want to access it with a session bean facade.
    I get the following error:
    <!-- ERROR BEGIN -->
    23:41:25,984 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.2.2
    Warning: The entity bean class must not be defined as abstract.
    23:41:25,984 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.4.7.1
    Warning: The primkey-field element must name a public field in the bean implemen
    tation class.
    <!-- ERROR END -->
    I'm following what is wrote in the Professional EJB editeb by wrox?
    Is it possible to deploy an entity bean alone with Local interfaces? Is there something I'm missing? It's true that I defined the implementation class as abstract, but because there are abstract getter/setter methods.
    Thanks for any help,
    Marco

    Greetings,
    Hi, I'm trying to deploying a simple entity bean on
    Jboss. The EJB has been developed with Local
    23:41:25,984 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.2.2
    Warning: The entity bean class must not be defined as abstract.
    23:41:25,984 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.4.7.1
    Warning: The primkey-field element must name a public field in
    the bean implementation class.What version of JBoss are you using? These errors indicate container compliance with EJB spec 1.1, not 2.0 to which your CMP beans are written. Download the latest JBoss release version - 3.2.1 - and you should not see this problem.
    Is it possible to deploy an entity bean alone with
    Local interfaces? Is there something I'm missing? It'sYes it is (no, you are not "missing something" ;). In fact, this is recommended practice in most cases under CMP 2.0 - CMR having been a major impetus to the development of Local interfaces in the specification. ;)
    true that I defined the implementation class as
    abstract, but because there are abstract getter/setter
    methods.No problems. You are "right on track" for CMP 2.0. :)
    Thanks for any help,
    MarcoRegards,
    Tony "Vee Schade" Cook

  • How do I create an Entity Bean with unknown primary keys

    Hi,
    Can a good folk help me.
    I am mapping an entity bean to an oracle table for the purpose of logging . I do not need a primary key contraint on this table. How do I specify in my entity bean file descriptor not to use any field for primary key ...
    I have done this so far...
    in my ejb.xml file - I set....
    <prim-key-class>java.lang.Object</prim-key-class>
    and deleted ....
    <primkey-field>...</primkey-field>
    My table structure is .....
    CREATE TABLE FAMS_REQUEST_LOG (
    EDITEDBY VARCHAR2(20),
    OLDTRANSDATE DATE,
    REQUESTID VARCHAR2(30) NOT NULL,
    OLDQTY NUMBER(20),
    NEWQTY NUMBER(20),
    NEWTRANSDATE DATE)
    but I still get this error message on deploying...
    [#|2006-03-01T14:30:29.250+0100|INFO|sun-appserver-pe8.1_02|javax.enterprise.system.tools.deployment|_ThreadID=19;|Total Deployment Time: 11000 msec, Total EJB Compiler Module Time: 0 msec, Portion spent EJB Compiling: 0%|#]
    [#|2006-03-01T14:30:29.265+0100|SEVERE|sun-appserver-pe8.1_02|javax.enterprise.system.tools.deployment|_ThreadID=19;|Exception occured in J2EEC Phase
    com.sun.enterprise.deployment.backend.IASDeploymentException: Fatal Error from EJB Compiler -- JDO74046: JDOCodeGenerator: Caught a MappingConversionException loading or creating mapping model for application 'fixassetenterpriseapp' module 'FixAssetEnterpriseApp-EJBModule': JDO71030: There is no column in table FAMS_REQUEST_LOG which can be used to support the servers implementation of unknown key classes.
    at com.sun.ejb.codegen.CmpCompiler.compile(CmpCompiler.java:274)
    at com.sun.ejb.codegen.IASEJBC.doCompile(IASEJBC.java:615)
    at com.sun.ejb.codegen.IASEJBC.ejbc(IASEJBC.java:563)
    at com.sun.enterprise.deployment.backend.EJBCompiler.preDeployApp(EJBCompiler.java:340)
    at com.sun.enterprise.deployment.backend.EJBCompiler.compile(EJBCompiler.java:209)
    at com.sun.enterprise.deployment.backend.AppDeployer.runEJBC(AppDeployer.java:284)
    at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:176)
    at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:107)
    at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:146)
    at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:71)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:633)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:188)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:520)
    at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:143)
    at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:172)
    |#]
    Dotun

    you will have to create a sequence and a trigger
    CREATE SEQUENCE <SEQUENCE NAME>
    INCREMENT BY  1
    START WITH  1
    NOCACHE
    /this sequence will guarantee that each requested number is unique
    the trigger will select from this sequence and insert the obtained value in the new record
    CREATE OR REPLACE TRIGGER <TRIGGER NAME>
    BEFORE INSERT ON <TABLE NAME>
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
        BEGIN
            select
                <SEQUENCE NAME>.nextval
            into
                :NEW.<COLUMN NAME>
            from
                dual;
        END;
    [/CODE]
    this will always take the value from the sequence, even if you already provided a value yourself
    (otherwise you will first have to test if :NEW.<column name> is null, but I wouldn't do this for a key column.
    if you need the generated key back for further processing (inserting it into a child table for example), you can use the returning clause on the insert statement
    see the oracle documentation for more information about sequences, triggers and the returning clause
    greetings
    Freek D
    I am new to Oracle and need to know how to create a table that uses an automatic incrementation on a primay key for it's default. I need the uniqueness automatically managed by the DBMS.. This activity is know as setting the Column (primary key with identity) in Ms-SQL..
    Your help would be appreciated greatly....
    Thanks....

  • Entity bean with another class as primary key generator class

    Hi All,
    I have a CMP entity bean in which I generate the primary key using my own class know as unique id generator.
    I use it in ejbCreate method in the following manner
    public Long ejbCreate(HospitalData hospitalData) throws CreateException{
              Long myid = new Long(UniqueIdGenerator.getId());
              System.out.println("My id generated ====== "+myid);
              this.hospitalid = myid;
              System.out.println("My id generated ====== "+this.hospitalid);
              System.out.println("Came in ejbCreate method of HospitalEJB");
              this.hospitalname = hospitalData.getHospitalname();          
              return null;
    Can you tell me how I map this primary key in my ejb-jar.xml and jbosscmp-jdbc.xml.
    Anyhelp would be appreciated.
    Thanks
    Sameer

    "Bhamu" <[email protected]> wrote in message
    news:9keuo4$[email protected]..
    I am trying to develop an entity bean attached to a key which have a
    composite key using Primary Key Class. When I use the findByPrimaryKey
    method of the bean it throws an exception as follows,I notice that you are using the reference CMP plugin.
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)I'm also willing to bet that you may have created your own primary key class
    with a single field, rather than using the fields type as a primitive
    primary key class. If you do this, then SQLPersistenceManager will break.
    It is badly written, and has some stupid assumptions. The one I remember
    the most is that if you only have one primary key field, then
    SQLPersistenceManager assumes you have used a primitive type such as
    java.lang.String or java.lang.Integer, to represent it, rather than creating
    your own <Enity>Pk.java file.
    SQLPersistenceManager works for toy examples, but in general I would say it
    is broken and unusable. Either use BMP, or splash out the money for Coco
    Base from Thought Inc. Currently the only CMP plugin for iPlanet App server,
    other than the reference implementation, that I know of.

  • Entity Bean with Primary Key Class

    Hi
    I am trying to develop an entity bean attached to a key which have a
    composite key using Primary Key Class. When I use the findByPrimaryKey
    method of the bean it throws an exception as follows,
    java.sql.SQLException: Parameter typecheck failed: invalid parameter type:
    ORA-00000: normal, successful completion
    at com.netscape.server.jdbc.PreparedStatement.verifyError(Unknown Source)
    at com.netscape.server.jdbc.PreparedStatement.afterVerify(Unknown Source)
    at com.netscape.server.jdbc.PreparedStatement.executeQuery(Unknown Source)
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown
    Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown Source)
    at
    TestBean2.ejb_home_TestBean2_EntityBean2Bean.findByPrimaryKey(ejb_home_TestB
    ean2_EntityBean2Bean.java:120)
    at
    TestBean2.ejb_kcp_skel_EntityBean2Home.findByPrimaryKey__TestBean2_EntityBea
    n2__TestBean2_TestBKey(ejb_kcp_skel_EntityBean2Home.java:258)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at
    TestBean2.ejb_kcp_stub_EntityBean2Home.findByPrimaryKey(ejb_kcp_stub_EntityB
    ean2Home.java:341)
    at
    TestBean2.ejb_stub_EntityBean2Home.findByPrimaryKey(ejb_stub_EntityBean2Home
    ..java:88)
    at TestBean2.Simple1.defaultAction(Simple1.java:115)
    at TestBean2.Simple1.doGet(Simple1.java:26)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    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)
    javax.ejb.FinderException
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown
    Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown Source)
    at
    TestBean2.ejb_home_TestBean2_EntityBean2Bean.findByPrimaryKey(ejb_home_TestB
    ean2_EntityBean2Bean.java:120)
    at
    TestBean2.ejb_kcp_skel_EntityBean2Home.findByPrimaryKey__TestBean2_EntityBea
    n2__TestBean2_TestBKey(ejb_kcp_skel_EntityBean2Home.java:258)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at
    TestBean2.ejb_kcp_stub_EntityBean2Home.findByPrimaryKey(ejb_kcp_stub_EntityB
    ean2Home.java:341)
    at
    TestBean2.ejb_stub_EntityBean2Home.findByPrimaryKey(ejb_stub_EntityBean2Home
    ..java:88)
    at TestBean2.Simple1.defaultAction(Simple1.java:115)
    at TestBean2.Simple1.doGet(Simple1.java:26)
    [03/Aug/2001 15:26:41:7] error: Exception: SERVLET-execution_failed: Error
    in executing servlet Simat
    javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServletple1: java.lang.ClassCastException:
    com.netscape.server.deployment.EntityBeanDescriptor
    Exception .service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)Stack Trace:
    java.lang.ClassCastException:
    com.netscape.server.deployment.EntityBeanDescriptor
    a
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.ext
    com.netscape.server.servlet.servletrunner.AppInfo.popWebAppDescriptor(Unknow
    n Source)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.seecute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Threadrvlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execu.run(Thread.java:479)
    te(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)
    Any kind of help is appreciated. I am using iPlanet App Builder 6.0 with iAS
    6.0 SP1.
    Thanks
    Bhaskara Murthy
    Eclipse Networks Inc

    "Bhamu" <[email protected]> wrote in message
    news:9keuo4$[email protected]..
    I am trying to develop an entity bean attached to a key which have a
    composite key using Primary Key Class. When I use the findByPrimaryKey
    method of the bean it throws an exception as follows,I notice that you are using the reference CMP plugin.
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)I'm also willing to bet that you may have created your own primary key class
    with a single field, rather than using the fields type as a primitive
    primary key class. If you do this, then SQLPersistenceManager will break.
    It is badly written, and has some stupid assumptions. The one I remember
    the most is that if you only have one primary key field, then
    SQLPersistenceManager assumes you have used a primitive type such as
    java.lang.String or java.lang.Integer, to represent it, rather than creating
    your own <Enity>Pk.java file.
    SQLPersistenceManager works for toy examples, but in general I would say it
    is broken and unusable. Either use BMP, or splash out the money for Coco
    Base from Thought Inc. Currently the only CMP plugin for iPlanet App server,
    other than the reference implementation, that I know of.

  • Accessing Managed Bean Variables in Entity Impl Class

    How can I access managed bean variables in the entity Impl class .
    While inserting a new record in DB , i want to set few entity properties values . The values of those properties are available in the managed bean .
    How can i access those values from Managed Bean and set them the entity Impl class to override the create method.
    Or is there any better recommended approaches ?
    Jdev - 11.1.1.5

    >
    While inserting a new record in DB , i want to set few entity properties values .
    >
    you can user CreateWithparams
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/13-create-with-params-169140.pdf
    http://andrejusb.blogspot.com/2011/02/createwithparams-operation-for-oracle.html

  • Named query in Entity Bean - Problem with embedded class

    Hello Forum,
    I'm trying to set up a named query in my Entity Bean and I'm unable to get
    it up and running for an embedded class object.
    The class hierarchy is as follows:
             @MappedSuperclass
             AbstractSapResultData (contains dayOfAggregation field)
                     ^
                     |
            @MappedSuperclass
            AbstractSapUserData (contains the timeSlice field)
                     ^
                     |
              @Entity
              SapUserDataThe named query is as follows:
    @NamedQuery(name = SapUserDataContext.NAMED_QUERY_NAME_COUNT_QUERY,
                                query = "SELECT COUNT(obj) FROM SapUserData AS obj WHERE "
                                         + "obj.sapCustomerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_CUSTOMER_ID
                                         + " AND "
                                         + "obj.sapSystemId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SYSTEM_ID
                                         + " AND "
                                         + "obj.sapServerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SERVER_ID
                                         + " AND "
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATION
                                         + " AND "
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime")The query deploys and runs except that part:
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONI don't see any difference to the part of the query accessing the timeSlice
    field which is also an embedded class object - I access it in exactly the same way:
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime"The problem is that the complete query runs on JBoss application server
    but on the SAP NetWeaver application server it only rund without the
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONpart - If I enable that part on SAP NetWeaver the server complains:
    [EXCEPTION]
    {0}#1#java.lang.IllegalArgumentException: line 1: Comparison '=' not defined for dependent objects
    SELECT COUNT(obj) FROM SapUserData AS obj WHERE obj.sapCustomerId= :sap_customer_id AND obj.sapSystemId= :sap_system_id AND obj.sapServerId= :sap_server_id AND obj.dayOfAggregation.calendar= :day_of_aggregation AND obj.timeSlice.startTime= :timeSliceStartTime AND obj.timeSlice.endTime= :timeSliceEndTime
                                                                                                                                                                                                 ^I know that this isn't an application server specific forum but the SAP NetWeaver server is the most strict EJB 3.0 and JPA 1.0 implementation I've seen so far so I think I'm doing something wrong there.
    Someone in the SAp forum mentioned:
    The problem here is that you compare an input-parameter with an embeddable field of your entity.
    Regarding to the JPQL-grammer (spec 4.14) you are not allowed to compare
    with the non-terminal embeddable field but with the terminal fields of your
    embeddable. Stating that your embedded class might have the fields
    startTime and endTime your JPQL query might look like this:
    Query q = em.createQuery("SELECT count(obj.databaseId) FROM SapUserData obj WHERE obj.timeSlice.startTime = :startTime AND obj.timeSlice.endTime = :endTime");
    q.setParameter("startTime", foo.getStartTime());
    q.setParameter("endTime", foo.getEndTime());
    q.getResultList();
    This limitation in the JPQL grammar is rather uncomfortable.
    An automatic mapping of the parameter's fields to the terminal fields of your
    embedded field would be more convenient. The same can be said for lists
    as parameter-values which is possible in HQL, too. I think we have to wait
    patiently for JPA 2.0 and hope for improvements there. :-)
    With that help I was able to get it up and running for the timeSlice field but
    I don't see the difference to the dayOfAggregation field which is also just
    another embedded class using an object of a class annotated with
    @Embeddable.
    The get method of the dayOfAggregation field is as follows:
         * Get method for the member "<code>dayOfAggregation</code>".
         * @return Returns the dayOfAggregation.
        @Embedded
        @AttributeOverrides({@AttributeOverride(name = "calendar", /* Not possible to use interface constant here - field name must be used for reference */
                                                column = @Column(name = DayContext.COLUMN_NAME_DAY_OF_AGGREGATION,
                                                                 nullable = false)),
                             @AttributeOverride(name = "weekday",
                                                column = @Column(name = DayContext.COLUMN_NAME_WEEKDAY,
                                                                 nullable = false)),
        public Day getDayOfAggregation() {
            return this.dayOfAggregation;
        }The link to my question in the SAP forum for reference:
    https://www.sdn.sap.com/irj/sdn/thread?messageID=3651350
    Any help or ideas would be greatly appreciated.
    Thanks in advance.
    Henning Malzahn

    Hello Forum,
    got a response in the SAP forum - Issue is a bug in the SAP NetWeaver
    app. server.
    Henning Malzahn

  • Unable to use Class Designer when deriving Entity Bean from another class

    I have several Entity Beans that have common fields. In order to maximise reusability, I have defined a base class which contains these common fields and corresponding get/set methods on these fields.
    In the next step, I build an Entity Bean using JDeveloper. I then go to Source Editor and in the Bean class, modify the Java code to inherit from this base class that I have defined. I then try to go to Class Designer expecting to see the inherited fields as well.
    However, this is the error I get :
    "Error while trying to parse source file...."
    Any pointers on resolving this would be a great help ! Thanks !!!
    -Andre
    null

    If you're running >Java 1.4, you'll need to put your classes into a package since Tomcat can no longer import the class 'BeanProdess' which is in an unnamed namespace.
    Your JSP is compiled into a class (in the package org.apache.jsp) that doesn't recognize anything in the default package.
    Here's a reference if you want to read about this.
    http://java.sun.com/j2se/1.4/compatibility.html#incompatibilities1.4

  • Do I need to Create Primary Key Class for Entity beans with Local interface

    Do I need to Create Primary Key Class for Entity beans with Local interface?
    I have created my entity bean with the wizard in Sun One Studio and it does not create a primary key class for you.
    I thought that the primary key class was required. My key is made up of only one field.
    Anyone know the answer.
    Jim

    u dont need to create a primary key class for a entity bean.if ur table's primary key feild(int ,float) is a built in or primitive data type,then u dont need one.But if ur table has a primary key field which is non primitive (for example StudentID,ItemID etc)then u have to create a primary key class.
    hope this helps :-)

Maybe you are looking for

  • Unable to open any .IFDs in Designer 7.0 or 7.1

    I am trying to convert some ifd files to pdf. I've tried both Designer 7.0 and 7.1 and the ifds are being saved with Output Designer 5.6. I know when I originally tried to open an IFD in 7.0, before I had OD5.6 installed, it would ask for OD 5.5. I a

  • Testing fire wire port

    I have tried several times to test my fire wire port on this mac mini. I tnever does anything differently than boot up. I am hooking up an audio interface and cant seem to get it to recognize the unit. I have tried testing the port, different cables

  • Nokia PC Suite and Outlook sync - field

    Hello, why does Nokia PC Suite put default contact number into "Other Phone" field in outlook? This field isn't shown anywhere, and it gives troubles when trying to sync outlook with other applications. How can I change where number is saved in outlo

  • Validity period for services in ITS

    We are on Extended classic scenario with EBO 4.0 and wanted to have service order created. When I log into ITS server Shop -> Describe Requirement -> I have Description, Internal Note, Quantity, Price, Category and Required on. However I want "From d

  • Checking for errors before saving in CRMD_ORDER

    Hi, I have a requirement where I need to check if any errors exist before being able to save a document in t-code CRMD_ORDER. If any error exists, then user should not be able to save the document. Currently, if even if errors exist, the user is able