I have the following java class (Templateaccessor) which I need to call
from a jaggery file. For that I created a jar and accessed it. But it gives
an error when I try to access the getTemplateDomain() method.

I can access simple methods as in
http://madhukaudantha.blogspot.com/2014/02/using-java-method-from-jaggery-file.html

I figured that it is due to the use of imports. Can someone suggest me a
way to resolve the imports in the jar file?

*M.N.F. Dilhasha*
Software Engineering Intern | *WSO2 Lanka*

email   :
*[email protected] <[email protected]>*mobile : +94 77 8449321
package org.wso2.cep;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.wso2.cep.templating.*;

/**
 * Created by dilhasha on 1/14/15.
 */
public class templateaccessor {

    private static Log log = LogFactory.getLog(templateaccessor.class);
    TemplateDomain templateDomain;

    public TemplateDomain getTemplateDomain(){
        try {
            String path="org/wso2/cep/templating/TemperatureAnalysis.xml";
            //create JAXContext instance
            JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);

            //JAXBContext instance to create the Unmarshaller.
            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

            //Unmarshaller to unmarshal the XML document to get an instance of JAXBElement.
            JAXBElement<TemplateDomain> unmarshalledObject =
                    ((JAXBElement<TemplateDomain>) unmarshaller.unmarshal(ClassLoader.getSystemResourceAsStream(path)));

            //Get the instance of the required JAXB Root Class from the JAXBElement.
            templateDomain = unmarshalledObject.getValue();
        }
        catch(JAXBException e)
        {
            log.error("JAXBException occured", e);
        }
        return templateDomain;
    }
}
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to