 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

June 27th, 2003, 12:34 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

November 26th, 2003, 06:18 AM
|
Registered User
|
|
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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. class)).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
|

December 2nd, 2003, 01:44 AM
|
Registered User
|
|
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

March 16th, 2004, 05:00 AM
|
Registered User
|
|
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

March 16th, 2004, 05:02 AM
|
Registered User
|
|
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 21st, 2004, 01:29 AM
|
Registered User
|
|
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am using weblogic 8.1 the same sample program in exploded archive.please give me a sample code for application.xml
|

June 27th, 2005, 09:14 PM
|
Registered User
|
|
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |