Rest API import package error

HI,

I am getting an error when I compile the REST API code in the script console using the Forge-RestAPI cartridge. The error is when I import certain packages e.g.

import javax.ws.rs.*;
import javax.ws.rs.core.*;
import javax.ws.rs.container.*;
import javax.servlet.http.*;
import com.quest.forge.rest.annotation.Secured;
import com.quest.forge.rest.service.*;
import com.quest.forge.rest.api.*;
import com.quest.wcf.servicelayer.*;
import com.quest.qsi.fason.framework.utils.QSIAES; // Error when I import this package

How can I get the package in the class path and still compile it in the script console or if there is any other way to compile?

Thanks

Parents
  • Is the error about unresolved class QSIAES ? There's a field named "Choose an Associated Cartridge (Optional):" in the popup window of Script Console, through this field you can select the corresponding cartridge for the class you want to import. The one you want to import may be from DB_DB2.

    Regards

    Jemy

  • Thanks for replying back Jemy. I am already selecting Forge-RestApi associated cartridge to resolve 

    import javax.ws.rs.*;
    import javax.ws.rs.core.*;
    import javax.ws.rs.container.*;
    import javax.servlet.http.*;
    import com.quest.forge.rest.annotation.Secured;
    import com.quest.forge.rest.service.*;
    import com.quest.forge.rest.api.*;
    import com.quest.wcf.servicelayer.*;

    The cartridge selection although does not resolve com.quest.qsi.fason.framework.utils.QSIAES;

    Is there a way to associate multiple cartridges or any other way to resolve the class?

    Thanks

     

  • Now it's not possible to associate multiple cartridges in the Script Console. For some classes from other cartridges, you may need to have a classloader to load the classes from corresponding paths before using them. Here's a simple example for your reference.

    import javax.ws.rs.*;
    import javax.ws.rs.core.*;
    import javax.ws.rs.container.*;
    import javax.servlet.http.*;
    import com.quest.forge.rest.annotation.Secured;
    import com.quest.forge.rest.service.*;
    import com.quest.forge.rest.api.*;
    import com.quest.wcf.servicelayer.*;
     
    // you can get jars from corresponding folder under cartridge.exploded
    List<File> jars = Arrays.asList(new File("C:\\Quest\\Foglight597-11build\\state\\cartridge.exploded\\DB_DB2-5_9_3_10\\DB_DB2-FMS-APIs-5_9_3_10").listFiles());

    URL[] urls = new URL[jars.size()];
    for (int i = 0; i < jars.size(); i++) {
        try {
            urls[i] = jars.get(i).toURI().toURL();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    URLClassLoader childClassLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
     
    obj = Class.forName("com.quest.qsi.fason.framework.utils.QSIAES", true , childClassLoader);
     
    StringBuffer buf = new StringBuffer()
    buf.append(obj.BLOCK_SIZE).append('  ---  ').append(Secured)
    buf

    Regards

    Jemy

Reply
  • Now it's not possible to associate multiple cartridges in the Script Console. For some classes from other cartridges, you may need to have a classloader to load the classes from corresponding paths before using them. Here's a simple example for your reference.

    import javax.ws.rs.*;
    import javax.ws.rs.core.*;
    import javax.ws.rs.container.*;
    import javax.servlet.http.*;
    import com.quest.forge.rest.annotation.Secured;
    import com.quest.forge.rest.service.*;
    import com.quest.forge.rest.api.*;
    import com.quest.wcf.servicelayer.*;
     
    // you can get jars from corresponding folder under cartridge.exploded
    List<File> jars = Arrays.asList(new File("C:\\Quest\\Foglight597-11build\\state\\cartridge.exploded\\DB_DB2-5_9_3_10\\DB_DB2-FMS-APIs-5_9_3_10").listFiles());

    URL[] urls = new URL[jars.size()];
    for (int i = 0; i < jars.size(); i++) {
        try {
            urls[i] = jars.get(i).toURI().toURL();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    URLClassLoader childClassLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
     
    obj = Class.forName("com.quest.qsi.fason.framework.utils.QSIAES", true , childClassLoader);
     
    StringBuffer buf = new StringBuffer()
    buf.append(obj.BLOCK_SIZE).append('  ---  ').append(Secured)
    buf

    Regards

    Jemy

Children