Ejb Programe Run On Jboss
Ejb Programe Run On Jboss
Ejb Programe Run On Jboss
D:\jboss-4.2.0.GA\server\default\lib\jboss-j2ee.jar
For Servlets
D:\jboss-4.2.0.GA\client\servlet-api.jar
JAVA_HOME
JBOSS_HOME
D:\jboss-4.2.0.GA\bin
J2EE Application
Web Client JSP OR Servlet ->Java Server (Tomcat) mapping (web.xml)
class file server container EJB Database
Ejb files--
1. wizardSession.java---------Remote interface
2. wizardSessionHome.java-------Home Interface
3. wizardSessionBean.java-------Bean File
4. wizardServlet.java-----------UI
wizardServlet.java
package com.wizard.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wizard.WizardSession;
import com.wizard.WizardSessionHome;
/**
* author mohd zaid khan
* @Email zaid.khan@wizardinfosolutions.co.in
*/
WizardSessionHome wizardSessionHome;
out.println("<html>");
out.println("<head>");
out.println("<title>Hello World Servlet!</title>");
out.println("</head>");
out.println("<body>");
out.println("<p align=\"center\"><font size=\"4\" color=\"#000080\">Servlet
Calling Session Bean</font></p>");
try{
WizardSession wizardSession;
wizardSession = wizardSessionHome.create();
out.println("<p align=\"center\"> Result is: <b>" +
wizardSession.addNumber(20,400) + "</b></p>");
wizardSession.remove();
}catch(Exception CreateException){
CreateException.printStackTrace();
}
out.println("<p align=\"center\"><a href=\"javascript:history.back()\">Go to
Home</a></p>");
out.println("</body>");
out.println("</html>");
out.close();
}
wizardSession.java
package com.wizard;
/**
* author mohd zaid khan
* @Email zaid.khan@wizardinfosolutions.co.in
*/
WizardSessionHome.java
package com.wizard;
/**
* author mohd zaid khan
* @Email zaid.khan@wizardinfosolutions.co.in
*/
WizardSessionBean.java
package com.wizard;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
/**
* author mohd zaid khan
* @Email zaid.khan@wizardinfosolutions.co.in
*/
1---
WEB-INF----
1. jboss-web.xml
2. web.xml
3. classescomwizardservletWizardServlet.class
i. jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.2//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web.dtd">
<jboss-web>
</jboss-web>
http://www.apache.org/licenses/LICENSE-2.0
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>zaid</servlet-name>
<servlet-class>com.wizard.servlet.WizardServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>zaid</servlet-name>
<url-pattern>/call</url-pattern>
</servlet-mapping>
</web-app>
iii. classescomwizardservletWizardServlet.class
After this
We will create a .war file of WEB-INF folder
Wizard.jar---- WEB-INF--
1. jboss-web.xml
2. web.xml
3. classescomwizardservletWizardServlet.class
2--
Second Step-
we will make Two folder Ist Meta-inf and com folder
META-INF folder hv three file
And com hv one folder wizard hv three .class file
1. META-INF--
i. ebj-jar.xml
ii. jboss.xml
iii. MANIFEST.MF
2. com-wizard--
i. WizardSession.class
ii. WizardSessionHome.class
iii. wizardSessionBean.class
1. META-INF
i. ebj-jar.xml
<ejb-jar>
<description>Example 3</description>
<display-name>Example 3</display-name>
<enterprise-beans>
ii. jboss.xml
<jboss>
<enterprise-beans>
<session>
<ejb-name>wizardSessionBean</ejb-name>
<jndi-name>ejb/test/WizardSessionBean</jndi-name>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss>
iii. MANIFEST
Manifest-Version: 1.0
Created-By: 1.5.0_06 (Sun Microsystems Inc.)
2.. com-wizard--
i. WizardSession.class
ii. WizardSessionHome.class
iii. wizardSessionBean.class
After this
We will create a .jar file of WEB-INF folder
zaid.jar-------------- 1. META-INF--
ii. ebj-jar.xml
iii. jboss.xml
iv. MANIFEST.MF
2. com-wizard--
iv. WizardSession.class
v. WizardSessionHome.class
vi. wizardSessionBean.class
zaid.jar--------------- META-INF+com
3--
third Step-
we will make one folder Meta-inf
1.META-INF-- application.xml
application.xml
<application>
<display-name>Example 3 </display-name>
<module>
<web>
<web-uri>wizard.war</web-uri>
<context-root>/wizard</context-root>
</web>
</module>
<module>
<ejb>zaid.jar</ejb>
</module>
</application>
After this
Jboss configuration
C:\jboss-4.2.0.GA\server\default\deploy/sir.ear
Run file
======
Open the brower http://localhost:8080/wizard/call
output
close