Creating your first Enterprise Application Project on eclipse-jee-helios
Tech-Today

Creating your first Enterprise Application Project on eclipse-jee-helios


First you should create an ejb project as specified here:
http://czetsuya-tech.blogspot.com/2011/03/creating-your-first-ejb3-project-in.html

Take note that my interface were inside the ejb project. You can pull that out and place in its own project ipielEJB2Client.

Note that I set it up on jboss server.

How to create an EAR project, with EJB, EJB Client and Dynamic web project.

1.) Follow the instruction above
2.) You can extract the interface in an ejbclient. The best way to accomplish his is on creating the ejb project, check the option that says "include client".
Let's name the 2 projects ipielEJB2 aind ipielEJB2Client.
ipielEJB2Client should include jboss-javaee.jar in its build path, which can be found on JBOSS_HOME/common/lib.
3.) Create an EAR project, name it ipielEJB2EAR.
The workspace should look like this:
4.) I assume you followed the instruction in the link above. aside from that we need to do some modifications.
add method: String sayHello(String name); to both BookBeanLocal and BookBeanRemote class.
And of course it's implementation on BookBean.java:
public String sayHello(String name) {
return getClass().getName() + " says hello to " + name + ".";
}
5.) Create a new Web Dynamic Project, lets name it ipielEJB2Web
6.) Add index.jsp, with the following code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Enterprise Application Development</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/sayHello">
<input type="text" name="name" /><input type="submit" value="Submit" />
</form>
</body>
</html>
7.) Add a new servlet in the same project (ipielEJB2Web) with the following code (it will handle the get request):
package com.kbs;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.kbs.BookBeanRemote;

/**
* Servlet implementation class IpielServlet
*/
public class IpielServlet extends HttpServlet implements Servlet {
private static final long serialVersionUID = 1L;

@EJB
BookBeanRemote remoteBook;

public IpielServlet() {
super();
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
if (name == null || name.length() == 0) {
name = "anonymous";
}
response.getWriter().write(remoteBook.sayHello(name));
}

}
8.) ipielEJB2Web project should look like the following:
9.) Right click ipielEJBEAR project and click properties. Go to references and add click the following projects:
ipielEJB2, ipielEJB2Client, ipielEJB2Web
10.) Right click ipielEJB2Web and select Run on Server. If you don't have a server configure yet, then configure 1. I used jboss5.1 ga.
11.) Make sure to start the server.
12.) Open the following url in your browser: http://localhost:8080/ipielEJB2Web, did you see something like this:

Any question? Feel free to ask :-D




- Social Login Using Rest Fb
This is an implementation tutorial on how we can use REST FB to enable facebook social login on our web application. Basically, it's a project created from javaee7-war template. To run this app you need to set up a Facebook application with callback...

- Do Some Initialization Work After The Web Application Initialization Process
We can achieve this by using a webListener. See code below: package com.czetsuya; import java.text.MessageFormat; import java.util.ResourceBundle; import javax.inject.Inject; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener;...

- How To Implement No Caching On Jsf Pages
Currently there are 2 ways I know that can do this. 1.) By implementing Filter and manually overriding the cache controls. See code below (note: not my original I found this somewhere else long time ago): @WebFilter(servletNames = { "Faces Servlet" })...

- Using Ejb3.1 As The Backing Bean For Jsf Using Cdi (jsr-330)
This tutorial assumes that you already have knowledge on EJB, JSF, maven and injection. These are the steps as well as the code I use to make it work. 1.) Create 2 maven projects (web, ejb - has HelloBean class) 2.) 2.) In the web part we need to create...

- Creating And Testing A Web Service Using Soap Ui
I just want to share a simple example on how to create and test a web service on java. Download and install the following: 1.) eclipse java (client) 2.) eclipse jee (web service) 3.) jboss 5.1 AS 4.) soap ui, get the stand alone (http://www.soapui.org/)...



Tech-Today








.