Hello, 

I really hope someone can help me.
I have been reading trough a lot of faqs and forums but it 
simply seams that I am not able to solve this newbie problem.
I am newbie using EJB3 (and EJB in general).
I installed JBOSS 4.0.4GAPatch1 on my windows xp sp2 machine.
I am trying to deploy a Stateless session bean; a typical HelloWorldBean.
Following information:

jmx-console show
+- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  +- HelloWorldBean (class: org.jnp.interfaces.NamingContext)
  |   +- local (proxy: $Proxy60 implements interface 
ejb.HelloWorldLocal,interface org.jboss.ejb3.JBossProxy,interface 
javax.ejb.EJBLocalObject)
  |   +- remote (proxy: $Proxy59 implements interface 
ejb.HelloWorldRemote,interface org.jboss.ejb3.JBossProxy,interface 
javax.ejb.EJBObject)
  
My HelloWorldBean

public class HelloWorldBean implements ejb.HelloWorldRemote, 
ejb.HelloWorldLocal{
    
    /** Creates a new instance of HelloWorldBean */
    public HelloWorldBean() {
    }
    
    public String getHelloWorld() {
        return "Hello World!";
    }
    
}


My java client

public class Main {

        /** Creates a new instance of Main */
        public Main() {

        }

        public static void main(String[] args) {

                Context context = null;
                
                try {
                        context = getInitialContext();
                } catch (NamingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                String myBean = "HelloWorldBean";
                Object hello = null;
                try {
                        hello = context.lookup(myBean);
                } catch (NamingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                System.out.println(myBean + " is bound to " + hello);
                Class[] c = hello.getClass().getInterfaces();
                for (int i=0;i<c.length;i++){
                        System.out.println(c.getName());
                }
                
                
                HelloWorldRemote helloSession = null;
                
                try {
                        helloSession = 
(HelloWorldRemote)PortableRemoteObject.narrow(hello, HelloWorldRemote.class);   
 
                } catch (ClassCastException e) {
                        e.printStackTrace();
                }
                
        }
        
        public static Context getInitialContext()
                        throws javax.naming.NamingException {
                        Properties p = new Properties();
                        
p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
                        
p.put("java.naming.provider.url","jnp://localhost:1099");
                        
p.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
                        return new InitialContext(p);
                }
}


The error output

HelloWorldBean is bound to [EMAIL PROTECTED]
javax.naming.Context
java.io.Serializable
java.lang.ClassCastException
        at 
com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
        at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
        at Main.main(Main.java:62)
Caused by: java.lang.ClassCastException: org.jnp.interfaces.NamingContext
        at 
com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
        ... 2 more

I do not use any jboss.xml or other xml descriptors. I hope that is ok, as i 
can lookup the bean at least; Please correct me if I am wrong.

So as far as I can see, I can lookup the context; but I have no idea why it 
fails then.

Any ideas.
thanks
walter.



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

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


_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to