Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa EJB Ejb Module

Have Programming Question? Ask it here!
 
 
 


Sunil Kumar Gahlot
Ejb Module
0 Answer(s)      a year and 11 months ago
Posted in : EJB


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

//When i run this application,ClassCastException has occurred,How to solve this problem.


Advertisement
View Answers

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
login module program
login module program  hello friends i want to develop the web service using .net pls send the login ejb module .net program to my mail id
login module program
login module program  hello friends i want to develop the web service using .net pls send the login ejb module .net program to my mail id
Admin Module
Admin Module The admin have the privilege  to add the question, delete the question. He is responsible for maintaining the site. He can also search the question paper by question Id and by title. The Admin does the following
User Module
User Module The user first need to make registration on the website for appearing in the online examination. After the making successful registration he is eligible for online test examination. To appear in the examination he need
ejb
ejb  why ejb components are invisible components.justify that ejb components are invisible
ejb
ejb  what is ejb   ejb is entity java bean
EJB
EJB  How is EJB different from servlets
EJB
EJB  what is an EJB container?   Hi Friend, Please visit the following link: EJB Container Thanks
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
spring JEE module tutorial
spring JEE module tutorial  Hi, I want spring Jee module tutorial and spring ORM module tutorial plz send me
spring DAO module turorial
spring DAO module turorial  how to integrate springDAO and spring webMVC
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
ejb - EJB
ejb  how can i run a simple ejb hello application.please give me...: http://roseindia.net/ejb/ejbtutorial/building_a_simple_ejb_application.shtml http://www.roseindia.net/ejb/ejb-hello-world.shtml Hope
EJB - EJB
EJB  i want to make a small application using EJB ,pls any one can tell me how i can deploy EJB in server ???   Hi You can start from anywhere on this site! for introduction and deployment of EJB Tutorial visit
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
EJB - EJB
EJB  i want to know coding for providing fault-tolerance for EJB componenti.e., coding in EJB for transaction process(deposit and withdraw) using JDBC connection. please send me the code as soon as possible
EJB - EJB
Learning EJB  What i need to know to start doing programming in EJB
EJB - EJB
EJB  Dear Sir , Which book is good for learning EJB . THANKS AND REGARDS, SENTHILKUMAR.P
ejb - EJB
of 3.0 version.  Hi friend, EJB : The Enterprise JavaBeans architecture or EJB for short is an architecture for the development and deployment... and budget. EJB 3.0 New Features Following are the new features of EJB
Structure of Web Module
In this section, you will learn the structure of the web module
EJB - EJB
EJB  What is the difference between EJB 2.0 and EJB 3.0? GIVE ME.../ejb/ Thanks. Amardeep  Hi friend, Difference between EJB 2.0 and EJB 3.0 EJB 2.0 It is very complex, difficult to learn/use
Module In An Application
are as follows- Customer Module Customer Registration Customer Login.... and save information Admin Module Add Update Delete Search Add Scheme on The Product Generate Report of Product Shipping Module View Shipping
EJB - EJB
://www.roseindia.net/ejb/ Thanks
EJB - EJB
to : http://www.roseindia.net/ejb/SessionBean.shtml Thanks
EJB-MDB - EJB
EJB-MDB  What are the MDB transaction attributes
java EJB - EJB
java EJB  Please, Tell me the directory structure of EJB applications and how to deploy ejb on glassfish server
what is separate request processor per module in struts1
what is separate request processor per module in struts1  what is separae request processor per module in struts1.x
what is separate request processor per module in struts1
what is separate request processor per module in struts1  what is separae request processor per module in struts1.x
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 vs hibernate - EJB
ejb vs hibernate  1>>> If we have ejb entity bean why we need hibernate? 2>>> Is hibernate distributed
EJB in jsp code - EJB
EJB in jsp code  Suppose in EJB we created the session bean, remote... can we access the EJB methods in the jsp file.... if u can present me... the following links: http://www.roseindia.net/ejb/examples-of-StatelessBean.shtml
Design patterns in ejb - EJB
on design patterns in EJB iam toally new to this concept(i.e design patterns)  Hi friend, The job of the EJB developer is constantly challenging... of design patterns, strategies, and best practices for EJB design and development
EJB communication - EJB
EJB communication  i am trying to create call a bean from another bean but it will not call. i cann't understand the dd configuration.please help me
EJB Example - EJB
EJB Example  Hi, My Question is about enterprise java beans, is EJB stateful session bean work as web service? if yes can you please explain... the following link: http://www.roseindia.net/ejb/WebServices.shtml Hope
how to call ejb with in another ejb - EJB
how to call ejb with in another ejb  Does any one have idea about ...how to call ejb with in another ejb
EJB Environment
EJB Environment  can we work EJB in JDK1.4
java - EJB
java  execution process of ejb
use of ejb - EJB
use of ejb  what is the use of ejb??  Hi friend, Some points to be remember for using ejb : * Applications developed by using.... * EJB are deployable reuseable server-side components. The components
How Spring MVC Module Works
of Spring MVC module. The Spring MVC modules comes with the Spring
Difference between EJB 2 and EJB 3 - EJB
Difference between EJB 2 and EJB 3  I know we dont implement home and remote interfaces. 1)Do we have ejb-jar.xml in EJB 3.0... in EJB lifecycle. 3) Why do we have Remote and Home interfaces in EJB 2.x
Hibernate - EJB
hibernate ejb hibernatepersistence jar  Need to know about hibernate ejb hibernatepersistence jar
tutorials - EJB
ejb tutorial for beginners free  Can anyone give me the reference of EJB tutorials for beginners
question - EJB
EJB Query language reserved words  What is the ejb query language reserved words
Advertisements
 

 

 

DMCA.com