Passion of IT

Enterprise Java Beans and all J2EE

This is a schema of a simple java application

 

j2ee

 

1 Presentation layer

The presentation layer is the software to show web pages and to allow the user interaction it is a http client called browser (for example mozila firefox or google chrome or microsoft internet explorer) this software executes a http request and processes the result html page (for example it formats the text of the page with the code written in CSS files and also executes javascript code)

The presentation layer is the layer that receives http request, calculates the response (in most cases calling the business layer) and sends the response to the client web browser.

There are a lot of ways to receive an http request:

  1. using servlet: Java class that works in background on the server machine at a specific socket (address of 4th level of TCP that consists of IP-Port)
  2. using a JSP java server pages, html page with java code
  3. using specific front end framework for example spring model and view or JSF etc. NB this framework uses a specific servlet that converts the request http in a command that are processed by framework.
  4. using rest services that convert all methods of http request (get put post delete) in a CRUD (create, read, update, delete) operations of database. This point usually is performed by business tier.

2 business layer

Here is defined the business logic of the application, this level is made of  a lot of technologies:

  1. Web service SOA
  2. Rest services
  3. RMI
  4. EJB
  5. Corba
  6. Other frameworks and different technologies for example web sphere message broker, websphere data stage, workflows Mule etc.
  7. JMS

Ejb is one of these technologies, it is composed by three types of bean:

container-ejb

  • Message Driven Bean: this bean is used for making MOM (message oriented middleware) and the communication is made of asynchronous messages. I used this bean in the project of Java message service and I discovered that this technology has more priority than JMS
  • Session Bean: this bean is used to perform the communication between client peer that needs to call remote method and server peer that share this method. It is like RMI. There are two types of session beans: Stateful (remembers the state of the application) and Stateless (don’t remember the state of the application).
  • Entity Bean: is a persistent technology that is encapsulated in JPA

3 Persistence Layer

necessary to perform the operation with the database, the technologies used are hibernate or JPA (entity java beans)

 

4 Data Base (ETL)

for example mysql, oracle, db2 is the archive that contains all structural data of the system

J2EE Server

J2EE servers are special servers in which run the Java Virtual Machine, there are two types of servers:

  • Web servers: this server like apache tomcat allows to execute only web application, this application is stored in a special archive with extension war (web archive). This web server receives http request and executes it calling another server or by using internal libraries
  • Application server: this server has as web container (to execute web application) as EJB container (to execute EJB). The above server can execute the below three type of archive: simple JAR (Java archive) for example that includes EJB, WAR (web archive that includes web application) and EAR (Enterprise Archive) that includes both WAR and JAR. The application server has many modules for example queue for making JMS or login module to perform the login at the access of the system (my webapp affittavetrina doesn’t use login module of jboss but the login page is implemented by me), mySql module to execute my sql code etc.  You can use JNDI for getting the information contained in these module. These servers are a little slow and require much more memory ram of java virtual machine. An example of these servers are Jboss, IBM Websphere, oracle weblogic etc
  • Other special servers for making special middleware for example WebSphere message broker that read BAR files (broker archive)

My Projects

I studied all these three beans and I already made JMS and ejb message driven beans and now I tried to made EJB Session bean project but I failed the client:

The server was developed correctly because the logs show:

java:global/ejbRM/RSessionBean!ejbRM.SessionBean
java:app/ejbRM/RSessionBean!ejbRM.SessionBean
java:module/RSessionBean!ejbRM.SessionBean
java:global/<strong>ejbRM/RSessionBean!ejbRM.SessionBeanRemote</strong>
java:app/ejbRM/RSessionBean!ejbRM.SessionBeanRemote
java:module/RSessionBean!ejbRM.SessionBeanRemote
java:jboss/exported/ejbRM/RSessionBean!ejbRM.SessionBeanRemote
java:global/ejbRM/RSessionBean!ejbRM.SessionBeanLocal
java:app/ejbRM/RSessionBean!ejbRM.SessionBeanLocal
java:module/RSessionBean!ejbRM.SessionBeanLocal

but when I call this server the client remains in a loop.

The socket is correct because if it is wrong jboss logs an exception, in my opinion the reference of the method is wrong but I tried with this syntax:


ejb://ejbRM/RSessionBean!ejbRM.SessionBeanRemote

and with this syntax:


SessionBeanRemote.class.getName() +"/remote"

but client when executes the lookup remains in loop

this is the main of the client:


public static void main(String[] args) throws NamingException {
BasicConfigurator.configure();
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
p.put(Context.PROVIDER_URL, "127.0.0.1:8080");
InitialContext ctx = new InitialContext(p);
SessionBeanRemote ejb = (SessionBeanRemote) <span style="color: #ff6600;">ctx.lookup("ejb://ejbRM/RSessionBean!ejbRM.SessionBeanRemote");</span>
ejb.SessionBeanMethod();
System.out.print("end");
}

when server executes the orange lines remains in loop and logs the following line:


0 [main] DEBUG org.jnp.interfaces.TimedSocketFactory - createSocket, hostAddr: /127.0.0.1, port: 8080, localAddr: null, localPort: 0, timeout: 0

No Comments Yet

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite="
"> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Comments

Michele Rizzithe website doesn't exist. Ara you a robot? In any case it's difficult that an automatic system writes a comment here since there are two captchas...
Hello there! This is kind of off topic but I need some guidance from an established blog. Is it very hard to set up your own blog? I'm not very t...
We are a group of volunteers and opening a new scheme in our community. Your web site offered us with valuable information to work on. You've done a...
November 2024
M T W T F S S
« Dec    
 123
45678910
11121314151617
18192021222324
252627282930  

Login