I would like to migrate some old EJB 2.1 code to EJB 3.0, but there is some handling of configuration errors in the ejbCreate method. Is there an EJB 3 version of that method?
Edit: In EJB 2.x ejbCreate could throw a CreateException. Based on the documentation of @PostConstruct etc. I can no longer throw any checked Exceptions. How can i handle this if i cannot migrate the code using the EJB right now.
Edit2: The frontend specifically handles CreateException which unfortunately is checked.
@PostConstruct
public void anyName() {
//initialization code, dependencies are already injected
}
No only the name is arbitrary, you can have several UPDATE:@PostConstruct
methods in one EJB - however the order of invocation is unspecified, so be careful and try to stick with one method.
Only one method can be annotated with this annotation.
You need to use EJB 3.0 lifecycle callback methods using annotations
@PostConstruct, @PreDestroy, @PostActivate or @PrePassivate
These annotations can go on any method that is public, void and no-arg.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With