Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PortableRemoteObject.narrow() throws ClassCastException

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have deployed my sample EJB on standalone oc4j.jar using JDeveloper.
I have also successfully tested my EJB application through JDeveloper by
connecting to standalone oc4j.jar.
Now I want to invoke the EJB from a servlet.
I have written the code in the servlet as follows.
Hashtable oEnv = new Hashtable(); // Max needed + 1
oEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.ApplicationCli
entInitialContextFactory");
oEnv.put(Context.SECURITY_PRINCIPAL, "admin");
oEnv.put(Context.SECURITY_CREDENTIALS, "admin");
oEnv.put(Context.PROVIDER_URL, "ormi://Sanjeev/myejb");
System.out.println("Setting initial context");
InitialContext ic = new InitialContext(oEnv);
System.out.println("looking up");
Object homeObject = ic.lookup("java:comp/env/MyEJBBean");
System.out.println("Look up successful=");
home =
(MyEJBHome)PortableRemoteObject.narrow(homeObject,MyEJBHome.class);
System.out.println("Got home");
It is able to perform look up, but at the time of type casting, I am thrown
exception
java.lang.ClassCastException : MyEJBHome_StatelessSessionHomeWrapper1
The orion-ejb-jar.jar which is generated by the Container by itself has the
following code.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1
runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
<orion-ejb-jar deployment-version="9.0.3.0.0" deployment-time="f7f191a26c">
<enterprise-beans>
<session-deployment name="MyEJBBean" location="MyEJBBean"
wrapper="MyEJBHome_StatelessSessionHomeWrapper1"
persistence-filename="MyEJBBean" />
</enterprise-beans>
<assembly-descriptor>
<default-method-access>
<security-role-mapping name="<default-ejb-caller-role>"
impliesAll="true" />
</default-method-access>
</assembly-descriptor>
</orion-ejb-jar>
.
I want to know what kind of error is this and what is
MyEJBHome_StatelessSessionHomeWrapper1?
For your information, I have deployed EJB using EAR file (that contains the
ejb jar file only and not the war file) on standalone oc4j.jar and I have
placed the servlet in default-web-app directory under WEB-INF/classes.
anshul.sehgal@nucleussoftware.com,
sanjeev.saxena@nucleussoftware.com
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hope all your classes are of the same version.
 
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic