Bugs item #463590, was opened at 2001-09-21 08:50
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=463590&group_id=22866

Category: None
Group: v2.4 (stable)
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Andreas Schaefer (schaefera)
Summary: Entity bean reference is lost

Initial Comment:
I'm using a stateful session bean to lookup home interfaces for different entity 
beans, instantiate 
them and return the remote references to the client. This code worked properly with 
JBoss 2.2X 
but fails with 2.4.1.

Excerpt from sample session bean code:
public CustomerRemote getCustomer( Integer customerPK ) throws RemoteException {
    try {
        CustomerHome home = (CustomerHome) jndi.lookup( "java:comp/env/ejb/Customer" );

        return clHome.create( customerPK );
    }
    catch(Exception e) {
        e.printStackTrace();
        throw new RemoteException(e.getMessage());
    }
}

When client calls getCustomer() on the stateful session bean, a new Customer i created 
and the 
remote customer is returned. Now, when the client makes a call to this newly created 
Customer 
bean (entity), yet another instance is created, without all the inital data such as 
the primary key.
No exceptions thrown, but contents of Customer is of course invalid.

This is part of my ejb-jar.xml:
    <session>
        <ejb-name>Session</ejb-name>
            <home>com.posten.ejb.SessionHome</home>
            <remote>com.posten.ejb.SessionRemote</remote>
            <ejb-class>com.posten.ejb.Session</ejb-class>
            <session-type>Stateful</session-type>
            <transaction-type>Bean</transaction-type>
            <ejb-ref>
                <ejb-ref-name>ejb/Customer</ejb-ref-name>
                <ejb-ref-type>Entity</ejb-ref-type>
                <home>com.posten.ejb.CustomerHome</home>
                <remote>com.posten.ejb.CustomerRemote</remote>
                <ejb-link>Customer</ejb-link>
            </ejb-ref>
    </session>

I'm using Sun JDK 1.3 on a Win NT 4.0 workstation with Oracle Thin Driver 8.1.6.

----------------------------------------------------------------------

Comment By: Bo Carlsson (boca007)
Date: 2001-10-04 07:41

Message:
Logged In: YES 
user_id=167925

Actually, I was able so solve this problem after reading 
the J2EE Developer's Guide carefully. As you suspect you 
are not guaranteed to get the same bean instance in 
successive calls. If the container wishes it creates a new 
instance and calls ejbActivate() where the primary from 
EntityContext is valid. If needed ejbLoad() is called and 
this primary key should be used to refresh data.

Thus, the calls made are:
setEntityContext() Get the context
ejbActivate() Get the primary key from context
ejbLoad() Synchronize data using the primary key

In ver 2.2.2 it seems that the container always kept the 
instance where ejbCreate and ejbFindBy* was first invoked.

I recommend you read The Life Cycle of an Entity Bean in 
section 4 of J2EE DevGuide.


----------------------------------------------------------------------

Comment By: Charlie Dobbie (cfmdobbie)
Date: 2001-10-04 06:07

Message:
Logged In: YES 
user_id=34788

I seem to be having a similar problem.  I have an EJB that 
was working correctly under 2.2.2, but now fails on 2.4.1.

I call an ejbFindByX method on the Home interface of my BMP 
EJB.  My SELECT in the EJB runs correctly and populates a 
primary key with the correct data (verified), and returns 
it.  The client then invokes a method on the Remote 
interface which calls a method on the EJB class that calls 
EntityContext.getPrimaryKey()... which returns null.

For some reason either the EJB I'm accessing isn't the one 
I searched for, or the primary key is being nulled either 
before returning the Remote reference, or on any subsequent 
access of the EJB.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=463590&group_id=22866

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to