p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

Go Back   p2p.wrox.com Forums > Java > Java and JDK > J2EE
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 27th, 2003, 12:34 AM
Authorized User
Points: 41, Level: 1
Points: 41, Level: 1 Points: 41, Level: 1 Points: 41, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem Deploying EJBs to Weblogic Server

Dear All,
 i m new to EJBs. Actually i have developed my own web-container(Servlet engine),and now i want to switch to EJBs. But i have problem deploying EJBs on Weblogic server. if anyone can help me, please mail me a deployed version of EJB with clear instructions about how to deploy this Bean and how to run client. I'll be thankful to you. My e-mail address is: malik_maltaf@hotmail.com

I am using: weblogic server 5.10
Win XP professional
jdk 1.3

Thank you.
Altaf Malik
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old November 26th, 2003, 05:18 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Altaf Malik

Find the code attached herewith which would help u to run a simple stateless session bean in weblogic server 6.0. Get back to me if u find any difficulties on this

1. Create following files.

    Demo -> Remote Interface

    DemoHome -> Home Interface

    DemoEJb -> Bean

    In a separate pakcage. Move all the files to application/ejb directory.


    package demoejb;

    import java.rmi.RemoteException;
    import java.rmi.Remote;
    import javax.ejb.*;
    public interface Demo extends EJBObject, Remote {
        public String demoSelect() throws RemoteException;
    }

    // Home interface

    package demoejb;

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

    public interface DemoHome extends EJBHome {
        public Demo create() throws CreateException, RemoteException;
    }

    // Bean

    package demoejb;
    import javax.ejb.*;
    import java.io.Serializable;
    import java.util.*;
    import java.rmi.*;

    public class DemoBean implements SessionBean {
      static final boolean verbose = true;
      private SessionContext ctx = null;
      public void ejbActivate() {}
      public void ejbRemove() {}
      public void ejbPassivate() {}
      public void setSessionContext(SessionContext ctx) {
        this.ctx = ctx;
      }
      public void ejbCreate () {}
      public String demoSelect()  throws RemoteException{
        return("hello world");
        }
    }

Create Ejb-jar and Weblogic-ejb-jar.xml files and move the files to application\ejb\META-INF dir.

    ***Ejb-jar.

    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'  'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

    <ejb-jar>

    </ejb-jar>

    ***Weblogic-ejb-jar.xml

    <weblogic-ejb-jar>

    </weblogic-ejb-jar>


1. Open the server console.

2. Open Application/ejb node

3. Edit Ejb Descriptor

    Click : Configure a new Enterprise Bean

        EJBName : DemoEjb

        JNDI Name : demoejb.DemoHome

    Click : EnterPriseBean/Session/ Configure a new Session.

        EJBName : DemoEjb

        Home  : demoejb.DemoHome

        Remote : demoejb.Demo

        Ejb Class: demoejb.DemoBean

        Session Type : Stateful

        Transcation : Container.

4. Validate and Persist the bean ( Which will update ejb-jar and weblogic-ejb-jar xml files. )



Create a new JSP to invoke ejb method.

    <%@ page import="demoejb.*"%>
    <%@ page import="javax.ejb.*"%>
    <%
    Demo ob = (Demo) ((DemoHome)  EJBHomeFactory.getFactory().lookUpHome(DemoHome.c lass)).create();
    String str = ob.demoSelect();
    out.println(str);
%>

5. Save and run the jsp.

    EJBHomeFactory ( Reusable Class).

    package demoejb;
    import javax.ejb.*;
    import java.rmi.*;
    import java.util.*;
    import javax.naming.*;
    public class EJBHomeFactory {
        private Map    ejbHomes;
        private static EJBHomeFactory aFactorySingleton;
        Context    ctx;
        private EJBHomeFactory()  throws NamingException {
        String  strUrl = "t3://localhost:7001";
            Properties objProp = new Properties();
            objProp.put(Context.INITIAL_CONTEXT_FACTORY,    "weblogic.jndi.WLInitialContextFactory");
            objProp.put(Context.PROVIDER_URL, strUrl);
            ctx = new InitialContext(objProp);
            this.ejbHomes = Collections.synchronizedMap(new HashMap());
            }
        public static EJBHomeFactory getFactory()throws NamingException {

            if (EJBHomeFactory.aFactorySingleton == null) {
                    EJBHomeFactory.aFactorySingleton = new EJBHomeFactory();
            }
            return EJBHomeFactory.aFactorySingleton;
            }
        public EJBHome lookUpHome(Class homeClass)  throws NamingException {

            EJBHome anEJBHome = (EJBHome) this.ejbHomes.get(homeClass);
            if (anEJBHome == null) {
                anEJBHome = (EJBHome)  javax.rmi.PortableRemoteObject.narrow(ctx.lookup( homeClass.getName()),
                    homeClass);
                this.ejbHomes.put(homeClass, anEJBHome);
            }
        return anEJBHome;
            }
    }

Application Directory Structure.

ApplicationName
    Deploy
        ejb
            META-INF (ejb-jar and weblogic-ejb-jar)
        web
            jsp
            WEB-INF
                classes (web.xml and weblogic.xml)
        META-INF (Application.xml)

Rgds
Prasanna
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old December 2nd, 2003, 12:44 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: Kolkata, WB, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Abhijitsaha2000 Send a message via Yahoo to Abhijitsaha2000
Default

Hi,

Thanks a lot.

I am using WebLogic 6.1 in development mode and have my EJB/Servlet/JavaBean classes & all others in exploded format in the weblogic mydomain/applications folder. But when I try to deploy the EJBs, I get Deployment Exception. I have done everything as per Weblogic 6.1 doc.

Please inform me about possible ways, if anybody have deployed EJBs in exploded format in WebLogic 6.1.

Regards,
Abhijit

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old March 16th, 2004, 04:00 AM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
In weblogic 5.1 you will find a weblogic.properties file in home directory. There you register your ejb and then again start the server. First try out some in built examples by uncommenting relevent lines in properties file. If it does not work out let me know. I will tell you tell step by step
Cheers
Arvind

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old March 16th, 2004, 04:02 AM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
In weblogic 5.1 you will find a weblogic.properties file in home directory. There you register your ejb and then again start the server. First try out some in built examples by uncommenting relevant lines in properties file. If it does not work out let me know. I will tell you tell step by step
Cheers
Arvind

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old May 21st, 2004, 01:29 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: kollam, kerala, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ferozklm Send a message via Yahoo to ferozklm
Default

I am using weblogic 8.1 the same sample program in exploded archive.please give me a sample code for application.xml

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old June 27th, 2005, 09:14 PM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

 I am new to EJBs. Can someone tell me the significance of application.xml file while developing EJB application on Weblogic server.

thanks,
Nivas

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
deploying war file in weblogic vivekkumar_23 J2EE 0 January 9th, 2007 12:08 AM
Problem in deploying EAR on application server v6. mohib.raza BOOK: Professional IBM WebSphere 5.0 Application Server 0 November 29th, 2006 03:11 AM
deploying wroxapp in weblogic server veenaV BOOK: Professional Jakarta Struts 0 September 21st, 2006 12:53 AM
steps for deploing ejbs in weblogic 8.1 satishsat J2EE 0 October 18th, 2004 02:15 PM
J2ee with weblogic server wlsbook_code.zip - help kannanks J2EE 1 July 15th, 2004 11:25 AM



All times are GMT -4. The time now is 12:29 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc