aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Too many exceptions for first EJB Client App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Too many exceptions for first EJB Client App " Watch "Too many exceptions for first EJB Client App " New topic
Author

Too many exceptions for first EJB Client App

Sandip Shinde
Greenhorn

Joined: Apr 28, 2005
Posts: 6
Using Sun RI server

While accessing EJB component got different errors for diffrent code combinations

//
Context con = new InitialContext();
Object objTatto = con.lookup("Tatto");
TattoHome tattoHome = (TattoHome) PortableRemoteObject.narrow(objTatto, TattoHome.class);
//

for above code I got --->
javax.naming.NoInitialContextException: Need to specify class name in environment or system property


//
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:4848");
Context con = new InitialContext(env);
Object objTatto = con.lookup("Tatto");
TattoHome tattoHome = (TattoHome) PortableRemoteObject.narrow(objTatto, TattoHome.class);
//

for above code I got-->
javax.naming.CommunicationException: Cannot connect to ORB. Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed:

though RI is displaying bean as deployed

what is wrong exactly ....
[ April 29, 2005: Message edited by: Sandip Shinde ]
Sandip Shinde
Greenhorn

Joined: Apr 28, 2005
Posts: 6
Finally I am able to get reference of EJBHome by lookup
for that I made changes in code (as described solution to other thread in this message board)

//
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");env.put(Context.PROVIDER_URL,"iiop://localhost:3700");

Context con = new InitialContext(env);
//

Now there is ClassCastException

when I try to narrow HomeObject
TattoHome tattoHome = (TattoHome) PortableRemoteObject.narrow(objTatto, TattoHome.class);

I am using eclipse to run client(standalone java app), and client project setting is including path to Client.jar generated by Sun RI server.

why ClassCastException is there

??
please help
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Sandip,

Can you please post the error stack trace?
However at a glance I suspect that something might be wrong here:

Can you please check whether you�re looking up the home interface? I�m afraid that you actually look up the bean here and not the home interface. Probably your code should look like this:

Again a full stack trace might help little bit.
Regards.


I think, therefore I exist -- Rene Descartes
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
in the properties for your initial context you need to set the following:

java.naming.factory.initial
java.naming.factory.url.pkgs
java.naming.provider.url
(and for some vendors, they also require a few others including security settings like Principal)

for JBoss (as an example) the above would be:

[ May 12, 2005: Message edited by: Robert Paris ]
Sandip Shinde
Greenhorn

Joined: Apr 28, 2005
Posts: 6
Hi Valentin,

here is stacktrace

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 com.end.TattoClient.main(TattoClient.java:50)

Actually I am able to get refernce of HomeObject , exception is coming for the line on which I am trying to cast it using narrow method.

Bean deployed "Tatto" as JNDI Name , so am looking for Tatto.

when I kept watch on the returned object(returned by lookup) it is something like -->
com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1:IOR:0000000000000029524d493a636f6d2e73746172742e546174746f486f6d653a3030303030303030303030303030303000000000000000010000000000000198000102000000000f3139322e3136382e3130322e313100000e74000000000056afabcb00000000260000003f00000009533141532d4f5242000000000000000200000008526f6f74504f41000000001237333035303637323334333032333631360000000000000d010387330f9c000000000001ff0a00000000000700000001000000200000000000010001000000020501000100010020000101090000 000100010100000000260000000200020000000000030000001a000000000000000f3139322e3136382e3130322e313100000eec0000000000030000001a000000000000000f3139322e3136382e3130322e313100000f5000000000001f0000000400000003000000200000000400000001000000210000008000000000000000010000000000000024000000220000006600000000000000010000000f3139322e3136382e3130322e313100000eec004000000000000000080606678102010101000000170401000806066781020101010000000764656661756c74000400000000000000000000010000000806066781020101010000000f
and again I have made sure that Client.jar is added to project as external Jar files using eclipse project setting.

Thanks and regards
Sandip
[ May 13, 2005: Message edited by: Sandip Shinde ]
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704

Actually I am able to get refernce of HomeObject , exception is coming for the line on which I am trying to cast it using narrow method.

Bean deployed "Tatto" as JNDI Name , so am looking for Tatto.

Yes you right it should work. If your client wouldn�t be able to lookup the bean, or the bean was not properly deployed you�d get different error messages. Also you�d get ClassNotFoundException if the client wouldn�t be able to load the bean specific classes.
Unfortunately I never used Sun RI server and therefore I can�t help you much here. But at least I can suggest you couple of things:
  • Try to use ejb references and JNDI ENC.
  • Make sure the TattoHome client and server versions are identical.


  • Regards.
     
     
    subject: Too many exceptions for first EJB Client App