[jboss-user] [JNDI/Naming/Network] - ClassCastException on PortableRemoteObject.narrow(object, He

lavkul do-not-reply at jboss.com
Wed Oct 24 04:43:13 EDT 2007


  posted Sunday, October 21, 2007 11:47 PM                      
--------------------------------------------------------------------------------
I have created an EJB module and a web module.
When I try to run EJB from a servlet I get ClassCastException. I do not know why?

I am using myEclipse 6.0 and JBoss 4.2.1 GA application server.

I get ClassCastException When I try to narrow after lookup.

I have seen many sites but i could not resolve this problem.

Can some one help on this?

Please find below the code details.

jboss.xml
-----------------------------------------------

<enterprise-beans>

<ejb-name>Hello</ejb-name>
<jndi-name>ejb/Hello</jndi-name>


<ejb-name>TesterBean</ejb-name>
<jndi-name>test/Tester</jndi-name>
 

</enterprise-beans>



ejb-jar.xml
-----------------------------------------------
<enterprise-beans>

<ejb-name>Hello</ejb-name>
com.wiley.examples.HelloHome
com.wiley.examples.Hello
<ejb-class>com.wiley.examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>



<display-name>TesterBean</display-name>
<ejb-name>TesterBean</ejb-name>
com.wiley.examples.TesterHome
com.wiley.examples.Tester
<ejb-class>com.wiley.examples.TesterEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>


jboss-web.xml
-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
<ejb-ref>
<ejb-ref-name>ejb/HelloEjb</ejb-ref-name>
<jndi-name>ejb/Hello</jndi-name>
</ejb-ref>
</jboss-web>


web.xml
-----------------------------------------------------
<ejb-ref>
<ejb-ref-name>ejb/HelloEjb</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
com.wiley.examples.HelloHome
com.wiley.examples.Hello
<ejb-link>Hello</ejb-link>
</ejb-ref>


code from servlet 
---------------------------------------------------
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming  rg.jnp.interfaces");
env.put("org.omg.CORBA.ORBInitialHost","localhost");
env.put("org.omg.CORBA.ORBInitialPort","3700");

Context context = new InitialContext();
Object object = context.lookup("java:comp/env/ejb/HelloEjb");
System.out.println(object);
HelloHome helloHome = null; 
if (object != null) {
// PortableRemoteObject.narrow(object, HelloHome.class);
helloHome = (HelloHome)PortableRemoteObject.narrow(object, HelloHome.class);

Hello hello = helloHome.create();
System.out.println(hello.hello());
}

I am able to compile entire code but When i excute EJB's I get ClassCastException on PortableRemoteObject.narrow(object, HelloHome.class);

Please help.  

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

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



More information about the jboss-user mailing list