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. 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 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
  11. 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
  12. Your blog is very nice and interesting. Your way of writing this blog forced me to read the full blog. Being a new reader, your blog increased my interest in reading. If anyone is interested for Fake Experience Certificate in Chennai here we have the chance for you, Dreamsoft is providing is Fake experience certificate in Chennai. To get you experience certificate in Chennai you can contact at 9599119376. or can visit our website at https://experiencecertificates.com/experience-certificate-provider-in-chennai.html

    ReplyDelete
  13. This blog is very useful for me it gives me the very knowledgeable information to me. Dreamsoft is the 20years old consultancy providing the experience certificate in many status of the India. the interested may contact at the 9599119376 or can visit our website for the
    Career Boosting Genuine Experience Certificate In Mumbai
    https://experiencecertificates.com/experience-certificate-provider-in-mumbai.html
    Career Boosting Genuine Experience Certificate In Gurugram
    https://experiencecertificates.com/experience-certificate-provider-in-Gurgaon.html
    Career Bosting Genuine Experience Certificate In Delhi
    https://experiencecertificates.com/experience-certificate-provider-in-delhi.html
    Career Boosting Experience Certificate In Noida
    https://experiencecertificates.com/experience-certificate-provider-in-Noida.html
    Career Boosting Genuine Experience Certificate In Bangalore
    https://experiencecertificates.com/experience-certificate-provider-in-bangalore.html
    Career Boosting Genuine Experience Certificate Hyderabad
    https://experiencecertificates.com/experience-certificate-provider-in-Hyderabad.html

    ReplyDelete
  14. A big thank you for sharing this post and if anyone looking for best c++ institute in delhi Contact Here-+91-9311002620 Or Visit Website-https://www.htsindia.com/Courses/modular-courses/c-plus-plus-training-course

    ReplyDelete
  15. Thank you for sharing such a really admire your post. Your post is great! . micronutrients fertilizer for plants

    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

Creating your First Ruby on Rails (RoR) application using scaffolding on Windows with Rails in 7 Steps

We will use Bitnami Ruby stack on Windows Environment through out this article If you are absolute beginner and need to start from knowing what is Ruby and Rails try below links   What is Ruby ? What is Rails ? Once you get acquaint with basic syntax of Ruby try out basic ruby code snippets in an interactive shell like web environment here at http://tryruby.org Prerequisites for this article: Bitnami Ruby Stack: (You can download the Bitnami installer at URL ). Once installed it starts appearing in your start menu as  Start > All Programs > Bitnami Ruby Stack Bitnami Ruby Stack is an Ruby environment with Rails and other  software  stacks like Apache , MySQL , PostgreSQL. It is good starting point when you start learning RoR development since here you need not struggle with RoR installation and other configurations, Remember that Bitnami Ruby Stack is for development purpose only. And I further feel that Production RoR environment should be using Lin