Results 1 to 3 of 3
  1. #1
    nida is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default 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

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    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

  3. #3
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default http://www.questionpapers.net

    your doubt's will be solved just logon questionpapers.net

Similar Threads

  1. ClassCastException
    By paulsim in forum Java Applets
    Replies: 2
    Last Post: 08-21-2008, 03:14 PM
  2. java.lang.ClassCastException
    By wrwelden in forum New To Java
    Replies: 4
    Last Post: 05-22-2008, 04:43 PM
  3. ClassCastException in TreeSet
    By pHew in forum New To Java
    Replies: 2
    Last Post: 01-16-2008, 01:20 AM
  4. ClassCastException
    By Ed in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 06:26 AM
  5. ClassCastException
    By Felissa in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 06:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •