Tyronne Fernando

Ranch Hand
+ Follow
since May 11, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tyronne Fernando

Hi,

Is it important to read the JSR 109 and JSR 921 documents for the SCDJWS 5 exam? I don't see any reference to these documents in the exam objectives. Do you think it will have any benefit for the exam?

Thanks.

Cheers,
Tyronne
Thanks everyone for all the best wishes.

Devaka, you are correct. I am Sri Lankan.

Gargi, it took me about 3-4 months and I spent 2-3 hours 4-5 times a week. All the other information is in my first post. All the best with the preparation and good luck.
8 years ago
I recently passed SCBCD with 98%. I thought I will share my experience with you.

To start with I didn't have much experience in EJBs. I read the "EJB 3 In Action" book once. At the same time I created my own notes. Later on I went through my own notes few times before the exam.

I also did the tutorials from JBoss (http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html_single/index.html). I only did specific once after reading each chapter from "EJB 3 In Action".

I also read the Mikalai Zaikin's study notes. Thanks for sharing those notes with us Mikalai.

The most helpful source was the Enthuware exam simulator. It heped me to build my confidence and point out my weak areas. The explanations are excellent and helped me to understand the concepts. So, a big thank to Enthuware When I did the mock exams for the first time i got some where around 55% - 65%. But, after working on my weak areas and doing the exams again after a couple of weeks time, I got around 80% - 90%. Also the exam questions had the same kind of format and difficulty as the real exam.

I also read the simplified EJB 3 specification (ejb-3_0-fr-spec-simplified.pdf).

I thought the Sun online exam was pretty tough (http://au.sun.com/training/certification/assessment/). I did that twice and didn't do that well in both occasions

Last not least, thanks for all of you guys in Java ranch for answering my questions. You have been very helpful as always.

I guess if you understand the concepts the exam should be pretty straight forward. At the start I was not really good with Transactions, Exceptions and Roles. I spent more time on those areas to understand the concepts.

All the best for everyone preparing for this exam.

Cheers,
Tyronne
8 years ago
Thanks for the quick reply Lee.
Thanks for the quick reply Lee.
Hi,

Please let me know whether the Message is sent in the following scenario:

"A session bean sends a message to a MDB within a transaction. After sending the message the transaction is marked for rollback."

Is the message will be sent to the MDB?

Thanks in advance.

Cheers,
Tyronne
Hi,

Let's say Bean A invokes a method in Bean B. Bean B throws a System Exception. Does the container discard both Bean A and Bean B? Or it just discard the bean that gets a System Exception (Bean A) not the System Exception originator (Bean B)?

Does the above outcomes change depending on the bean type (session or message driven)?

Please let me know. Thanks in advance.

Cheers,
Tyronne
The following code is from EJB 3 In Action page 212.

public class SecurityInterceptor {
@AroundInvoke
public Object checkUserRole(InvocationContext context)
throws Exception {
if (!context.getEJBContext().isCallerInRole("CSR")) {
throw new SecurityException(
"No permissions to cancel bid");
}
return context.proceed();
}
}

@Stateless
public class BidManagerBean implements BidManager {
@Interceptors(actionbazaar.security.SecurityInterceptor.class)
public void cancelBid(Bid bid, Item item) { ... }
.......

Does anyone can tell me where is the getEJBContext() method is coming from? That method is not specified for InvocationContext (http://java.sun.com/javaee/5/docs/api/javax/interceptor/InvocationContext.html). Also I can't find any correction in the errata (http://www.manning.com/panda/excerpt_errata.html).

Thanks in advance.

Cheers,
Tyronne
The following code and text is from page 332 of EJB 3 In Action:

public Item undoItemChanges(Item item) {
entityManager.refresh(entityManager.merge(item));
return item;
}

"The merge operation is performed first in the undoItemChanges method because the refresh method only works on managed entities."

Because of this, I get the impression that the refresh() method does not attach the entity to the persistence context.

.... and Tyronne Fernando is my real name
@Stateless
public class ItemManagerBean implements ItemManager {
@PersistenceUnit private EntityManagerFactory entityManagerFactory;
private EntityManager entityManager;
public ItemManagerBean() {}

@PostConstruct public void initialize() {
entityManager = entityManagerFactory.createEntityManager();
}
...
public Item updateItem(Item item) {
entityManager.joinTransaction();
entityManager.merge(item);
return item;
}
...
@PreDestroy
public void cleanup() {
if (entityManager.isOpen()) {
entityManager.close();
}
}
...
}


The above code is from pages 308 and 309 of "EJB 3 in Action" book. This bean is using an application-managed EntityManager within a container. In the updateItem() method where does the JTA transaction comes from when we call entityManager.joinTransaction()? Is it created by the container?

Thanks in advance.
The following is from the "EJB 3 in Action" page 320.

"Note that if an entity instance matching the specified key does not exist in the database, the find method will not throw any exceptions. Instead, the Entity- Manager will return null or an empty entity and your application must handle this situation."

Is that true that the find() method can return an empty object, if it can not find the coresponding record in the database? Is it up to the persistence provider to decide whether to return a null or an empty object?

Thanks in advance.
The following section is from EJB 3 in Action page 299.

"An entity can become attached to the EntityManager’s context when you pass the entity to the persist, merge, or refresh method."

Does the entity get attached to the persistence context when it passed to the refresh() method or is this an error in the book?

Thanks in advance.

I am pretty new to EJBs.

The above sample code is from "EJB 3 in Action" book pages 303 and 304.

@Stateless
public class ItemManagerBean implements ItemManager {
@PersistenceContext(unitName="actionBazaar")
private EntityManager entityManager;
public ItemManagerBean() {}

public Item addItem(String title, String description, byte[] picture, double initialPrice, long sellerId) {
Item item = new Item();
item.setTitle(title);
item.setDescription(description);
item.setPicture(picture);
item.setInitialPrice(initialPrice);

Seller seller = entityManager.find(Seller.class, sellerId);

item.setSeller(seller);
entityManager.persist(item);

return item;
}

public Item updateItem(Item item) {
entityManager.merge(item);
return item;
}

public Item undoItemChanges(Item item) {
entityManager.refresh(entityManager.merge(item));
return item;
}

public void deleteItem(Item item) {
entityManager.remove(entityManager.merge(item));
}
}


Within the undoItemChanges() method the entityManager.merge() is called first on the item object before calling the entityManager.refresh() method.

I understnad that in this instance, the merge() is called before refresh() is to attach the item entity to the persistence context and also that any method invocation on EntityManager (like merge() or refresh()) will not get executed on the database straight away. I also understand that the merge() method is used to update the database from an object and the refresh() method is called to update and object from the databse.

According to the given code sample (ie. undoItemChanges() method), does the merge() method call will be over-written by the call to the refresh() method before they get executed on the database? That means the merge() method will not get executed on the database at all, which will stop updating the item record in the database.

Otherwise if the merge() get executed first and the refresh() get executed after on the database will the following scenario could happen? Let say the item object was already modified (different from the database record) while it was detached. When we execute merge() it will update the databse with the changes. When we call refresh() it will update the item object with latest data from the database. The state of the item object will be the same as before we executed undoItemChanges(). If this happens the undoItemChanges() method functionality will not be correct.

So, if I simplified my question, I am trying to figure out whether merge() and refresh() will be executed in that order on the database for the given code sample. If so, wouldn't that give an unexpected result.

Can someone please explain what will actually happen behind the scene?

Thanks in advance.
HI,

One of the objectives in 959 exam is "Identify supported portlet frameworks". I searched in the 6.1 Information Center (http://publib.boulder.ibm.com/infocenter/wpdoc/v6r1m0/index.jsp) and I can only find Struts Portlet Framework. Is that it for Portlet Frameworks in 6.1? Or do we consider JSR168 and JSR286 as Portlet Frameworks as well? Or are there more Portlet Frameworks?

Thanks in advance.

Cheers,
Tyronne