EjbHomeRemove vs ejbRemove

I need to delete a record from the database using BMP. Would I put the call to the database in the ejbHomeRemove or ejbRemove?
If I do not place the logic in the ejbHomeRemove, how would I invoke the ejbRemove. I read a document from the tutorials that indicates the ejbRemove could be invoked by client. But I thought that the client could not call ejbRemove on the entity bean itself, but would need to do so possibly off the home object. But when I add "public void remove()" to the home, I get a compilation error indicating that since I am using local interfaces, that I must declare "ejbHomeRemove" on the entity bean. But at the same time I get a compilation error requiring "ejbRemove" be on the entity bean. So my entity bean has both ejbHomeRemove and ejbRemove.
Thanks

The EJBHome object already has a remove method defined. Actually, it has two remove methods:
void remove(Handle handle)
void remove(Object primaryKey)You don't need to add a remove() to the home in order to use these methods. The EJBObject also has a remove method already defined:
void remove() When any of these remove methods are invoked, the ejbRemove() method in the bean will be invoked. The client can invoke the remove method on the EJBObject in which case that entity bean will be removed. If the client invokes a remove method on the Home, he must specify a handle or primary key to determine which entity bean to remove.
The reason you got a compiler error telling you that you need a ejbHomeRemove in the bean when you tried to add a remove method to the Home is because it thought your remove method was some sort of business method. All methods in the Home except create and finder methods require corresponding ejbHome... methods in the bean. These business methods are not specific to a particular entity bean; they normally handle aggregate functions. This definitely isn't what you had in mind.
All you need to do is put your database calls in ejbRemove and don't put any remove() methods in your Home and Remote/Local interfaces.

Similar Messages

  • Question about ejbRemove and bmp

    hi,
    do I need to implement all of the ejbXxx methods in a bmp, what I see is that I call findByPrimaryKey on a bmp and then remove() but if then I try to access it again it's still there. My ejbRemove is empty at the moment, but I thought that the container would anyway remove the instance of the bean it had loaded so I am a bit confused. Do I HAVE to check in the db if the row is still there and in case throw ObjectNotFoundException in my ejbFindByPrimaryKey? Is this the only way to know the bean has been removed? Doesn't the container do anything with the bean when I call remove() (either on the local or home interface)
    thanks,
    A.

    didn't see there already was a reply
    http://forum.java.sun.com/thread.jsp?forum=13&thread=447215&tstart=0&trange=15

  • Why doesn't timeout call ejbRemove in 1.1

    I just read that in EJB 1.0 if the container decides to remove a stateful session bean it will call the ejbRemove() function on that session bean. In 1.1 however the container can remove the entity bean at will and will not call the ejbRemove() function giving the bean no oppurtunity to clean up after itself.
    How can the 1.1 way be preferable? It seems to me that is just going to cause problems. This is especially aggravating since the EJB server we use doesn't seem to have any way to modify the timeout. I don't even know if it has one.

    The reason this is giving me trouble is that I have an entity bean that should only exist if there are session beans referencing it. I want the entity bean to be removed when the last session with a reference to it is removed. If the client app closes without calling remove on the session bean's remote interface, the ejbRemove method in the Session Bean is not called but Session Bean is removed. Is there any way around this. I need to know if the Session Bean is removed.

  • TimerService in EJB. Cannot get initialized timers in ejbRemove() method

    I try to cancel all timers from the ejbRemove() method of stateless session bean. Timers are initialized in the bean.
    The call timerService.getTimers() throws an exception:
    "StatelessBean: Timer Service methods not allowed from state = POOLED "
    How could I solve this problem? I just want to remove initialized timers when the server stops (ejbRemove())

    TimerService methods are not permitted to be invoked from the PreDestroy(previously known as
    ejbRemove) callback. EJB does not define any server shutdown-specific lifecycle events.
    --ken                                                                                                                                                                                                                                                                                                                                                                                           

  • EjbRemove, remove(), bean logic, database row logic

    In some Sun examples the remove() method is not exposed trhu the home interface, but anyway it is called from the client thru the home interface, I would like to know the reason; another question is the logic after the remove() method exposed thru the remote interface versus the ejbRemove() method exposed (?) thru the home interface, so the question is:
    - there is a logic directed to the bean (to delete de entity bean) and another logic directed to the persistent row represented by the bean?.
    If I delete a row it is obvious the entity bean representing it should be deleted, but what happens if the client (or the container) invokes ejbRemove() either directly (the container) or trhu the home interface (the client) and I only want to delete the bean, but not the persistent row? Iin fact, the container could call ejbRemove as part of the bean lifecycle, and this should not imply the persistent database row delete, so it appears that the row delete code should not be in the ejbRemove() ?!
    thanks.

    I think that that the removing of an entity ejb should not imply the removing of the database row, thought the remove of the database row really implies the removing of the entity ejb representation. So, if you code an sql delete statement in the ejbRemove method, it implies that as consequences of the lifecycle of ten entity bean the row could be removed, and I think it is not allway rihgt, for if you want to remove the ejb representing your account (for example), to free server memory, it should not imply that yout account database row should be removed too, unless the ejbRemove method woulnd't be never called by the container, so, to cut it short: what happens if the container, as a consequence of the lifecycle of the bean, call ejbRemove and you coded in this method a sql delete, your account (for example) in your bank would dissapppear!, and you only wanted to free the memory associated to the entity ejb.
    I think the remove() and ejbRemove() are tricky!
    Maybe I don't understand well the basics of ejb, but I really thought a lot about this question.
    thanks!

  • EJB's ejbRemove function

    hello:
    I have a question.How to make the Weblogic6.X server
    call my stateful session bean's ejbRemove function immediately after my client side application is abnormally terminated.It is very important to me. Thanks in advance.
    shao-chi liu

    With weblogic 6.1, it is possible to have control of when a statefull session bean is removed from the app server.
    To do this you have to use max-beans-in-cache and idle-timeout-seconds deployment elements.
    The following links will be helpful to you
    http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1031433
    http://e-docs.bea.com/wls/docs61/ejb/reference.html#1195912
    regards,
    Abhishek.

  • NoSuchObjectLocalException for current object in ejbRemove

    Hi!
    In our system we currently have trouble removing some objects due to NoSuchObjectLocalExceptions. The method goes like this:
    /*1*/ public void ejbRemove () throws RemoveException {
    /*2*/ String type = getType ();
    /*3*/ callSomeSessionEJBs();
    /*4*/ type = getType (); // just a test which should work.
    /*5*/ super.ejbRemove ();
    /*6*/}
    Here we get an NoSuchObjectLocalException about the entity itself, which is being removed, in line 4. If I remove the callSomeSessionEJBs call, this does not happen and the entity is removed successfully. (I inserted line 4 as a test - if it is not present, the NoSuchObjectLocalException is just thrown just a little later, after the ejbRemove is concluded.) The callSomeSessionEJBs call does not try to access the current entity. What can I do about that?
    We are using Bea 8.1SP4 Portal. Strangely, this worked up to a few months ago, and still does work on elder versions of the application with the same code at ReferenceBean and almost the same code in callSomeSessionEJBs. The actual exception message follows. ReferenceBean is the EJB being removed.
         javax.ejb.NoSuchObjectLocalException: [EJB:010140]Bean with primary key: 'cd4cede1-01de-11db-b224-1bd9a414a8b1' not found.: javax.ejb.NoSuchEntityException: [EJB:010140]Bean with primary key: 'cd4cede1-01de-11db-b224-1bd9a414a8b1' not found.
         at de.mms_dresden.gpp.server.core.entity.Reference_dujp68__WebLogic_CMP_RDBMS.__WL_loadGroup0(Reference_dujp68__WebLogic_CMP_RDBMS.java:2415)
         at de.mms_dresden.gpp.server.core.entity.Reference_dujp68__WebLogic_CMP_RDBMS.getType(Reference_dujp68__WebLogic_CMP_RDBMS.java:429)
         at de.mms_dresden.gpp.server.core.entity.ReferenceBean.ejbRemove(ReferenceBean.java:152)
         at de.mms_dresden.gpp.server.core.entity.Reference_dujp68__WebLogic_CMP_RDBMS.__WL_superEjbRemove(Reference_dujp68__WebLogic_CMP_RDBMS.java:2805)
         at weblogic.ejb20.manager.DBManager.remove(DBManager.java:1388)
         at weblogic.ejb20.internal.EntityEJBLocalObject.remove(EntityEJBLocalObject.java:128)
         at de.mms_dresden.gpp.server.core.entity.Reference_dujp68_ELOImpl.remove(Reference_dujp68_ELOImpl.java:835)
         at de.mms_dresden.gpp.server.core.session.CoreFactoryBean.removeReference(CoreFactoryBean.java:286)
    Judging after the contents of Reference_dujp68_ELOImpl.java, it seems the application server has forgotten the value it loaded in line 2 and tries to load the current bean again in line 4 and cannot not find it anymore.
    Any help is greatly appreciated! I've already spent days on the problem. 8-{
    Hans-Peter Stoerr

    Hi
    Try searching for the auth object in either SU24 or try adding the authorization in pfcg with manual selection.

  • EjbRemove fails with deferred constraints in 8.1.6

    I get a constraint violation under certain conditions from Oracle.
    IBM ejb container hides the exception, and raises a CSI_ROLLBACK exception. The only workaround I can think of, is disabling all constraints in Oracle, and trusting IBMs Application server to guarantee the
    referential integrity of the database.
    Does anyone else notice these problems and found a resolution?
    Oracle introduced deferred constraints to allow the constraint violation checking at the end of an transaction.
    For the IBM implementation of entity EJBs this is essential,
    because any the "DELETE FROM WHERE id=" which result from an ejbRemove() happens >>>before<<< an ejbStore() which results in "UPDATE SET foreignkey = NULL ".
    I am using the jdbc driver from classes12.zip, and noticed that
    you get an constraint violation on a commit, when the record has been created in a transaction, is updated in a transaction, and then is deleted in a transaction. The transactions are isolated.
    A rollback, and deleting again resolves the problem.
    But the problem is that an Websphere Application server is in between the
    delete from a user, and the jdbc driver accessed through a datasource.
    null

    Does anyone know where to configure and find required settings (e.g. the number of open_cursors) for Oracle 8.1.6 server when using the jdbc thin driver ?
    null

  • When ejbRemove() is called?

    Guys,
    I have a simple EJB bean class.
    import javax.ejb.*;
    public class HelloBean implements javax.ejb.SessionBean
    private SessionContext ctx;
    public void ejbCreate()
    System.out.println("ejbCreate()");
    public void ejbRemove()
    System.out.println("ejbRemove()");
    public void ejbActivate()
    System.out.println("ejbACtivate()");
    public void ejbPassivate()
    System.out.println("ejbPassivate()");
    public void setSessionContext(javax.ejb.SessionContext ctx)
    this.ctx=ctx;
    public String hello()
    System.out.println("Hello World EJB");
    return "Hello World EJB return this time with SUNIL";
    When I invoke my client, it displays the string from ejbCreate() but the string inside the ejbRemove() method is not at all called. WHY?
    Thanks,
    Guru

    ejbRemove() is called by the EJB Container after the client invokes remove method and makes the instance eligible for GC.
    So the SOP would be displayed after GC :)

  • Force container to call ejbRemove from the bean

    Hi,
    I have a stateful bean with few business methods. This bean is invoked by a MDB.
    The ejbRemove() method cannot be called by the caller.
    The only component to know when the bean can be removed itself is that bean's particular business method.
    Is it possible for the bean itself intimate the container that the bean can be removed.
    What happens currently is that bean gets passivated and moves to 'does not exist' state. And it happens after a 10 minutes. I'd wish to be removed immediately after its service.
    Regards,
    Raj

    >
    >
    Is it possible for the bean itself intimate the container that the bean can be removed.Yes, this capability was added in EJB 3.0. Just mark the business method implementation with
    @Remove. In that case, the container will remove the bean after the business method executes.
    This will follow the normal removal process, which means that if the bean defines a @PreDestroy
    method that will be called as well.
    Also, the bean can define any number of @Remove business methods.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ClassNotFound on ejbRemove

    We encounter a ClassNotFound problem at ejbRemove of one of our SessionBeans. The class is loaded on ejbCreate without problems. For example on redeployment the server throws a ClassNotFoundException while executing ejbRemove for the class which has been found successfully on ejbCreate. Does anyone know something about special classloading conditions while shuting down an application in wl ?

    Did you read this part there:
    There is a second possible issue that is specific to the commons-logging and related libraries when used with Integrated WLS and the configuration (which includes ADF) out-of-the-box. Because the commons-logging.jar is apparently in the system classpath, due to the way Java classloader delegation works, any log4j classes at the web application level are not visible to the logger factory by default. As long as this is the case, you may need to add the following to your web-application's WEB-INF/weblogic.xml:
    <container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>
    What this does is tell the WLS JSP servlet to let web application classes override classes found in the system classloader. Standard Java classloader delegation gives the highest priority to the system classes.

  • Y can;t we call ejbRemove() to diretly delete a record

    Hi,
    Can any1 of u explain to me why can;t we call ejbRemove() to directly delete a record from a database? Is there any reason y can;t we do that?
    Thanks in advance.

    Hi,
    Actually your post does not mention what you want.
    Hi,
    Can any1 of u explain to me why can;t we call
    ejbRemove() to directly delete a record from a
    database? Is there any reason y can;t we do that?
    Thanks in advance.Then the answer to this is yes you can do this as already explained.I was wondering what you were asking for.
    It totally depends on you what way to continue.Also you should use to CMP rathar that BMP as you get the Database independenency.Let the Container provider concentrate on this and you put more efforts on applicaiton development,that is the reason why there are different Roles in the EJB areana,It is for Divide and Conquer as expalined by AdRoman.
    Regards
    Vicky

  • Trouble in   ejbRemove()

    some piece of code
    ===================
    public class ProductBean implements EntityBean {
    EntityContext context;
    int productId;
    String productName;
    String description;
    double price;
    // blah
    //blah
    public void ejbRemove() throws RemoteException {
    System.out.println("ejbRemove");
    Connection con = null;
    PreparedStatement ps = null;
    try {
    String sql = "DELETE FROM Products" +
    " WHERE ProductId=?";
    ProductPK key = (ProductPK) context.getPrimaryKey(); // note it
    int productId = Integer.parseInt(key.productId);     // note it
    con = getConnection();
    ps = con.prepareStatement(sql);
    ps.setInt(1, productId);
    ps.executeUpdate();
    catch (SQLException e) {
    System.out.println(e.toString());
    finally {
    try {
    if (ps != null)
    ps.close();
    if (con != null)
    con.close();
    catch (SQLException e) {
    }// blah
    // blah
    public void setEntityContext(EntityContext context) {
    System.out.println("setEntityContext");
    this.context = context;
    }// blah
    //blah
    Question: but which row ( Enity bean ) will be removed ? last row or the last entity bean bean would be removed by this code. am i right ? because API says,
    API:
    ====
    getPrimaryKey()
    Obtain the primary key of the EJB object that is currently associated with this instance.
    So, the last row that is the last created entity bean would be removed . but if an user want to delete some particular product whose product id is known to him. How can he delete that particular row ?

    There is one instance for each row. So you have to
    call remove on the instance which represents the row
    which you want to delete.
    /Kajthank you man...it was a huge help. i found a code after some pages in the client code......
    // Create an Interest object from the Home interface
    home.create(11, "Franklin Spring Water", "400ml", 2.25);
    home.create(12, "Franklin Spring Water", "600ml", 3.25);
    home.create(13, "Choco Bar", "Chocolate Bar 200g", 2.95);
    home.create(14, "Timtim Biscuit", "Biscuit w. mint flavor,
    300g", 9.25);
    Product product = home.create(15, "Supermie", "Instant Noodle",
    1.05);
    product.remove();and also......
    void ejbRemove()
       // A container invokes this method before it removes the EJB object
       // that is currently associated with the instance. thank you very much....peace..ahh nice thing.

  • NullPointerException while doing ejbremove

    I have deployed my application on Oracle9iAS (9.0.2) and am getting the following error while doing ejb remove of any Bean (My application has only stateless session beans)
    java.lang.NullPointerException
    at AssetMgmt.AssetMgmtBEAN.ejbRemove(AssetMgmtBEAN.java:82)
    at
    com.evermind.server.ejb.StatelessSessionEJBHome.removeUnusedCache(StatelessSessionEJBHome.java:60) at com.evermind.server.ejb.EJBTask.run(EJBTask.java:69)
    at com.evermind.util.TaskManager.run(TaskManager.java:133)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:66)
    the same application works without any error with Oracle9iAS (9.0.1).
    Please let me know what might be the cause of this error.

    Please repost your message on the OC4J forum. This is a Web Cache forum. Thank you.

  • Error calling ejbRemove()

    Hi there,
    I always get following error while trying to delete a row from the datasource.
    Thrown error:
    [code]com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception in method removeStatus.
         at com.dcx.mcg.itp.aa.projects.eeim.beans.DataObjectImpl0.removeStatus(DataObjectImpl0.java:2889)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.Data_Stub.removeStatus(Data_Stub.java:2207)
         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:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy441.removeStatus(Unknown Source)
         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:324)
         at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:146)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:68)
         at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
         at SoapServlet.doPost(SoapServlet.java:51)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: javax.ejb.EJBException: Exception in method com.dcx.mcg.itp.aa.projects.eeim.beans.StatusLocalHomeImpl0.remove(java.lang.Object).; nested exception is: com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in method com.dcx.mcg.itp.aa.projects.eeim.beans.StatusLocalHomeImpl0.remove(java.lang.Object).
         at com.dcx.mcg.itp.aa.projects.eeim.beans.DataBean.removeStatus(DataBean.java:813)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.DataObjectImpl0.removeStatus(DataObjectImpl0.java:2861)
         ... 32 more
    ; nested exception is:
         javax.ejb.EJBException: Exception in method com.dcx.mcg.itp.aa.projects.eeim.beans.StatusLocalHomeImpl0.remove(java.lang.Object).; nested exception is: javax.ejb.EJBException: com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in method com.dcx.mcg.itp.aa.projects.eeim.beans.StatusLocalHomeImpl0.remove(java.lang.Object).
         at com.dcx.mcg.itp.aa.projects.eeim.beans.StatusLocalHomeImpl0.remove(StatusLocalHomeImpl0.java:197)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.DataBean.removeStatus(DataBean.java:807)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.DataObjectImpl0.removeStatus(DataObjectImpl0.java:2861)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.Data_Stub.removeStatus(Data_Stub.java:2207)
         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:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy441.removeStatus(Unknown Source)
         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:324)
         at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:146)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:68)
         at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
         at SoapServlet.doPost(SoapServlet.java:51)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.engine.services.ejb.entity.ContainerException: Exception in method ejbLoad().
         at com.sap.engine.services.ejb.entity.ContextFP.activate(ContextFP.java:196)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.StatusLocalHomeImpl0.remove(StatusLocalHomeImpl0.java:125)
         ... 34 more
    Caused by: java.lang.ClassCastException
         at com.dcx.mcg.itp.aa.projects.eeim.beans.StatusBean0Persistent.init(StatusBean0Persistent.java:102)
         at com.sap.engine.services.ejb.entity.pm.PersistentCache.supply(PersistentCache.java:85)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.StatusBean0PM.ejbLoad(StatusBean0PM.java:237)
         at com.sap.engine.services.ejb.entity.ContextFP.activate(ContextFP.java:187)
         ... 35 more
    com.sap.engine.services.ejb.entity.ContainerException: Exception in method ejbLoad().
         at com.sap.engine.services.ejb.entity.ContextFP.activate(ContextFP.java:196)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.StatusLocalHomeImpl0.remove(StatusLocalHomeImpl0.java:125)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.DataBean.removeStatus(DataBean.java:807)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.DataObjectImpl0.removeStatus(DataObjectImpl0.java:2861)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.Data_Stub.removeStatus(Data_Stub.java:2207)
         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:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy441.removeStatus(Unknown Source)
         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:324)
         at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:146)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:68)
         at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
         at SoapServlet.doPost(SoapServlet.java:51)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: java.lang.ClassCastException
         at com.dcx.mcg.itp.aa.projects.eeim.beans.StatusBean0Persistent.init(StatusBean0Persistent.java:102)
         at com.sap.engine.services.ejb.entity.pm.PersistentCache.supply(PersistentCache.java:85)
         at com.dcx.mcg.itp.aa.projects.eeim.beans.StatusBean0PM.ejbLoad(StatusBean0PM.java:237)
         at com.sap.engine.services.ejb.entity.ContextFP.activate(ContextFP.java:187)
         ... 35 more[/code]
    My code:
    [code]
    private StatusLocalHome statusHome = null;
    public void setSessionContext(SessionContext context)
    Status obj = jndiContext.lookup("java:comp/env/ejb/EEIMStatus");
                   statusHome =
                        (StatusLocalHome) PortableRemoteObject.narrow(
                             obj,
                             StatusLocalHome.class);     
    public int removeStatus(long id)
              try
                   StatusLocal statusLocal =
                        statusHome.findByPrimaryKey(new Long(id));
                   statusHome.remove(statusLocal);
                   return 1;
              catch (EJBException ex)
                   throw new EJBException(ex.getMessage(), ex);
              catch (FinderException ex)
                   throw new EJBException(ex.getMessage(), ex);
              catch (RemoveException ex)
                   throw new EJBException(ex.getMessage(), ex);
         }[/code]
    Does somebody recoginzes what I've done wrong?
    Thanks for all replies
    Regard
    Daniel

    Hello Daniel,
    The first problem that I see is the usage of PortableRemoteObject.narrow method - it must be used only in the case when remote EJB reference is obtained. I assume in your case the EJB reference is local.
    The real problem, however, is the wrong parameter in the remove() method. I suppose it causes the ClassCastException. The parameter must be the primary key, not the EJBObject reference. The code should be:
    statusHome.remove(new Long(id));
    instead of
    StatusLocal statusLocal =
    statusHome.findByPrimaryKey(new Long(id));
    statusHome.remove(statusLocal);
    I hope this helps.
    Regards,
    Svetoslav

Maybe you are looking for

  • Can't delete game

    Hi, I'm using parallels desktop to run windows xp. I installed a game some time ago and had problems so decided to uninstall it. The problem is that although the game was removed using the Add/Remove software program the game files, although not visi

  • SmartView Retrieval error

    Hi Folks, Excel and Smart view being used is Excel 2010 and 11.1.2.5 We are trying to 'Refresh All sheets' in a workbook which has ~ 130 tabs. Everything was working till couple of weeks back. We needed to add one more tab with just one change in the

  • CASE/DECODE in WHERE caluse

    Hi friends, Let's consider an EMP table has the following structure and data: create table EMP EMPNO NUMBER(4) not null, ENAME VARCHAR2(10), JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE, SAL NUMBER(7,2), COMM NUMBER(7,2), DEPTNO NUMBER(2), CONFDATE

  • How to restrict user from deleting record

    Dear All, Kindly share your experience... Situation: My client have one SOB, used by several branches. Each branch has its own branch code in Chart of Account (accounting flexfield). Currently, to prevent branch accessing other branch's journal in Ge

  • Possible Solution: Rentals Freeze

    First, I have a Powerbook G4. Last week I rented a movie through Itunes. I noticed, as many others have, that rentals seem to freeze quite frequently. In fact, mine was freezing about every 2 minutes. Once I plugged my laptop in, because it was dying