on 07-07-2005 10:09 AM
Hi,
I'm going to query some of the Session stateless beans from XI like sap.com/com.sap.xi.directory/DirQueryServiceBean.
This gives an object of com.sap.aii.ib.sbeans.query.QueryServiceHome_Stub. I can only cast this object to a QueryServiceHome object, which has a create method. The create method on QueryServiceHome return a remote object.
Context ctx = new InitialContext(env);
// Look up an object
Object obj = ctx.lookup(name);
// Print it
out.println(name + " is bound to: " + obj + " type " + obj.getClass());
QueryServiceHome home= (QueryServiceHome) obj;
out.println("-home found-");
QueryServiceHome_Stub stub = (QueryServiceHome_Stub)home.create();
I get -home found- printed, but the I get at ClassCastException.
Does any body have an answert to how I can get access to the bean and query it for information.
Hi Daniel,
The QueryServiceHome.create() method would return the remote interface of the bean. So the last line in your code should be
QueryService remoteObj = home.create();
Now you can work with the remote object and query it for information.
Hope that helps!
Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
You are going in right direction, but you have wrriten last line wrongly.
Your home object of EJB returns the object of your remote Interface, which is here in your case is: QueryService
So, replace QueryServiceHome_Stub to QueryService.
and run your code.
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I try to use the home.create() as described I compile because the create() return a remote object.
I have use the get Client Jar form an application. In this i only have the *home_stub and *remote_stub of the different objects. Should there be any other ways to get more interfaces for the application.
Hi Daniel,
In general, when you want to use some application, at least you must have the classes that you access in your client's classpath. That is how it works. Otherwise, can you explain me how you have access to the QueryServiceHome interface but not to the QueryService interface?
In particular in your case you must find the application "com.sap.xi.directory" and include its jars in your client's classpath. Then proceed as already described.
Best regards,
Vladimir
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.