Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

Ravi Singh

Ranch Hand
+ Follow
since Aug 02, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ravi Singh


Can anyone tell me/show me how to send an attachment that is uploaded from the client?

Thank you.
Does anyone know of any websites which explain the way bean instances (entity, session, message) and instance pooling works, including the way the container handles method invocation on the different interface types (home, remote etc)?

I thought invoking the create() method for a stateless session bean created an ejbObject for the client on the server, and then when the client invoked a method a bean from the instance pool was 'swapped' into the ejbObject of the client and serviced the request before being placed back into the instance pool?

Then when you invoke remove(), it is the 'ejbObject' which is removed.

Or is this just a conceptual view of things?
I executed the following code as a stateless session bean test:

InitialContext ctx = new InitialContext(); // Get initial context
CaseEJBHome home = (CaseEJBHome)ctx.lookup("CaseEJB"); // Lookup home
caseEJB = home.create(); // Create stateless session bean

caseEJB.remove() // Remove newly created stateless session bean
caseEJB.remove() // Remove again, the newly created bean

I was expecting the second remove statement to throw an exception as the session bean has previously bean removed but it doesn't.

Is there any reason why no exception is thrown?
If you overide both the init() and init(ServletConfig sf) methods, which one is called when the serlvet is instantiated?
17 years ago
If you construct an Initial Context using the no argument InitialContext() constructer, how does the initial context 'know' which naming service to connect to?

Does it connect to the localhost?
What does the narrow() method actually do to the remote stub originally returned?
17 years ago
When obtaining a remote stub for a session/entity bean why must you use the PortableRemoteObject.narrow() method before the remote stub can be cast?
17 years ago
What happens if a method is invoked on a stateless/stateful session bean or entity bean which has previously been removed by some other client invoking the remove( ) method?

Is an exception thrown? If so, which one?
But what happens to the ejbObject on the server if you don't invoke remove().
The reason I'm asking is because I'm trying to get a better understanding of the way a container manages transactions.

If the con.commit() doesn't throw an exception, is the statement simply ignored?
If you invoke commit e.g. con.commit(), from a bean which has its transactions managed by the container what happens?

Is the commit action performed or is the commit action ignored?
In the case of stateless session beans, I'm under the impression that when you invoke create(), an ejbObject is created on the server and a remote reference returned.

Then when you invoke remove(), the ejbObject is invalidated.

What would happen to the ejbObject if you didn't invoke remove(). Would it continue to persist or would it be automatically invalidated after some period of time?
When using the result set methods getInt(), getString() etc to get the values returned from the database do the database column types have to be of type number or varchar2 respectively?

Or, do the methods attempt to parse the value of the database column as a string (for the getString() method) or as a int (for the getInt() method)?

I understand the concept of BM and CM transactions but does anyone know what would happen if you placed a commit() statement in a bean which had its transactions managed by the container?

Would an exception be thrown or would the commit simply be ignored?