cancel
Showing results for 
Search instead for 
Did you mean: 

Calling an ESA service from EJB

Former Member
0 Kudos

Hi,

I am trying to call an ESA service from an EJB DC project.

for that i have created a deployable proxy DC project. And created a new client proxy definition.

Now I am doing a JNDI lookup for the deployable proxy in my stateless session bean.

its successfully doing the lookup. But now i am now able to typecast the returned object into one of the implementing classes.

in other words my JNDI lookup is giving me return object of type ECC_CostCtrVarBudMonRuleROwQRServiceImpl. but the deployable proxy project does not have any such class.

generally I have seen that in case of calling any normal webservice the deployable proxy project generates all the required files. But it is not happening in case of ESA.

is there something I am missing.

thanks in advance.

regardxs,

saurabh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi there,

there's a <a href="http://help.sap.com/saphelp_nw04/helpdata/en/45/029840cf43495195da923f32262911/content.htm">HOWTO</a> on <a href="http://help.sap.com">help.sap.com</a>.

Probably you missed chapter 11 of it:

<i>Add an application reference

After step 7, you have defined the reference that is to be bound to your application’s naming environment. However, to be able to load classes of the referenced proxy interface, you must also set a reference at classloader level. That is, you must set a reference to the corresponding server component in the application-j2ee-engine.xml descriptor in your Enterprise Application Project. To do this, open the application-j2ee-engine.xml editor of the EAR project you created and choose General -> References -> Add-> Create New.

a. Reference target – this is the component to which you want to create a reference.

b. Reference type – hard means that your application will not be started if the component is not started. Weak means that it will be started whether the proxy application is deployed or not, but it will not be useable until the proxy is started.

c. Reference target type – this is the type of the component to which you are creating a reference.

d. Provider name – enter sap.com

</i>

regards, anton

Answers (1)

Answers (1)

Opgenorth
Employee
Employee
0 Kudos

Hi Saurabh,

the class ECC_CostCtrVarBudMonRuleROwQRServiceImpl implements the interface ECC_CostCtrVarBudMonRuleROwQRService which should be contained in your deployable proxy project. In your application, you should cast to the interface, not to the implementation, because the implementation may differ for different server releases. In any case you have to set the reference in the deployment descriptor as Anton wrote in his answer.

Best regards,

Juergen

Former Member
0 Kudos

Hi Juergen,

when i do that - cast the object i receive from the lookup to the interface - i get a java.lang.ClassCastException.

the code is this:

InitialContext ctx = new InitialContext();
			wetterService = (WeatherForecast) ctx.lookup("java:comp/env/WeatherServiceProxy");

The Object i get back before casting is of type WeatherServiceImpl.

Do you have any explanation/solution to this?

Thanks & Greetings, Michael