I'm facing Linkage error while consuming addSubscriberToList method of Exact target AEM api.
Code snippet used:
package com.test;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.wcm.webservicesupport.Configuration;
import com.day.cq.wcm.webservicesupport.ConfigurationManager;
import com.day.cq.mcm.exacttarget.ExactTargetException;
import com.day.cq.mcm.exacttarget.ExactTargetService;
import com.day.cq.mcm.exacttarget.client.Subscriber;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@SlingServlet(paths="/bin/exactTarget/createSub", methods="POST")
public class ExactTargetAPI extends SlingAllMethodsServlet {
/**
*
*/
private static final long serialVersionUID = 155566L;
private final Logger log = LoggerFactory.getLogger(ExactTargetAPI.class);
@Override
protected void doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response) {
try {
log.info("Inside doPost");
ExactTargetService exactTargetService = getServiceReference(ExactTargetService.class);
ConfigurationManager etConfigMgr = getServiceReference(ConfigurationManager.class);
Configuration config = etConfigMgr.getConfiguration("/etc/cloudservices/exacttarget/test");
//Subscriber subscriber = getServiceReference(Subscriber.class);
Subscriber subscriber = new Subscriber();
subscriber.setEmailAddress(request.getParameter("email"));
exactTargetService.addSubscriberToList(config, subscriber);
}
catch (ExactTargetException exp ) {
log.info("Something went wrong during the connection" + exp);
}
catch (Exception ex ) {
log.info("General Exception" + ex);
}
}
/**
* Gets the service reference either from BundleContext.
*
* @param <T>
* the generic type
* @param serviceClass
* the class whose reference has to be returned.
* @return T the service reference
*/
@SuppressWarnings("unchecked")
public static <T> T getServiceReference(final Class<T> serviceClass) {
T serviceRef = null;
/**
* Get the BundleContext associated with the passed class reference.
*/
final BundleContext bundleContext = FrameworkUtil.getBundle(serviceClass).getBundleContext();
if (null != bundleContext) {
final org.osgi.framework.ServiceReference osgiRef = bundleContext.getServiceReference(serviceClass.getName());
if(null != osgiRef){
serviceRef = (T) bundleContext.getService(osgiRef);
}
}
return serviceRef;
}
}
Error snippet
java.lang.LinkageError: loader constraint violation: when resolving interface method "com.day.cq.mcm.exacttarget.ExactTargetService.addSubscriberToList(Lcom/day/cq/wcm/webservicesupport/Configuration;Lcom/day/cq/mcm/exacttarget/client/Subscriber;)V" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the current class, com/test/ExactTargetAPI, and the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for resolved class, com/day/cq/mcm/exacttarget/ExactTargetService, have different Class objects for the type cq.mcm.exacttarget.ExactTargetService.addSubscriberToList(Lcom/day/cq/wcm/webservicesupport/Configuration;Lcom/day/cq/mcm/exacttarget/client/Subscriber;)V used in the signature
Views
Replies
Total Likes