Skip to main content

Creating Stateless Session Bean Using NetBeans 7.4 with Companion Video on YouTube

In this article we will learn how to create a Stateless Session Bean in NetBeans 7.4. There is a screen cast video for this article on YouTube (Creating Sample Stateless Session Bean in NetBeans 7.4)


Session beans are the part of Enterprise Java Beans (EJB) which are based on RMI as basic foundation technology. Good Introduction to Enrerprise Java Beans its types and application is been provided by Oracle Inc on its site at  J2EE Tutorial (PDF)

A stateless session bean does not maintain a conversational state with the client. When a client invokes the methods of a stateless bean like Remote Method Invocation , the bean’s instance variables may contain a state specific to that client but only for the duration of the invocation. When the method is finished, the client-specific state should not be retained.

Most Often Stateless Session beans are more scalable due to their stateless nature.It is to be noted that it is developers responsibility that he/she does not include any code which may turn out to be a non-transient data for clients request for invocation of session beans business method.

When Creating stateless session beans in NetBeans we need to follow the following steps in general.
As like RMI where every client has a copy of interface containing  remote method's declaration , Session Bean's Remote interface is distributed in form of Java Class Library , a .file jar. So before we start creating session bean its good we create a blank Java Class Library Project.

We will be creating a Session Bean with business method "int getSquare(int var)" which would return us square value of argument passed. Finally we will create a java servlet to access Session Bean's business method as a client.

Step 1: Create a blank Java Class Library Project. with a proper name and remember the name of the the project created you need select this project while creating Remote interface  for Session Bean in Step 2



Step 2: Create an Enterprise application with EJB Module and Web Project. Ensure that you are selecting GlassFish as a Server ,since Apache Tomcat does not come with EJB Container.





After you are done with creating  Enterprise application you will find that two projects have been created one with EJB module and Other with Web Module in which you write a Servlet to act as Client.

Add a new Session Bean to the EJB module , the type of Session bean should be Stateless and also create Remote and Local Interfaces for the created Bean



While creating Remote interface you need to select the Java Class Library Project which you have created in Step 1 to hold Remote interface which would be containing Business method's declaration.


 Add a Business method to your Session Bean



Step 4: Create a Servlet in Web Project and call EJB's Business method







Step 5: Deploy the Enterprise Project and call servlet in browser by using its context path.


Your Servlet's output should look somewhat like below screen




Happy Coding !!! :)







Comments

  1. I have read your blog its very attractive and impressive. I like it your blog.


    JavaEE Training in Chennai JavaEE Training in Chennai

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training Core Java 8 Training in Chennai Java 8 Training in Chennai

    ReplyDelete
    Replies
    1. IEEE Cloud computing DOamin is a general term for anything that involves delivering hosted services over the Internet. IEEE Projects on Cloud Computing The cloud is a metaphor for a global network of remote servers which operates as a single ecosystem, commonly associated with the Internet. IEEE FInal Year Project Domains Final Year Projects for CSE cloud computing is the delivery of computing services—including servers, storage, databases, networking, software, analytics, and intelligence


      JavaScript Training in Chennai


      JavaScript Training in Chennai

      Delete
    2. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
      Cyber Security Projects for Final Year

      JavaScript Training in Chennai

      Project Centers in Chennai

      JavaScript Training in Chennai

      Delete
  2. Spring's spring-beans institution has an org.springframework.beans.BeanUtils class that implements a copyProperties method for copying a source object instance into a target object occurrence. However, it only does so for the object's initial level fields.If you want to belong become learning for Java Real-Time Training and Live High-Level Experience instructor Trained from Java Training Programme Course to reach us
    Java Training in Chennai | Java Training Institute in Chennai

    ReplyDelete
  3. Great way of explaining.. searched the whole internet but didn't found such resource.. thnx a ton!

    ReplyDelete
  4. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site. hadoop training in bangalore

    ReplyDelete
  5. AWS Training in Bangalore - Live Online & Classroom
    myTectra Amazon Web Services (AWS) certification training helps you to gain real time hands on experience on AWS. myTectra offers AWS training in Bangalore using classroom and AWS Online Training globally. AWS Training at myTectra delivered by the experienced professional who has atleast 4 years of relavent AWS experince and overall 8-15 years of IT experience. myTectra Offers AWS Training since 2013 and retained the positions of Top AWS Training Company in Bangalore and India.


    IOT Training in Bangalore - Live Online & Classroom
    IOT Training course observes iot as the platform for networking of different devices on the internet and their inter related communication. Reading data through the sensors and processing it with applications sitting in the cloud and thereafter passing the processed data to generate different kind of output is the motive of the complete curricula. Students are made to understand the type of input devices and communications among the devices in a wireless media.

    ReplyDelete
  6. A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  7. An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  8. For Hadoop Training in Bangalore Visit : Hadoop Training in Bangalore

    ReplyDelete
  9. Excellent and very cool idea and great content of different kinds of the valuable information's.

    Python Training Institute in Pune
    Best Python Classes in Pune

    ReplyDelete
  10. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
    Reactjs Training in Chennai |
    Best Reactjs Training Institute in Chennai |
    Reactjs course in Chennai

    ReplyDelete

  11. This blog is very useful it include very knowledgeable information. Thankyou for sharing this blog with us. If anyone want to experience certificate in bangalore can call at 9599119376 or can visit https://experiencecertificates.com/experience-certificate-provider-in-bangalore.html

    ReplyDelete
  12. Thanks for sharing this post , if anyone looking his/her career in sas so join with High technologies solutions Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/business-analytics/sas-training-institute-in-delhi

    ReplyDelete

Post a Comment

Popular posts from this blog

Why Learn Cloud Computing and Big Data ?

Today “Cloud computing” and "Big data" have become one of those buzzwords you hear everywhere whether you are a IT professional, a Faculty or a Student. So let's clear up what these buzzwords really mean and why to learn technologies associated with them in convergence. The easiest definitions which I find quite simple and quick to grasp for any layman to expert are from Wikipedia. Let me take defination of Big Data from Wiki. Wikipedia defines big data as, “Big data” is an term for any collection or grouping of data sets which are so large and complex that at some point of time it becomes difficult to process them using traditional data processing applications like RDBMS or single node sequential processing. The main hindrances in processing of Big data are its analysis, extraction, processing, searching, sharing, storage, transfer, visualization. As far as what cloud computing is, I prefer the definition from IBM and it goes as:  “Cloud computing, often referred to

Project Areas and Ideas for Undergraduate and Graduate level CS/IT Enggineering

The most intriguing question in your minds when you are at a stage to choose your graduate or undergraduate projects is  "How to choose an Project area ?" Well by asking following further questions to yourself, will assist you in choosing most suitable project area for your Course. 1) What's the duration you have to complete the project ? 2) Do you have enough knowledge about the area you wish to do project in ? 3) Do you get any guidance in case you get stuck (technical guidance) ? 4) Which development language you will choose ? 5) Do you know how to manage your project ? 6) Do you have geeks in your group (monkey coders , your friends with big lenses spending time learning new technologies :-) ) ? 7) Do you know what exactly are you doing (with your Project Idea)??? 8) Constant activity on Project required !! Some Prospective Project Areas in CS but not limited to !! Web Technologies Cloud Computing and BigData Analytics Databases Data mining & Web Mining