Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:05:53+00:00 2026-05-25T19:05:53+00:00

I want to invoke groovy method from the given below class package infa9 import

  • 0

I want to invoke groovy method from the given below class

 package infa9

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import com.ABC.csm.context.AppCtxProperties;

import com.ABC.csm.context.AppContext;


 public class LicenseInfo
{
private StringBuffer licenseInformation;

public LicenseInfo() {
    licenseInformation = new StringBuffer();
}

public StringBuffer getLicenseInformation(){
    return licenseInformation;
}

public void fetchLicenseInformation(HashMap<String,String> params,Map env)
{
    ArrayList<String> licenseList = fetchLicenses(params);
    .
    .
    .

}

private ArrayList<String> fetchLicenses(HashMap<String,String> params,Map env)
{

    ArrayList<String>licenseList = new ArrayList<String>();
    .
    .
    .
return licenseList;

}

}

So this is what I am trying to do

//getting user parameters
HashMap<String,String> params = IntermediateResults.get("userparams")

//getting environment variables
Map env=AppContext.get(AppCtxProperties.environmentVariables)

Object[] arguments=new Object[2]
arguments.putAt("userparams", params)
arguments.putAt("env", env)

GroovyShell shell = new GroovyShell()
Script infa9LicenseScript = shell.parse("plugins.infa9.LicenseInfo")

   infa9LicenseScript.invokeMethod(fetchLicenseInformation, arguments)
   String lic=(String)infa9LicenseScript.invokeMethod(getLicenseInformation,null)

Am I passing the parameters to fetchLicenseInformation correctly?? I need to pass HashMap<String,String> ,Map Please help me invoke a groovy method with parameters

Error: Exception in thread "main" groovy.lang.MissingPropertyException: No such property: userparams for class: [Ljava.lang.Object;

Update

public List<String> fetchLicenses( Map<String,String> params, Map env ) {
//[ 'a', 'b', 'c' ]
  ArrayList<String>licenseList = new ArrayList<String>();
    String infacmdListLicensesCommand = null;

    if (System.getProperty("os.name").contains("Win"))
    {   infacmdListLicensesCommand = env.get("INFA_HOME")
                + "/isp/bin/infacmd.bat ListLicenses -dn "
                + params.get("dn") + " -un " + params.get("un") + " -pd "
                + params.get("pd") + " -sdn " + params.get("sdn") + " -hp "
                + params.get("dh") + ":" + params.get("dp");}
    else
    {   infacmdListLicensesCommand = env.get("INFA_HOME")
                + "/isp/bin/infacmd.sh ListLicenses -dn "  //this is line no 71, where exception is thrown
                + params.get("dn") + " -un " + params.get("un") + " -pd "
                + params.get("pd") + " -sdn " + params.get("sdn") + " -hp "
                + params.get("dh") + ":" + params.get("dp");}

    try {
        Process proc = Runtime.getRuntime().exec(infacmdListLicensesCommand);

        InputStream stdin = proc.getInputStream();
        InputStreamReader isr = new InputStreamReader(stdin);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            licenseList.add(line);
        }
        int exitVal = proc.waitFor();
        System.out.println("Process exit value is: " + exitVal);

    }catch (IOException io) {
        io.printStackTrace();
    }catch (InterruptedException ie) {
        ie.printStackTrace();
    } /* end catch */
return licenseList;
 }

Exception
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: java.lang.String.positive() is applicable for argument types: () values: []
Possible solutions: notify(), tokenize(), size()
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unaryPlus(ScriptBytecodeAdapter.java:764)
at infa9.LicenseInfo.fetchLicenses(Infa9LicensesUtil.groovy:71)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:05:54+00:00Added an answer on May 25, 2026 at 7:05 pm

    Right…I created this groovy script LicenseInfo.groovy inside a folder ./test/:

    package test
    
    public class LicenseInfo {
      StringBuffer licenseInformation
    
      public LicenseInfo() {
        licenseInformation = new StringBuffer()
      }
    
      public void fetchLicenseInformation( Map<String,String> params, Map env ) {
        List<String> licenseList = fetchLicenses( params, env )
        println "List is $licenseList"
      }
    
      public List<String> fetchLicenses( Map<String,String> params, Map env ) {
        [ 'a', 'b', 'c' ]
      }
    }
    

    inside the current folder ./, I created this groovy script Test.groovy:

    // Make some params...
    def params = [ name:'tim', value:'text' ]
    
    // Fake an env Map
    def env = [ something:'whatever' ]
    
    // Load the class from the script
    def liClass = new GroovyClassLoader().parseClass( new File( 'test/LicenseInfo.groovy' ) )
    
    // Run the method
    liClass.newInstance().fetchLicenseInformation( params, env )
    

    When I execute the command

    groovy Test.groovy
    

    it prints out:

    List is [a, b, c]
    

    Edit after update

    The positive errors you are getting are due to the way the Groovy parser works… You cannot put the + on the start of the next line when joining Strings, the + has to be trailing on the previous line (as semi-colons are optional for the end of lines in groovy, there is no way for the parser to know you are adding on to the previous line)

    This will work:

    if (System.getProperty("os.name").contains("Win")) {
      infacmdListLicensesCommand = env.get("INFA_HOME") + "/isp/bin/infacmd.bat ListLicenses -dn " +
                                   params.get("dn") + " -un " + params.get("un") + " -pd " +
                                   params.get("pd") + " -sdn " + params.get("sdn") + " -hp " +
                                   params.get("dh") + ":" + params.get("dp")
    }
    else {
      infacmdListLicensesCommand = env.get("INFA_HOME") + "/isp/bin/infacmd.sh ListLicenses -dn " +
                                   params.get("dn") + " -un " + params.get("un") + " -pd " +
                                   params.get("pd") + " -sdn " + params.get("sdn") + " -hp " +
                                   params.get("dh") + ":" + params.get("dp")
    }
    

    And this would be a more Groovy way of doing the same thing:

    boolean isWindows = System.getProperty("os.name").contains("Win")
    // Do it as a list of 3 items for formatting purposes
    infacmdListLicensesCommand = [
      "$env.INFA_HOME/isp/bin/infacmd.${isWindows?'bat':'sh'} ListLicenses"
      "-dn $params.dn -un $params.un -pd $params.pd -sdn $params.sdn"
      "-hp $params.dh:$params.dp" ].join( ' ' ) // then join them back together
    
    println infacmdListLicensesCommand // print it out to see it's the same as before
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to invoke a getter method (returns String value) of a Java class
I want to specifically invoke the base class method; what's the most concise way
I want to be able to invoke an SSIS package at will from a
What I want to do is invoke maven from a groovy script. The groovy
I want to invoke a creation of div with certain class just below the
Using Groovy's package name convention, I can intercept Groovy method calls to a Java
I want to invoke one application from another application. My Java file code: Intent
I want to invoke a masterPage's method from a inner user-control (user control inside
I want to invoke a selector of a method that has the usual NSError**
I want to invoke the main method which is static. I got the object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.