• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

very much new to ejb.

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello all,
i m very much new to ejb, i read some theory.
and i want to write an stateless session bean.
what steps i need to follow, from scratch?
i m using eclipse, do i need something else also apart from eclipse?
what steps i need to follow to write a stateless session bean?


Thank you..
 
Greenhorn
Posts: 26
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Punit,

Hope you have read the right theory for EJB's. Because they do confuse you a lot.

EJB's over the years has become from a developer nightmare to developer friendly (from version 1 to version 3). The version that is widely being used is EJB 3.0

EJB3.0 is more like a POJO with a few annotations. all you have to do is follow these steps.

1. Create an interface with your own name and mark it as @remote
import javax.ejb.Remote;

@Remote
public interface FirstEJBRemote {

public int addTheseTwoNumbers(int a, int b);

}

2. import javax.ejb.Stateless;

/**
* Session Bean implementation class FirstEJB
*/
@Stateless
public class FirstEJB implements FirstEJBRemote {

/**
* Default constructor.
*/
public FirstEJB() {
// TODO Auto-generated constructor stub
}

public int addTheseTwoNumbers(int a, int b){
System.out.println("The two numbers are a = "+ a +" b = "+ b);
return a+b;
}

}


Thats it we are done coding a Session Bean. All you have to do is get yourself an application server(JBOSS, Websphere, Weblogic, glassfish etc.) , package it and deploy. It's that simple.

You just dont need any XML's at all.


Hope this helps.

Do let me know if you need details on how to delpoy them.

Thanks and regards
Raghav.V
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


EJB3.0 is more like a POJO with a few annotations. all you have to do is follow these steps.


seems ejb is not very much difficult.


All you have to do is get yourself an application server(JBOSS, Websphere, Weblogic, glassfish etc.) , package it and deploy.


i have tomcat configured.


Do let me know if you need details on how to delpoy them.



yes please help me in deploying it also.

Than you very much..
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
also can you tell me what is HomeInterface class, i read that we also write this class, when writing ejb..?
 
Raghav Viswanathan
Greenhorn
Posts: 26
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Punit,

I am not really aware if EJB ever runs on Tomcat. Tomcat is basically a web container based server and not an EJB container based. Check the following URL

https://coderanch.com/t/507273/java-EJB-SCBCD/certification/Tomcat-EJB-Specifications.

You can use any one of the following
JBOSS
WebLogic
Websphere
GlassFish

you might also have to check the version compatibility.


Thanks and regards
Raghav.V

 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii, i have installed and configured jboss into my eclipse.
now do i need to create java class files, in java project or i have to create ejb project in eclipse??


Thank you...
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you need to do is go through some tutorials. Here, have fun
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii, thanks for the link.
but the tutorial is not using eclipse, can you please let me know, do i need to create simple java project or ejb project in eclipse??
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the Eclipse support, you should use the JavaEE version of Eclipse. Assuming the server you plan to use supports Java EE 6 (all the major ones do at this point) then you can just create what Eclipse calls a 'Dynamic Web Project'.

You can add Servlets, EJBs and more to a Dynamic Web Project and it will work fine provided the server supports them. As of Java EE 6 all these things work in plain .war files.

Here's a video of creating a simple Dynamic Web Project in Eclipse and creating and deploying a Servlet, EJB and CDI bean using the Java EE version of Tomcat (TomEE):

http://www.youtube.com/watch?v=Lr8pxEACVRI

There are also a lot of EJB (and more) examples here:

http://tomee.apache.org/examples-trunk/
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that is really helpful.
thank you david.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic