Results 1 to 3 of 3
Thread: ClassCastException: in EJB3
- 06-25-2009, 01:16 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 14
- Rep Power
- 0
ClassCastException: in EJB3
Hi,
i am using EJB3 with Jboss5 ,while runnung the application i am getting following exception in line
FirstBean r=(FirstBean)c.lookup("FirstBean/remote");
Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference
Following is the client code:
public static void call(){
Properties properties = new Properties();
properties.put("java.naming.factory.initial","org. jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs","=or g.jboss.naming:org.jnp.interfaces");
properties.put("java.naming.provider.url","localho st:1099");
Context c=null;
try {
Properties prop = new Properties();
prop.setProperty("java.naming.factory.initial","or g.jnp.interfaces.NamingContextFactory");
prop.setProperty("java.naming.provider.url","jnp://localhost:1099");
prop.setProperty("java.naming.factory.url.pkgs","o rg.jboss.naming:org.jnp.interfaces");
c=new InitialContext(prop);
FirstBean r=(FirstBean)c.lookup("FirstBean/remote");
r.display();
System.out.print("found.................");
} catch (NamingException e)
{
e.getMessage());
e.printStackTrace();
}
}
}
Implementation class is
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.swing.JOptionPane;
@Stateless
@Remote(IFFirstBean.class)
public class FirstBean implements IFFirstBean {
public void display()
{
System.out.print("done............................ .....");
}
}
Remote Interface is :
import java.io.Serializable;
import javax.ejb.Remote;
@Remote
public interface IFFirstBean extends Serializable{
public void display();
}
I am new in EJB3 , can any one help me out in resolving the issue?
Thanks ,
Nida
- 06-25-2009, 02:51 PM #2
lookup() returns a Reference, which you can't cast to a FirstBean
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 07-03-2009, 03:03 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
ClassCastException
By paulsim in forum Java AppletsReplies: 2Last Post: 08-21-2008, 02:14 PM -
java.lang.ClassCastException
By wrwelden in forum New To JavaReplies: 4Last Post: 05-22-2008, 03:43 PM -
ClassCastException in TreeSet
By pHew in forum New To JavaReplies: 2Last Post: 01-16-2008, 12:20 AM -
ClassCastException
By Ed in forum New To JavaReplies: 2Last Post: 07-04-2007, 05:26 AM -
ClassCastException
By Felissa in forum New To JavaReplies: 2Last Post: 07-04-2007, 05:06 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks