Multiple Business Interfaces

5 March 2012 By Nithya Vasudevan 1,364 views No Comment
1 Flares Twitter 0 Facebook 1 Google+ 0 1 Flares ×
  • A business interface cannot be annotated with more than one access type.
  • For example, an interface HelloWorld cannot have both @Local and @Remote annotations.
  • If we want the bean to provide multiple client views (for eg. both Local and Remote) we need to create two interfaces HelloWorldLocal and HelloWorldRemote annotated with @Local and @Remote respectively and let the bean HelloWorldBean implement both the interfaces as shown below.

Local Client View:

import javax.ejb.Local;

public interface HelloWorldLocal {
	String sayHello();

Remote Client View

import javax.ejb.Remote;

public interface HelloWorldRemote {
	String sayHello();

Session Bean class

import javax.ejb.Stateless;
public class HelloWorldBean implements HelloWorldLocal, HelloWorldRemote
    public HelloWorldBean() {

	public String sayHello() {
		return "Hello World !!!";

Tags: , , ,