Ejb Module

Ejb Module

Respected Sir/Mam

I m using jdk1.5 and jboss4.0.2 Here is my code File Name-sunLoginAction.java

/*
 * sunLoginAction.java
 *
 * Created on March 18, 2012, 12:31 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.myapp.struts;

import com.myapp.struts.ejb.EjbHome;
import com.myapp.struts.ejb.EjbRemote;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Administrator
 */
public class sunLoginAction extends Action {

    /** Creates a new instance of sunLoginAction */
    public sunLoginAction() {
    }
    private static final String SUCCESS = "success";

    public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
    {
        String formsg="success";
        sunLoginForm actionForm=null;
        if(form!=null)
        {
            actionForm=(sunLoginForm)form;
            System.out.println("Simple Message in Actionssss !!");

            try {
                 /*Properties env = new Properties();
       env.setProperty("java.naming.factory.initial", 
                 "org.jnp.interfaces.NamingContextFactory");
       env.setProperty("java.naming.provider.url",  "localhost:1099");
       env.setProperty("java.naming.factory.url.pkgs",  "org.jboss.naming");*/
            Context ic = new InitialContext();
            Object obj = ic.lookup("com/myapp/struts/ejb/Ejb");
            System.out.println("Cursor Here !!!! location 1\n");
            System.out.println(obj+"\t"+EjbHome.class);
            EjbHome home = (EjbHome)PortableRemoteObject.narrow(obj, EjbHome.class);
            System.out.println("Cursor Here !!!! location 2");
            EjbRemote objRm = home.create();
            String msg=objRm.stringMsg();
            System.out.println(msg);

        } catch ( Exception e ) {
            e.printStackTrace();
            formsg="failure";
        }
            //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        }
        return mapping.findForward(formsg);
    }
    }

//END sunLoginAction.java File

//Start sunLoginForm.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Administrator
 */
public class sunLoginForm extends org.apache.struts.action.ActionForm {

    private String name;
    private int number;
    private String userName="";

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
    /**
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * @param string
     */
    public void setName(String string) {
        name = string;
    }

    /**
     * @return
     */
    public int getNumber() {
        return number;
    }

    /**
     * @param i
     */
    public void setNumber(int i) {
        number = i;
    }

    /**
     *
     */
    public sunLoginForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */

}

//END of File sunLoginForm.java

//Start Here EJBBean.java File

package com.myapp.struts.ejb;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

/**
 *
 * @author Administrator
 */
public class EJBBean implements SessionBean{

     private SessionContext context;
    public void ejbCreate()
    {

    }
    public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
    }

    public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
    }

    public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException {
    }

     public void setSessionContext(SessionContext aContext) {
        context = aContext;
    }
    public String stringMsg()
    {
        String msg="";
        msg="This is simple program in java language !!";
        return msg;
    }
}

//END of File EJBBean.java

//Start Here EjbHome.java File
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.ejb;

import java.rmi.RemoteException;
import javax.ejb.*;

/**
 *
 * @author Administrator
 */
public interface EjbHome extends EJBHome{
    EjbRemote create() throws javax.ejb.CreateException,RemoteException;

}

//END of file EjbHome.java

//Start File EjbRemote.java From Here

 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.ejb;

import java.rmi.RemoteException;
import javax.ejb.*;

/**
 *
 * @author Administrator
 */
public interface EjbRemote extends EJBObject{
    public String stringMsg() throws RemoteException;

}

//END of File EjbRemote.java

//Start ejb-jar.xml file under WebApplication4.jar/META-INF folder

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

 <ejb-jar>
    <enterprise-beans>
    <session>
       <ejb-name>EJBBean</ejb-name>
      <home>com.myapp.struts.ejb.EjbHome</home>
      <remote>com.myapp.struts.ejb.EjbRemote</remote>
      <ejb-class>com.myapp.struts.ejb.EJBBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>
    </session>
  </enterprise-beans>


   <assembly-descriptor>

   </assembly-descriptor>

</ejb-jar>

//END of file ejb-jar.xml

//Start of file jboss.xml under WebApplication4.jar/META-INF folder

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

 <jboss>

   <enterprise-beans>

      <session>
         <ejb-name>EJBBean</ejb-name>
         <jndi-name>com/myapp/struts/ejb/Ejb</jndi-name>
      </session>

   </enterprise-beans>

   <resource-managers>
   </resource-managers>

</jboss>

//END OF file jboss.xml

//Start of file application.xml under WebApplication4.ear/META-INF folder

<?xml version="1.0" encoding="ISO-8859-1"?>

<application>
    <display-name>WebApplication4</display-name>
    <module>
    <web>
        <web-uri>WebApplication4.war</web-uri>
        <context-root>/WebApplication4</context-root>
    </web>
    </module>

    <module>
        <ejb>WebApplication4.jar</ejb>
    </module>

</application>

//End of file application.xml

View Answers

Ads









Related Tutorials/Questions & Answers:
Ejb Module
Ejb Module  Respected Sir/Mam I m using jdk1.5 and jboss4.0.2 Here...(); Object obj = ic.lookup("com/myapp/struts/ejb/Ejb... RemoteException; } //END of File EjbRemote.java //Start ejb-jar.xml file under
Ejb Module
Ejb Module  Respected Sir/Mam I m using jdk1.5 and jboss4.0.2 Here...(); Object obj = ic.lookup("com/myapp/struts/ejb/Ejb... RemoteException; } //END of File EjbRemote.java //Start ejb-jar.xml file under
Advertisements
ejb
ejb  what is ejb   ejb is entity java bean
Ejb
Ejb  what kind of web projects requires ejb framework
Ejb
Ejb  what kind of web projects requires ejb framework
Ejb
Ejb  what kind of web projects requires ejb framework
EJB
EJB  Hi, can any one please share the Document of EJB. I want to learn EJB from basic. Thanks a lot in advance
EJB
EJB  Please post screen shots of developing EJB pgms and also provide details about the files generated while we are developing applications using EJB
ejb
ejb  what is the best book to study ejb with examples in weblogic with (netbeans or eclipse)   Please visit the following link: http://www.roseindia.net/javabeans/javabeans.shtml
Version of xdoclet>xdoclet-ejb-module dependency
List of Version of xdoclet>xdoclet-ejb-module dependency
EJB - EJB
How to execute EJB(Entity bean) in desktop application   Dear Firends, I have one doubt about EJB that is "How to execute EJB(Entity bean) in desktop application using java in windows? Please reply quickly, i need very urgently
Maven Dependency xdoclet-ejb-module >> 1.2
You should include the dependency code given in this page to add Maven Dependency of xdoclet >> xdoclet-ejb-module version1.2 in your project
Maven Dependency xdoclet-ejb-module >> 1.2b1
You should include the dependency code given in this page to add Maven Dependency of xdoclet >> xdoclet-ejb-module version1.2b1 in your project
Maven Dependency xdoclet-ejb-module >> 1.2b2
You should include the dependency code given in this page to add Maven Dependency of xdoclet >> xdoclet-ejb-module version1.2b2 in your project
Maven Dependency xdoclet-ejb-module >> 1.2.3
You should include the dependency code given in this page to add Maven Dependency of xdoclet >> xdoclet-ejb-module version1.2.3 in your project
Maven Dependency xdoclet-ejb-module >> 1.2b4
You should include the dependency code given in this page to add Maven Dependency of xdoclet >> xdoclet-ejb-module version1.2b4 in your project
EJB Project
EJB Project  How to create Enterprise Application project with EJB module in Eclipse Galileo?   Please visit the following link: http://www.roseindia.net/ejb/ejbtutorial/buildingasimpleejbapplication.shtml
Types of EJB? - EJB
Types of EJB?  Explain different types of EJB and how it will be differ from one to another?  Hi friend, Read for more information. http://www.roseindia.net/ejb
EJB Environment
EJB Environment  can we work EJB in JDK1.4
Version of nanocontainer-ejb>nanocontainer-ejb dependency
List of Version of nanocontainer-ejb>nanocontainer-ejb dependency
Swing EJB
Swing EJB  Hi everyone !!! I tried to find wether EJB architecture can operate with swing, because I am trying to make application which would work... would work with EJB application server
EJB with NetBeans
EJB with NetBeans  I am very new in Ejb and with very few knowledge about it. I have download NetBeans (7.01) and GlassFish (3.01). But, as I have no idea about Ejb, I am not getting how to run the code which includes a simple
EJB Container or EJB Server
EJB Container or EJB Server       An EJB container is nothing but the program that runs on the server and implements the EJB specifications. EJB container provides special type
use of ejb 3.0
use of ejb 3.0  what is use of ejb 3.0
Coding with Ejb
Coding with Ejb  Hi Team, I am learning Ejb now. Can anybody help me how to implement this Stateful Session Bean Example by using this Hibernate example. Thanks in advance.   Sorry, actually I want simple code adding
ejb
ejb
Problem in EJB application creation - EJB
Problem in EJB application creation  Hi, I am new to EJB 3.0 technology and facing a couple of problems during the development of a simple application. 1. I would like to know how to associate an Entity bean class
EJB deployment descriptor
the brief description about the Ejb module created. <session-type>... EJB deployment descriptor       Deployment descriptor is the file which tells the EJB server that which classes make
RUNNING EJB PROGRAMS
RUNNING EJB PROGRAMS  how to run ejb programs using weblogic in windowsxp
EJB Container or EJB Server
EJB Container or EJB Server       An EJB container is nothing but the program that runs on the server and implements the EJB specifications. EJB container provides special type

Ads