cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing XI Repository Beans

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

My problem is that QueryService is just an Interface Class, so I cannot compile the code.

Vlado
Advisor
Advisor
0 Kudos

Hi Daniel,

Sure you can use the QueryService interface in your code! It's the same as you wrote QueryServiceHome home = ...

What's the problem if you change the last line to what I suggested above?

Best regards,

Vladimir

PS: Please consider rewarding points for helpful answers.

Former Member
0 Kudos

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.

Vlado
Advisor
Advisor
0 Kudos

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