Reputation: 61
I would be very much thankful to clear me some question about this new EJB3.0 and above version:
1) if suppose I need ejbCreate
, ejbActivate
and all other events so how can I get it from the new EJB3.0 and above ver.
2) I always have problem to find particular xml file to alocate a JNDI name according to variety of Application Servers so is there any way that I can give JNDI name without xml file and can also be use a portable name that in every Application Server it can be findable of EJB deployed on app server remotely
3)Can any buddy tell me, i have hosting plan of Java/Linux which supports i) Tomcat - 5.5.xSupport ii)JDK - 1.6.x Support iii)JSP/servlet - 2.0 Support
can it be possible that EJB 3.1 be deployed because some where i have got that tomcat is not able to deploy EJB so please give me some advice help...
Thank You...!!! please Help me...!!!
Upvotes: 1
Views: 1075
Reputation: 14943
Since no one answered Question 3 ..
3)Can any buddy tell me, i have hosting plan of Java/Linux which supports i) Tomcat - > 5.5.xSupport ii)JDK - 1.6.x Support iii)JSP/servlet - 2.0 Support
No, you are going to need a server that supports Java EE. Read How to deploy EJB based application on Tomcat
Upvotes: 0
Reputation: 336
1) if suppose i need ejbCreate, ejbActivate and all other events so how can i get it from the new EJB3.0 and above ver.
In EJB 3 and above, the EJB lifecycle is handled through life cycle annotations, such as: @PostConstruct and @PreDestroy.
2) i always have problem to find perticular xml file to alocate a JNDI name according to variety of Application Servers so is there any way that i can give JNDI name without xml file and can also be use a portable name that in every Application Server it can be findable of EJB deployed on app server remotly
The @Stateless and @Stateful annotations have two attributes that might solve this issue (name and mappedName). Yet
The mapped name is product-dependent and often installation-dependent.
Hope it helps you.
Upvotes: 3
Reputation: 15261
1) ejbCreate, ejbActivate
etc. are related to EJB 2.x, if you need similar functionality in EJB 3.x, you should decorate your methods with annotations @PostActivate, @PrePassivate
etc. Method signature should follow certain rules, example for @PostActivate
:
The method annotated with @PostActivate must follow these requirements:
The return type of the method must be void. The method must not throw a checked exception. The method may be public, protected, package private or private. The method must not be static. The method must not be final.
This annotation does not have any attributes.
2) It seems that you're referring to name
and mappedName
attributes of @Stateless
and @Stateful
annotations. For more details see official documentation. From my experience mappedName is better, but it's application-server-specific, e.g. on Glassfish it works perfectly. Example:
@Stateless(mappedName="ejb/myBean")
public class MyFirstBean {
..
}
Upvotes: 2