on 11-22-2005 4:26 PM
Hello,
I try to get an standalone remote client to to connect to my stateless session bean:
java.util.Properties props = new java.util.Properties();
props.put("java.naming.provider.url", "181.205.12.19:50004");
props.put("java.naming.factory.initial", "com.sap.engine.services.jndi.InitialContextFactoryImpl" );
props.put("java.naming.security.authentication", "simple");
props.put("java.naming.security.principal", "j2ee_admin");
props.put("java.naming.security.credentials", "*****");
jndiContext = new InitialContext(props);
fetching of jndi context is fine, but once I try to lookup my home interface I get a class cast exception:
home = (ToEdifactConverterHome) PortableRemoteObject.narrow(jndiContext.lookup ("sap.com/EdifactEar/ToEdifactConverterBean"), ToEdifactConverterHome.class);
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at test.cceag.transform.TransformTester.setUp(TransformTester.java:74)
at test.cceag.transform.TransformTester.main(TransformTester.java:48)
The jndi lookup seems to return the bean implementation object, but not the home interface itself.
Thanks for any hints
Matthias
The exaception thrown to indicate that your code has attempted to cast an object to a subclass of which it is not an instance. This means that ClassCastException occurs when you try to cast an instance of an Object to a type that it is not. Type Casting only works when the casted object follows an is a relationship to the type you are trying to cast to.
It is good practice to guard any explicit casts with an instanceof check first:
if (myApple instanceof Fruit) {
Fruit myFruit = (Fruit)myApple;
}
When will be ClassCastException is thrown:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Matthias,
i think the guide
"How to...EJB: Accessing EJB Applications Using JNDI"
will help you to solve the ejb lookup problem:
good luck, Katharina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you are using a local lookup, It would help to put a reference (of the bean you are trying to lookup) in the application-j2ee-engine.xml file.
Regards,
Guru
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Matthias,
Try with following code for look up:
home = (ToEdifactConverterHome) jndiContext.lookup ("sap.com/EdifactEar/ToEdifactConverterBean");
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.