Ask the Expert

Stateless EJBs for Java Web services

It is recommended that we use stateless EJBs for implementation of Java Web services. What are the logical reasons behind that? How do I manage state when using EJB as implementation for Java Web service? Are there stateless and stateful Web services? And how do you implement a Web service using stateful EJBs?

    Requires Free Membership to View

When discussing EJBs and Web services, stateless EJBs are usually recommended for building Web services. This is for a couple of reasons:
1) At present, Web services built around published standards are stateless
2) Stateless EJBs are usually recommended by the EJB community for encapsulating business logic.

Since current standards for Web services do not address maintaining state, you must use your own mechanism for maintaining state, such as proprietary cookies.

SOAP is currently the most widely discussed technology for Web service implementation and transport. Thus, any technology used to implement the logic that a service will expose, must, for all practical purposes, support SOAP. This means that whether or not you use EJBs to implement your Web services, your service implementations must interact with SOAP.

The EJB 2.1 specification introduces a standard mechanism for exposing a stateless session bean as a Web service. EJBs written to an earlier specification can take advantage of JAX-RPC and JAXM to interact as a Web service. Note that plain-old-Java-objects (POJOs) can be exposed as Web services using JAX-RPC and JAXM, as well.

Further information pertaining to exposing EJBs as Web services can be found at:

This was first published in July 2003

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: