Importing jar library

08 Feb '13, 04:03 PM
19,034 Views
No Forum Badges

Hi, I'm trying to import the groovy-json-2.0.1 library in a script unit. I added the jar file in <project_path>/Web Content/WEB-INF/lib as suggested in a previous topic of this forum but after importing it in script unit with the instruction import groovy.json, I have the following error in log file unable to resolve class groovy.json

 
x 1
Follow
Answer Answer at this question and get points!
No Forum Badges

Hi,

you should try to import all the classes of the library

import groovy.json.*;

Alternatively, if the Groovy script will use specific classes you can import only the needed ones. For example:

import groovy.json.<class1>;
import groovy.json.<class2>;

where <class1> and <class2> are the names of a Java classes.

 
x 1
Forum Starter - Level 2

Has anyone found a solution to this? I have the same error for the groovy.sql.Sql class. The groovy-all jar file is in my <project>/WEB-INF/lib folder, but if I try to use the import in a template file class for a custom unit the "unable to resolve ..." error message is given upon generation of the project.

Interesting though I can add import statements for java.sql.Connection, etc. What is the difference for the class loader for script units versus unit layout templates using scriptlets>

 
x 0
Answer at this question and get points!