Wrox Home  
Search P2P Archive for: Go

  Return to Index  

enterprise_java_beans thread: exception in non-transactional EJB invoke:javax.ejb.EJBException


Message #1 by "sami" <sami.s.n@l...> on Mon, 11 Dec 2000 05:47:21 -0000
 hi sachin,
thanx for ur reply
i changed that made  the home reference as a clas variable but then too  it was giving this exception
but when i went through the code carefully
i saw that instead of writing weblogic.jndi.WLInitialContextFactory i had missed out c in weblogic
any way thanxbut i was wonderig how it got compiled
thanx any way

--

On Tue, 12 Dec 2000 04:35:12  
 Sachin Gurung wrote:
>sami,
>  your client code does not initialize the home variable in your
>stateful bean. Please check that.
>
>awaiting reply..good luck
>
>
>>From: "sami" <sami.s.n@l...>
>>Reply-To: "Enterprise Java Beans" <enterprise_java_beans@p...>
>>To: "Enterprise Java Beans" <enterprise_java_beans@p...>
>>Subject: exception in non-transactional EJB invoke:javax.ejb.EJBException
>>Date: Mon, 11 Dec 2000 05:47:21 -0000
>>
>>i have succesfully created the deployable jars and its deployed also
>>but when i invoke the client
>>it gives me an pecular exception
>>i have used println statements in the client so as to know where the error
>>is
>>the session context is invoked(meth)
>>the ejbcreate is also invoked
>>but when the client after it has got the remote ref of the invokes the
>>meth in th efirst bean
>>it gives me this exception
>>exception in non-transactional EJB invoke:
>>javax.ejb.EJBException
>>at comm.stateful.YourBean.seeName(YourBean.java :39)
>>at comm.stateful.YourBeanEOImpl.seeName(YourBeanEOImpl.java:148)
>>pls help
>>this is the client code
>>import java.rmi.RemoteException;
>>import comm.stateful.*;
>>import javax.ejb.EJBException;
>>public class ClientComm{
>>String user;
>>String password;
>>String url;
>>
>>public ClientComm(String url,String user,String password) {
>>this.user=user;
>>this.url=url;
>>this.password=password;
>>
>>}
>>public ClientComm(){}
>>public static void main(String ar[]){
>>	 //home=null;
>>	System.out.println("invoking client");
>>	String user=null;
>>	String url="http://localhost:7001";
>>	String password=null;
>>	switch(ar.length){
>>	case 1:
>>	url=ar[0];
>>	case 2:
>>	user=ar[1];
>>	case 3:
>>	password=ar[2];
>>}
>>	ClientComm cc=null;
>>
>>	try{
>>		//cc=new ClientComm(url,user,password);
>>		cc=new ClientComm();
>>		System.out.println("createdd client successfull");
>>		YourHome home=cc.lookupHome();
>>		System.out.println("ref to home created");
>>		YourInterface yi=home.create();
>>		System.out.println("ref to remote got");
>>//till here i get the print statements
>>//but afterward in the below method i get the exception
>>		String s=yi.seeName("sami");
>>		System.out.println("called method");
>>		double d=yi.result(3,5);
>>	}
>>	catch(NamingException e){
>>		throw new EJBException (e);
>>	}
>>	catch(Exception e){
>>		throw new EJBException (e);
>>	}
>>	}
>>	public YourHome lookupHome() throws NamingException {
>>		Object hh=null;
>>		try{
>>			Context ctx=getInitialContext();
>>			System.out.println("got the initial context");
>>			hh=ctx.lookup("Connector");
>>			System.out.println("got the lookup");
>>			return(YourHome)javax.rmi.PortableRemoteObject.narrow(hh,YourHome.class);
>>
>>		}
>>		catch(NamingException e){
>>			throw new EJBException (e);
>>		}
>>	}
>>	public Context getInitialContext() throws NamingException{
>>		Properties p=new Properties();
>>		p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
>>
>>
>>			p.put(Context.PROVIDER_URL,url);
>>			if(user!=null){
>>				p.put(Context.SECURITY_PRINCIPAL,user);
>>				if(password ==null)
>>				password="";
>>				p.put(Context.SECURITY_CREDENTIALS,password);
>>			}return new InitialContext(p);
>>
>>		}
>>}
>>--
>>Stateful bean
>>package comm.stateful;
>>import javax.naming.*;
>>import java.util.Properties;
>>import javax.ejb.*;
>>import java.rmi.RemoteException;
>>import javax.rmi.PortableRemoteObject;
>>import comm.stateless.*;
>>public class YourBean implements SessionBean{
>>String url;
>>String user;
>>String password;
>>
>>comm.stateless.MyInterface home;
>>public void ejbCreate(){
>>log(":ejbCreate");
>>
>>}
>>public void ejbRemove(){
>>log("ejbremove");
>>}
>>public void ejbActivate(){
>>	log("ejbactivate");
>>}
>>public void ejbPassivate(){
>>	log("ejbpassivate");
>>}
>>public void setSessionContext(SessionContext ctx){
>>log("sessioncontext");
>>}
>>public String seeName(String name){
>>
>>	try{
>>		System.out.println("getting the lookup");
>>		home=lookupHome();
>>		System.out.println("got the lookup");
>>	String name1=home.setName(name);
>>
>>	System.out.println("the name set is "+name1);
>>return name1;
>>	}
>>	catch(Exception e){
>>		throw new EJBException (e);
>>	}
>>}
>>public double result(double a,double b) {
>>	try{
>>double num=home.addNumbers(a,b);
>>System.out.println("the numbers result is "+num);
>>return num;
>>}
>>catch(Exception e){
>>		throw new EJBException (e);
>>	}
>>}
>>
>>public Context getInitialContext() throws NamingException{
>>	Properties p = new Properties();
>>	p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogi.jndi.WLInitialContextFactory");
>>
>>	return new InitialContext(p);
>>
>>}
>>public MyInterface lookupHome() throws NamingException{
>>	Object h1=null;
>>	try{
>>		Context ctx=getInitialContext();
>>		h1=ctx.lookup("Reciever");
>>	comm.stateless.MyHome
>>mih	=(comm.stateless.MyHome)javax.rmi.PortableRemoteObject.narrow(h1,comm.stateless.MyHome.class);
>>
>>	return mih.create();
>>
>>	}
>>	catch(Exception e){
>>		throw new EJBException (e);
>>		}
>>	}
>>	private void log(String s){
>>		System.out.println(s);
>>}
>>}
>>
>>package comm.stateful;
>>import javax.ejb.CreateException;
>>import javax.ejb.EJBHome;
>>import java.rmi.RemoteException;
>>
>>public interface YourHome extends EJBHome{
>>
>>public YourInterface create() throws CreateException ,RemoteException;
>>}
>>
>>
>>package comm.stateful;
>>import java.rmi.RemoteException;
>>import javax.ejb.EJBObject;
>>
>>public interface YourInterface extends EJBObject{
>>
>>public String seeName(String name) throws RemoteException;
>>public double result(double a,double b) throws RemoteException;
>>
>>}
>>
>><?xml version="1.0"?>
>>
>><!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>
>>     <enterprise-beans>
>>       <session>
>>	<ejb-name>one</ejb-name>
>>	<home>comm.stateful.YourHome</home>
>>	<remote>comm.stateful.YourInterface</remote>
>>	<ejb-class>comm.stateful.YourBean</ejb-class>
>>	<session-type>Stateful</session-type>
>>	<transaction-type>Container</transaction-type>
>>	<ejb-ref>
>>	<ejb-ref-name>ejb/Reciever</ejb-ref-name>
>>		<ejb-ref-type>Session</ejb-ref-type>
>>		<home>comm.stateless.MyHome</home>
>>		<remote>comm.stateless.MyInterface</remote>
>>	</ejb-ref>
>>	</session>
>>
>>     </enterprise-beans>
>>     <assembly-descriptor>
>>       <container-transaction>
>>	<method>
>>	  <ejb-name>one</ejb-name>
>>	  <method-intf>Remote</method-intf>
>>	  <method-name>*</method-name>
>>	</method>
>>	<trans-attribute>Required</trans-attribute>
>>       </container-transaction>
>>     </assembly-descriptor>
>>   </ejb-jar>
>>
>><?xml version="1.0"?>
>>
>><!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 
>>EJB//EN' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>
>>
>><weblogic-ejb-jar>
>>     <weblogic-enterprise-bean>
>>       <ejb-name>one</ejb-name>
>>       <caching-descriptor>
>>	<max-beans-in-cache>100</max-beans-in-cache>
>>       </caching-descriptor>
>>       <reference-descriptor>
>>             <ejb-reference-description>
>>             <ejb-ref-name>ejb/Reciever</ejb-ref-name>
>>             <jndi-name>Reciever</jndi-name>
>>             </ejb-reference-description>
>>       </reference-descriptor>
>>       <jndi-name>Connector</jndi-name>
>>
>>     </weblogic-enterprise-bean>
>>
>>   </weblogic-ejb-jar>
>>
>>

--- 
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development, 
Web Development, Networking & Communications, and Hardware & Systems.  
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to enterprise_java_beans as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-enterprise_java_beans-$subst('Recip.MemberIDChar')@p2p.wrox.com

  Return to Index