facebook

Adding EJB Project/Module to A Web Project

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #246425 Reply

    saloni.priya
    Member

    Hi there,

    We have A Web Project(Implemented using MyEclipse).But as per the requirements we need to use EJB’s(Stateless Session Beans) in our project.How can we develop and use EJBs without distrubing the Structure of the Web Project??Which is the best way to Implement??
    Any advice is highly appreciated.

    Thanks In Advance

    Priya Saloni

    #246439

    saloni.priya
    Member

    I created an EJB Project using MyEclipse by referencing this Document “MyEclipse_EJB_Project_Quickstart.pdf” and created a “firstejb.jar” with MyEclipse’s MyEclipse–>Add and Remove Project Deployments.I kept “firstejb.jar” In my WebProject’s Build Path and trying to Access the EJB using the following Code

    
        public void buy() throws Exception{
            
            Context ictx = new InitialContext();
            Object objref = (Context)ictx.lookup("ejb/Trader");
            TraderHome traderHome = (TraderHome)PortableRemoteObject.narrow(objref,TraderHome.class);
            Trader trader = traderHome.create();
            trader.buy("XYZ",10);
    
        } 
    

    After the above code i deployed the Webapplication in Websphere 5.1.1 as a .war file and called the above method from my Action .But the EJB is getting called.Am i doing any thing Wrong???Please correct me if iam wrong.

    #246444

    Riyad Kalla
    Member

    Priya,
    When working with both Web and EJB projects, you need to create a top-level Enterprise Application Project and add them as modules to it. Then deploy the EAR to your J2EE application server. This is covered in this document here: http://www.myeclipseide.com/images/tutorials/quickstarts/earprojects/

    #246455

    saloni.priya
    Member

    Thanks For the response Riyad,

    But the Problem is We have to create a New top-level Enterprise Application Project and move the all the files from existing Web project(Which is stable and is in Production) into the New Enterprise Application Project.We don’t want to do that.instead we want to deploy the EJB and Web Projects separately and access the EJBs from Web Project…Please let me is it really possible to have 2 projects separately or is it mandatory to create New top-level Enterprise Application??Please advice us.

    Priya

    #246459

    Riyad Kalla
    Member

    But the Problem is We have to create a New top-level Enterprise Application Project and move the all the files from existing Web project(Which is stable and is in Production) into the New Enterprise Application Project

    No you don’t, please read the document I linked for you. The web project and ejb project become “modules” of the Enterprise Project, they are packaged and deployed with it.

    #246460

    saloni.priya
    Member

    Thanks I’ll go through it again.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Adding EJB Project/Module to A Web Project

You must be logged in to post in the forum log in