Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Help Required in Session Bean Interface

Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

public class SessionBean implements SessionRemote {

@Resource(name = "jdbc/sample1")
private DataSource jdbcSample1;
private Connection conn;
private String var;

public SessionBean() {

public void init()throws Exception{
System.out.println("Connection initilized");

public void getResult() {
var="SessionBean call";
public String getAnotherResult()throws Exception {
return var+" Another SessionBean call"+conn;

public void cleanup()throws Exception{
System.out.println("connection destroyed");

public void remove(){
System.out.println("remove called");
Above is code for Statefull Session Bean.
For above bean the SessionRemote interface should contain following methods

What about cleanup() and remove() methods,should i define theses methods in SessionRemote interface or not.
In case i have to define remove() method in SessionRemote interface
should i add @Remove annotation for remove() method in SessionRemote interface or not.

Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gowher Naik ,

Yes, you have to define clearnUp , Remove methods in Interface, no need to declate @Remove in interface.
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The cleanup() method is annotated as @PreDestroy and @Prepassivate is considered as life-cycle callback method, so no need to add in the business interface.

The methods (may be more than one with different names) annotated with @Remove are business methods and you must add them into business interface, if you want to call them. You have to call these methods annotated with @Remove explicitly in client codes. They are not called automatically by container. When you called one of the method annotated with @Remove the stateful bean instance is removed.

Hope this help

    Bookmark Topic Watch Topic
  • New Topic