I deployed interest.ear sample in jboss-3.0.0RC1_tomcat-4.0.3 and successfully run the InterestClient.java. When I tried to run InterestServletClient.java, it got the object reference but failed on cast it to a InterestHome object. What went wrong?

public class InterestServletClient extends HttpServlet
{
    public void init() throws javax.servlet.ServletException
    {
        super.init();

        Object ref  = null;
        try
        {

            InitialContext jndiContext = new InitialContext();
            System.out.println("Got context");
            ref  = jndiContext.lookup("ejb/Interest");
            System.out.println("Got reference");
            InterestHome home = (InterestHome) PortableRemoteObject.narrow (ref, InterestHome.class);
            System.out.println("Got InterestHome object.");
            // Create an Interest object from the Home interface
            Interest interest = home.create();
            System.out.println("Interest on 1000 units, at 10% per period, " +
                "compounded over 2 periods is:");
            System.out.println(new Double(interest.calculateCompoundInterest (1000, 0.10, 2)).toString());
        }
        catch(Exception e)
        {
            System.err.println("Error:" + e.toString());

            System.out.println("Remove Object type is " + ref.getClass().getName());
        }

    }

}

The output :

Got context

Got reference

Error: java.lang.ClassCastException

Remove Object type is $Proxy2



Sign up to watch the FIFA World Cup video highlights from your desk!

http://fifaworldcup.yahoo.com/fc/en

Reply via email to