cancel
Showing results for 
Search instead for 
Did you mean: 

EJB mapping function and service composition

Former Member
0 Kudos

Hi there,

My scenario is:

1) The trigger of my process refers to a web service with a purchase order input type (defined on my own xsd file). This PO type has a header and a collection of items.

2) I have a WD4J app which allows the user to enter a PO id and uses a composed service to get PO details before triggering the process

3) The composed service call the following SAP BAPIs:

- BAPI_PO_GETDETAIL1: to get PO header data

- BAPI_VENDOR_GETDETAIL: to get vendor/supplier information

4) I have an EJB to perform the mapping between the collection BAPI_PO_GETDETAIL1.Response/POITEM/item (cardinality is 0.**, type is BAPIMEPOITEM) to my own PO data structure

5) I have defined a EJB mapping function which receives an argument called parameter1 of type BAPIMEPOITEM, marked as a collection.

Everything compiles and deploy perfectly.

However, when I try to test my composed service using wsnavigator, I get the following Exception.

Any hints? How could I accomplish the same result working around this problem?

Best regards,

Ricardo Giacomin



Server Exception: javax.ejb.EJBException: ASJ.ejb.005044 (Failed in component: vetta.com.br/log_rec_almox_sc) Exception raised from invocation of public com.vetta.detalhepedido.GetPODetailsResponse com.vetta.detalhepedido.adapted.DetalhePedidoEjb.getPODetails(com.vetta.detalhepedido.GetPODetailsRequest) method on bean instance com.vetta.detalhepedido.adapted.DetalhePedidoEjb @ 544df7e4 for bean vetta.com.br/log_rec_almox_sc*annotation|vetta.com.br~log_rec_almox_sc.jar*annotation|com.vetta.detalhepedido.adapted.DetalhePedidoEjb in application vetta.com.br/log_rec_almox_sc.; nested exception is: java.lang.IllegalStateException: u2028Steps executed successful: 4 from 5: u2028Success: DetalhePedido_NewOperation/BAPI_PO_GETDETAIL1.xml (mappings execution) u2028Success: DetalhePedido_NewOperation/BAPI_PO_GETDETAIL1.xml (service execution) u2028Success: DetalhePedido_NewOperation/BAPI_VENDOR_GETDETAIL.xml (mappings execution) u2028Success: DetalhePedido_NewOperation/BAPI_VENDOR_GETDETAIL.xml (service execution) u2028Failed: DetalhePedido_NewOperation/getPODetails.xml (return value mappings execution) u2028u2028--> Caused by: An error on target path http://vetta.com.br/DetalhePedido/:getPODetailsResponse/out/http://vetta.com.br/DetalhePedido:idFornecedor u2028Details :ClassCastException: class $Proxy2680:vetta.com.br/log_rec_almox_ear @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 583ca424 @ alive incompatible with interface com.sap.glx.mapping.execution.api.function.Function:library:com.sap.glx.mapping.lib @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 25e12e2c @ alive u2028at: IllegalArgumentException: Lookup name 'vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal' invalid u2028at: EJB::vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal( urn:sap-com:document:sap:rfc:functions:BAPI_PO_GETDETAIL1.Response/POITEM/item --> parameter1 ) u2028at: EJB::vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal( urn:sap-com:document:sap:rfc:functions:BAPI_PO_GETDETAIL1.Response/POITEM/item --> parameter1 )/result --set(relay,void)--> http://vetta.com.br/DetalhePedido/:getPODetailsResponse/out/http://vetta.com.br/DetalhePedido:idFornecedor u2028at: . --merge(block,void)--> http://vetta.com.br/DetalhePedido/:getPODetailsResponse/out u2028at: . --merge(block,void)--> http://vetta.com.br/DetalhePedido/:getPODetailsResponse u2028u2028--> Caused by: ClassCastException: class $Proxy2680:vetta.com.br/log_rec_almox_ear @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 583ca424 @ alive incompatible with interface com.sap.glx.mapping.execution.api.function.Function:library:com.sap.glx.mapping.lib @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 25e12e2c @ alive u2028at: IllegalArgumentException: Lookup name 'vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal' invalid u2028at: EJB::vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal( urn:sap-com:document:sap:rfc:functions:BAPI_PO_GETDETAIL1.Response/POITEM/item --> parameter1 ) u2028at: EJB::vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal( urn:sap-com:document:sap:rfc:functions:BAPI_PO_GETDETAIL1.Response/POITEM/item --> parameter1 )/result --set(relay,void)--> http://vetta.com.br/DetalhePedido/:getPODetailsResponse/out/http://vetta.com.br/DetalhePedido:idFornecedor u2028at: . --merge(block,void)--> http://vetta.com.br/DetalhePedido/:getPODetailsResponse/out u2028at: . --merge(block,void)--> http://vetta.com.br/DetalhePedido/:getPODetailsResponse u2028u2028--> Caused by: ClassCastException: class $Proxy2680:vetta.com.br/log_rec_almox_ear @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 583ca424 @ alive incompatible with interface com.sap.glx.mapping.execution.api.function.Function:library:com.sap.glx.mapping.lib @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 25e12e2c @ alive u2028at: IllegalArgumentException: Lookup name 'vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal' invalid u2028u2028--> Caused by: Lookup name 'vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal' invalid u2028--> Caused by: class $Proxy2680:vetta.com.br/log_rec_almox_ear @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 583ca424 @ alive incompatible with interface com.sap.glx.mapping.execution.api.function.Function:library:com.sap.glx.mapping.lib @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 25e12e2c @ alive u2028u2028u2028at com.sap.engine.services.webservices.espbase.client.bindings.impl.SOAPTransportBinding.processFault(SOAPTransportBinding.java:2074) u2028at com.sap.engine.services.webservices.espbase.client.bindings.impl.SOAPTransportBinding.call_SOAP(SOAPTransportBinding.java:1415) u2028at com.sap.engine.services.webservices.espbase.client.bindings.impl.SOAPTransportBinding.callWOLogging(SOAPTransportBinding.java:990) u2028at com.sap.engine.services.webservices.espbase.client.bindings.impl.SOAPTransportBinding.call(SOAPTransportBinding.java:944) u2028at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DInterfaceInvokerImpl.invokeOperation(DInterfaceInvokerImpl.java:76) u2028at com.sap.esi.esp.wsnavigator.lib.Operation.execute(Operation.java:171) u2028

Accepted Solutions (1)

Accepted Solutions (1)

ch_loos
Advisor
Advisor
0 Kudos

Does your EJB interface (not the bean class!) extends com.sap.glx.mapping.execution.api.function.Function?

seems like this is the issue right there...

Former Member
0 Kudos

Christian Loos,

Thank you very much. This solved my problem.

Best regards,

Ricardo Giacomin

Answers (2)

Answers (2)

ch_loos
Advisor
Advisor
0 Kudos

Does your EJB interface (not the bean class!) extends com.sap.glx.mapping.execution.api.function.Function?

Are you sure that in the implementation, you are accessing the SDO structure correctly?

abhijeet_mukkawar
Active Contributor
0 Kudos

This exception is because the ClassLoaders from the class that belongs to the remote object (referred in JNDI lookup) and the class that acts as casting destination (object typed as the EJB local interface) are different.

Check below link

http://wiki.sdn.sap.com/wiki/display/XI/SapNetweaverProcessIntegration.CallEjb3.0methodfromJavaclassmappingPI7.1

-Abhijeet

Edited by: Abhijeet on Dec 14, 2011 5:20 PM

Former Member
0 Kudos

Abhijeet,

I understood the problem with different classloaders but didn't get what I could do to workaround this problem. And it seems to happen to any ejb mapping function I implement. For instance, I've just followed the directions presented at http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/10057e20-2ca2-2d10-1b91-a1b9a8c8e634. At runtime I get the same classcastexception I referred to in my original post.

Any hints?

Thank you in advance,

Ricardo Giacomin

Former Member
0 Kudos

Post EJB interface and implementation code here.

Former Member
0 Kudos

Local interface is:


package com.vetta.log.rec.almox.ejb;
import javax.ejb.Local;

@Local
public interface GetExternalUsersFunctionLocal {

}

Implementation code is:


package com.vetta.log.rec.almox.ejb;

import java.util.List;

import javax.ejb.Local;
import javax.ejb.Stateless;

import com.sap.glx.mapping.execution.api.function.Function;
import com.sap.glx.mapping.execution.api.invoker.SdoInvoker;
import commonj.sdo.DataObject;
import commonj.sdo.Property;

/**
 * Session Bean implementation class GetExternalUsersFunction
 */
@Stateless
@Local( { Function.class, SdoInvoker.class })
public class GetExternalUsersFunction implements GetExternalUsersFunctionLocal, Function, SdoInvoker {

	private static final String SOURCE_PROPERTY_EMAILADDRESSES = "$emailAddresses";
	private static final String SOURCE_PROPERTY_LOCALE = "$locale";
	private static final String SOURCE_PROPERTY_TIMEZONE = "$timezone";
	private static final String TARGET_PROPERTY_EXTERNALUSERSTYPE = "$result";
	private static final String TARGET_PROPERTY_EMAILID = "$EmailID";
	private static final String TARGET_PROPERTY_LOCALE = "$Locale";
	private static final String TARGET_PROPERTY_TIMEZONE = "$Timezone";

	/**
     * Default constructor. 
     */
    public GetExternalUsersFunction() {
    }

	/**
     * @see SdoInvoker#invokeSdo(DataObject, SdoInvoker.InvocationContext)
     */
    public DataObject invokeSdo(DataObject sourceDO, SdoInvoker.InvocationContext invocationContext) {
    	
    	// check source DO
		if (sourceDO == null) {
			throw new IllegalArgumentException("SourceDO must exist");
		}
		
		// Check invocation context
		if (invocationContext == null) {
			throw new IllegalArgumentException("InvocationContext must exist");
		}
		
		DataObject rootObject = invocationContext.createOutputDataObject();
		if (rootObject == null) {
			throw new IllegalArgumentException("Response must be registered");
		}
		
		Property emailAddressesProperty = sourceDO.getType().getProperty(SOURCE_PROPERTY_EMAILADDRESSES);
		Property localeProperty = sourceDO.getType().getProperty(SOURCE_PROPERTY_LOCALE);
		Property timezoneProperty = sourceDO.getType().getProperty(SOURCE_PROPERTY_TIMEZONE);
		List<String>  emails = sourceDO.getList(emailAddressesProperty);
		String locale = sourceDO.getString(localeProperty);
		String timezone = sourceDO.getString(timezoneProperty);
		Property externalUsersTypeProperty = rootObject.getType().getProperty(TARGET_PROPERTY_EXTERNALUSERSTYPE);
		
		for (String email: emails) {
			DataObject externalUserDO = rootObject.createDataObject(externalUsersTypeProperty);
			Property emailIDProperty = externalUserDO.getType().getProperty(TARGET_PROPERTY_EMAILID);
			Property targetLocaleProperty = externalUserDO.getType().getProperty(TARGET_PROPERTY_LOCALE);
			Property targetTimezoneProperty = externalUserDO.getType().getProperty(TARGET_PROPERTY_TIMEZONE);
			externalUserDO.set(emailIDProperty, email);
			externalUserDO.set(targetLocaleProperty, locale);
			externalUserDO.set(targetTimezoneProperty, timezone);
		}
		return rootObject;
	}
}

abhijeet_mukkawar
Active Contributor
0 Kudos

Double check your JNDI name..or get it from NWA (use the quick link http://<host>:<port>/nwa/jndi) ...your JNDI name looks to be

vetta.com.br/log_rec_almox_ear/LOCAL/ItemPedidoMappingFunction/com.vetta.log.rec.almox.ejb.ItemPedidoMappingFunctionLocal

Where as you EJB local interface seems :GetExternalUsersFunctionLocal

-Abhijeet

Edited by: Abhijeet on Dec 21, 2011 4:13 PM

Former Member
0 Kudos

Abhijeet,

There is a bit of confusion here. I started the thread describing a first scenario and then I said that even for the GetExternalUsers (available as a tutorial in SDN) I got the same error message. The code I posted here is for the latter, not the former. Therefore there is not a problem with JNDI names.

Best,

Ricardo

0 Kudos

hello,

I have used the same function but i am getting invalid expression.

please need your help