File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes very much new to ejb. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "very much new to ejb." Watch "very much new to ejb." New topic
Author

very much new to ejb.

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 931
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..
Raghav Viswanathan
Greenhorn

Joined: Apr 26, 2012
Posts: 26

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

Better late than never.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 931

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

Joined: Aug 20, 2011
Posts: 931
also can you tell me what is HomeInterface class, i read that we also write this class, when writing ejb..?
Raghav Viswanathan
Greenhorn

Joined: Apr 26, 2012
Posts: 26

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

http://www.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

Joined: Aug 20, 2011
Posts: 931
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...
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2052
    
  22

What you need to do is go through some tutorials. Here, have fun
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 931
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??
David Blevins
Greenhorn

Joined: May 03, 2010
Posts: 18
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

Joined: Aug 20, 2011
Posts: 931
that is really helpful.
thank you david.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: very much new to ejb.
 
Similar Threads
Stateless session Bean look up
how to execute EJB in websphere
Pooling vs Instance Caches
How to integrate hibernate and EJB (stateless session bean)
Caching EJB3 remote references prevents pooling or not