开发者

session beans belong to an application?

开发者 https://www.devze.com 2023-01-04 20:41 出处:网络
I have a newbie question as it relates to EJBs开发者_运维知识库. When we compose a web application, all the jsp\'s/servlets etc are organized/packed into a war file which is deployed on to the server,

I have a newbie question as it relates to EJBs开发者_运维知识库. When we compose a web application, all the jsp's/servlets etc are organized/packed into a war file which is deployed on to the server, when it comes to session beans and their deployment, are they treated as container level components that dont belong to any individual application?


No, they're not. EJBs should be packaged into a JAR (so called EJB-JAR) and then assembled into an EAR (that wraps EJB-JAR(s), WAR(s) and RAR(s)). Packaging EJB 3 Applications is a very good article (from the authors of EJB 3 in Action) on this topic and covers classloading, packaging and deployment of Java EE modules. Highly recommended.

Since Java EE 6, it is possible to deploy EJBs as part of a WAR (either put EJB-JARs in WEB-INF/lib or the classes directly in WEB-INF/classes). Note that all the classes are then loaded with the same classloader in this scenario (contrary to the EAR packaging). If you don't have strong modularization needs (which is the case of most applications), this is very interesting because simpler. Of course, the EAR packaging is still available for those with more advanced modularization requirements.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号