Hello all,

I am getting start to EJB 3.0 with a HelloWorld, but I got the following 
exception:
java.lang.ClassCastException: org.jnp.interfaces.NamingContext

I am using NetBeans 5.5 Preview, JBoss 4.0.4.CR2 with EJB3.

Here is my HelloWorldBean:


  | package hi;
  | 
  | import javax.ejb.Stateless;
  | 
  | @Stateless(name="HelloWorld")
  | public class HelloWorldBean implements HelloWorldRemote {
  |       public String sayHi (){
  |             return "Hello world!";
  |         }
  | }
  | 

Here is my HelloWorldRemote:


  | package hi;
  | 
  | import javax.ejb.Remote;
  | 
  | @Remote
  | public interface HelloWorldRemote {
  |     public String sayHi ();
  | }
  | 

And then I get the Remote by this:


  | Properties props = new Properties();
  | props.setProperty("java.naming.factory.initial", 
"org.jnp.interfaces.NamingContextFactory");
  | props.setProperty("java.naming.provider.url", new 
String("jnp://localhost:1099"));
  | props.setProperty("java.naming.factory.url.pkgs", 
"org.jboss.naming:org.jnp.interfaces");
  | InitialContext context = new InitialContext(props);
  | hello = (HelloWorldRemote) context.lookup("HelloWorld");
  | 

I got the exception when i cast the object to HelloWorldRemote after lookup.

What is the problem with my code? How should I get the Remote correctly?

Please help. Thanks!!

Regards,
Candy

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3936835#3936835

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3936835


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to