Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy EJB on server?

I am learning EJB3 from last few days. I have many questions regarding EJB, application servers and deployment of EJB.

To start with, I have created one simple helloworld stateless session bean but I don't know how to deploy it on server. It has single bean class, bean interface and one servlet client. I have used eclipse to develop this project.
None of the books that I read gives step by step details about how to put EJB on server and how to access those beans.

I have JBoss 6 server and I also have Java EE budle downloaded from sun website. Does this Java EE bundle contains Glassfish server? or do I need to download it separately?
Can anyone please give me step by step details of how to put my bean and its client on server (JBoss or Java EE)?

And why do we need to include bean interface class in EJB client code? I mean either we need to keep client and bean in same package or if we keep them in seperate packages we need to import bean interfaces in client code. Am I right?

like image 422
Shekhar Avatar asked Mar 29 '10 04:03

Shekhar


People also ask

Which server is used to implement EJB?

Using WebLogic Server Generic Bean Templates For each EJB type, WebLogic Server provides a generic class that contains Java callbacks, or listeners, that are required for most EJBs.

How does EJB work internally?

The EJB container interacts directly with a message-driven bean—creating bean instances and passing JMS messages to those instances as necessary. The container creates bean instances at deployment time, adding and removing instances during operation based on message traffic.

What is EJB in WebLogic?

Enterprise JavaBeans (EJBs) are Java EE components that implement EJB technology. EJBs run in the EJB container, a runtime environment within Oracle WebLogic Server.

What is an EJB file?

An Enterprise JavaBeans (EJB) module is used to assemble one or more enterprise beans into a single deployable unit. An EJB module is stored in a standard Java™ archive (JAR) file. An EJB module contains the following: One or more deployable enterprise beans.


1 Answers

With Java EE 6, you can package your Servlet and your EJB in a WAR (either package your EJB in a JAR and put it in WEB-INF/lib or simply put all classes in WEB-INF/classes). And to deploy this WAR, copy it to:

  • $GLASSFISH_HOME/domains/<domain1>/autodeploy for GlassFish v3*
  • $JBOSS_HOME/server/default/deploy for JBoss 6

With Java EE 5, you'll have to package your code in a EAR.

And if you want to deploy your application from Eclipse (using the Eclipse WTP), you'll have to install the appropriate server adapter. For Eclipse Galileo and GlassFish (there is currently no adapter for JBoss 6 AFAIK), right-click the server view, select New > Server, click on Download additional server adapters and select the GlassFish adapter. Finish to define your new GlassFish v3 Java EE 6 server and deploy your application on it (right-click on your application then Run As > Run on Server). For Eclipse Helios and GlassFish, you can follow the link given by @VonC (manual install) or check this answer (install via the Update Site).

like image 56
Pascal Thivent Avatar answered Oct 03 '22 15:10

Pascal Thivent