cancel
Showing results for 
Search instead for 
Did you mean: 

JavaMapping issue in SAP PO 7.5 when calling Twilio Java program

Former Member
0 Kudos

Hi Guys,

I trying to call the Twilio SendSMS class in Java Mapping SAP PO 7.5. In Eclipse the Twilio Class is working fine after adding the Reference Library "Twilio-7.24.2.jar" but when I merge the Twilio Java class along with "XPI Mapping Libraries & Twilio-7.24.2.jar" in SAP Java Mapping I am getting errors.

Error:-

LinkageError during appliction Java mapping org/twilio/sms/App

java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException at org.twilio.sms.App.sendSMS(App.java:37) at org.twilio.sms.App.transform(App.java:26) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:112) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:87) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:54) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:139) at com.sap.aii.ibrep.server.mapping.exec.ExecuteIfMapCommand.execute(ExecuteIfMapCommand.java:33) at

Twilio Java Code - https://www.twilio.com/docs/sms/api/message#create-a-message-resource

I have attached the screen shots for the reference.

twilio-java-code.jpgjava-mapping.jpgexternal-reference.jpgoperation-mapping-error.jpgmessage-monitor-error.jpg

Here is the Java Mapping Code

package org.twilio.sms;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import java.io.*;
import com.sap.aii.mapping.api.*;

public class App extends AbstractTransformation {
	public static final String ACCOUNT_SID ="ACfcc16e13854745a72a11a8e9fa29818d";
	public static final String AUTH_TOKEN ="39d934fd23909d0f3208ae6d79942f1f";
    @Override
        public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
        try {
            InputStream inputstream = transformationInput.getInputPayload().getInputStream();
            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
            // Copy Input content to Output content
            byte[] b = new byte[inputstream.available()];
            inputstream.read(b);
            outputstream.write(b);
            sendSMS();          
        } catch (Exception exception) {
            getTrace().addDebugMessage(exception.getMessage());
            throw new StreamTransformationException(exception.toString());
        }
    }
	public void sendSMS() {
	Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
	Message message = Message
	    .creator(new PhoneNumber("+14845228355"), // to
	            new PhoneNumber("+15312017780"), // from
	            "Got it!!") // body
	    .create();
	} 
    public static void main(String[] args) {
    }
}

Former Member
0 Kudos

Guys,

Is it achievable using this Java Mapping program to send SMS? Because I am using the Twilio Class in our SAP PO Java mapping so I am not sure.

Could any one please confirm is this approach achievable?

Thanks in advance,

RV

View Entire Topic
JacoVanebo
Explorer
0 Kudos

Hi RV,

It looks like Twilio has a lot of dependencies on other Java-libraries (all the Maven-dependencies listed in java-mapping.jpg). All of these Java-libraries must be included with Java Mapping i.e. the Jar-files must be imported as Imported Archive in Integration Service Builder.

Best regards,
Jacob

P.S. Please adhere from importing the XPI Mapping Libraries as Imported Archive - those Jars are already part of the runtime and could cause problems for you down the line, because they are not in same version, as the actual runtime.