Trying EJB 3.0

G

gaijinco

I'm trying to use EJB 3.0 to run a simple Dynamic Web Application

I have never used Java before to connect to a DB but I am fairly used
to the language.

However there seems to be a lot of information that unfortunalety
tends to be a comparison between EJB 2.x and EJB 3.0 and I'm lost.

Can anyone help me understand where should I begin? What parts of EJB
3.0 are the ones neccesary for a Dynamic Web Application?

Thanks.
 
O

Owen Jacobson

I'm trying to use EJB 3.0 to run a simple Dynamic Web Application

I have never used Java before to connect to a DB but I am fairly used
to the language.

However there seems to be a lot of information that unfortunalety
tends to be a comparison between EJB 2.x and EJB 3.0 and I'm lost.

Can anyone help me understand where should I begin? What parts of EJB
3.0 are the ones neccesary for a Dynamic Web Application?

Thanks.

No part of the EJB specification is necessary for a web application.
They can be helpful, though.

The easiest place to start is probably with a simple @Stateless EJB
("stateless session bean") that returns some hard-coded values to the
caller; you can then call it from your webapp. This can be as simple
as a "hello world" bean that returns a message.

Once that works, you can inject (using @Resource) a datasource and use
JNDI to talk to your database, or (using @PersistenceContext) a JPA
EntityManager instance into the stateless bean. You can also inject
(using @EJB) other collaborating EJBs.

-o
 
T

Tom Anderson

No part of the EJB specification is necessary for a web application.
They can be helpful, though.

The easiest place to start is probably with a simple @Stateless EJB
("stateless session bean") that returns some hard-coded values to the
caller; you can then call it from your webapp. This can be as simple as
a "hello world" bean that returns a message.

I've always thought that stateless beans were a solution in search of a
problem. What do they bring to the party that POJOs don't?

Perhaps as an easiest point of entry into the wonderful world of EJB they
have their use. But i'd be tempted to go straight to a stateful bean,
where you actually get some value out of it.

tom
 
O

Owen Jacobson

I've always thought that stateless beans were a solution in search of a
problem. What do they bring to the party that POJOs don't?

Semi-transparent remoting, and container-managed creation. Beyond
that, ideally most code is a collection of stateless objects that
cooperate against a very small collection of state stores (databases,
etc) -- stateful code is exponentially harder to prove correct. How
you get there, however, is up to you.

-o
 
A

Arne Vajhøj

Tom said:
I've always thought that stateless beans were a solution in search of a
problem. What do they bring to the party that POJOs don't?

Perhaps as an easiest point of entry into the wonderful world of EJB
they have their use. But i'd be tempted to go straight to a stateful
bean, where you actually get some value out of it.

Stateless session beans are probably the most popular EJB type.

It is remotely accessible, it has declarative transactions and
security, it comes with thread management by the container. Plenty
of good things compared to POJO's.

Arne
 
A

Arne Vajhøj

gaijinco said:
I'm trying to use EJB 3.0 to run a simple Dynamic Web Application

I have never used Java before to connect to a DB but I am fairly used
to the language.

However there seems to be a lot of information that unfortunalety
tends to be a comparison between EJB 2.x and EJB 3.0 and I'm lost.

Can anyone help me understand where should I begin? What parts of EJB
3.0 are the ones neccesary for a Dynamic Web Application?

Start by learning pure web app:
servlet
JSP
JSTL
EL
JSF

Then move on to full Java EE:
EJB (SLSB, SFSB, MDB, EB)
JMS
JCA

Arne
 
C

Corneil

I'm trying to use EJB 3.0 to run a simple Dynamic Web Application

I have never used Java before to connect to a DB but I am fairly used
to the language.

However there seems to be a lot of information that unfortunalety
tends to be a comparison between EJB 2.x and EJB 3.0 and I'm lost.

Can anyone help me understand where should I begin? What parts of EJB
3.0 are the ones neccesary for a Dynamic Web Application?

Thanks.

Dynamic Web Application in Java implies you may be using Servlets, JSP
or JSF or some Web Framework built on top of these. A Web Application
lives in the Web Container as described by the servlet specification.
EJB's live in an EJB container and provides a way to deploy your
business logic and persistance.
You can build a significant dynamic web application without the need
for EJB. However you may at some point need to make decisions around
the scalability of your application and then you may consider EJBs
when extending the application architecture for complex transactions
or message based processing.
 
C

Corneil

I'm trying to use EJB 3.0 to run a simple Dynamic Web Application

I have never used Java before to connect to a DB but I am fairly used
to the language.

However there seems to be a lot of information that unfortunalety
tends to be a comparison between EJB 2.x and EJB 3.0 and I'm lost.

Can anyone help me understand where should I begin? What parts of EJB
3.0 are the ones neccesary for a Dynamic Web Application?

Thanks.

Dynamic Web Application in Java implies you may be using Servlets, JSP
or JSF or some Web Framework built on top of these. A Web Application
lives in the Web Container as described by the servlet specification.
EJB's live in an EJB container and provides a way to deploy your
business logic and persistance.
You can build a significant dynamic web application without the need
for EJB. However you may at some point need to make decisions around
the scalability of your application and then you may consider EJBs
when extending the application architecture for complex transactions
or message based processing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top