How to deploy EJB on server?
Asked Answered
S

3

8

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?

Schiller answered 29/3, 2010 at 4:49 Comment(0)
K
8

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).

Knifeedged answered 29/3, 2010 at 10:28 Comment(2)
I didn't see your (much more complete) answer at the time. +1Sommersommers
Java EE 6 doesn't allow placing message driven beans inside the war.Foul
S
1

You need to add GlassFish to your Eclipse installation (see GlassFish plugin for Eclipse).

The full process is described here (with the latest Eclipse Helios 3.6M6)

Sommersommers answered 29/3, 2010 at 7:1 Comment(0)
D
1

You should export as EJB into your jboss<version>\server/default/deploy folder and then add the build path for it on the servlet's web project. You can "Run on Server" and choose an application server just like you would in any project, no need to export the WAR although if you do that, you're gonna have to re-export your WAR every time you modify your code
AFAIK there's no Eclipse plugin for JBoss 6 but Eclipse provides one for 5.1

Dropping answered 9/8, 2011 at 19:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.