aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes very strange error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "very strange error" Watch "very strange error" New topic
Author

very strange error

Pardha
Greenhorn

Joined: May 13, 2001
Posts: 15

Hi I am new to EJB and trying to execute my first application
but I am getting the following error please help me in finding out the solution
---------------
java.lang.ClassCastException
at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at HelloClient.main(HelloClient.java:16)
---------------------------------------
Here I am pasting my Java Code
** Home Object **
import javax.ejb.*;
import java.rmi.RemoteException;
public interface HelloHome extends EJBHome
{
Hello create() throws RemoteException,CreateException;
}
==================================
** Remote Interface **
import javax.ejb.*;
import java.rmi.RemoteException;
import java.rmi.Remote;
public interface Hello extends EJBObject
{
public String hello() throws java.rmi.RemoteException;
}
========================
** My Bean **
import javax.ejb.*;
public class HelloBean implements SessionBean
{
public void ejbCreate()
{
System.out.println("ejbCreated()");
}
public void ejbRemove()
{
System.out.println("ejbRemove()");
}
public void ejbActivate()
{
System.out.println("ejbActivate()");
}
public void ejbPassivate()
{
System.out.println("ejbPassivate()");
}
public void setSessionContext(SessionContext ctx)
{
System.out.println("setSessionContext()");
}
// Business methods
public String hello()
{
System.out.println("Hello()");
return "Hello World!";
}
}
===========================
** Client ******
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
import java.util.Properties;
//import javax.rmi.PortableRemoteObect;
public class HelloClient
{
public static void main(String[] args)
{
try
{
Properties props=System.getProperties();
Context ctx=new InitialContext(props);
Object obj = ctx.lookup("HelloBean");
HelloHome home= (HelloHome) PortableRemoteObject.narrow(obj, HelloHome.class);
Hello hello=home.create();
System.out.println(hello.hello());
hello.remove();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
=====================================
Please Help I have been stuck here since 8 days not finding any solution.
Thanking you in advance
Saradhi

------------------
Intelligent Hard work never goes waste


Intelligent Hard work never goes waste
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
I recommend to follow the tutorial provided by Sun at J2EE It gives step by step procedure, how to build and deploy EJB's on J2EE RI.

Originally posted by saradhi74:

Hi I am new to EJB and trying to execute my first application
but I am getting the following error please help me in finding out the solution
---------------
java.lang.ClassCastException
at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at HelloClient.main(HelloClient.java:16)


------------------
Sreenivasa Kumar Majji
Sun Certified Java Programmer
SCJP Mock Test


Sreenivasa Majji
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1836
saradhi74

The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
------------------

Mahindrakar
IBM Application Server Forum Moderator

Consultant - Zensar Technologies ,Pune India.
SCJP2, SCJD2 & SCJEA (Part I)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: very strange error
 
Similar Threads
Getting a SocketOrChannelConnectionImpl in Weblogic
problem in running client code
problem in EJB client.
headfirst code not working
how to deploy ejb on sun application