cancel
Showing results for 
Search instead for 
Did you mean: 

JobDefinition select from iterator

Former Member
0 Kudos

Hello,

my script should select jobs with a certain value of a given parameter and write the jobnames into a table.

But I cannot iterate through the selected jobs.

I get the error message "Cannot cast class com.redwood.scheduler.model.JobDefinitionParameterImpl to interface com.redwood.scheduler.api.model.JobDefinition" directly after control1. control2 will not be inserted in stdout.log.

      Iterator jobDefinitions;

      String sql = "select jdp.* from JobDefinition jd, JobDefinitionParameter jdp " +
             "where jdp.DefaultExpression like ? " +
             "and jdp.JobDefinition = jd.UniqueId " +
             "and jd.MasterJobDefinition = jd.UniqueId " +
             "and jdp.Name like ? ";

      String sql1 = "select jdp.* from JobDefinition jd, JobDefinitionParameter jdp, Application ap " +
            "where ap.Name = ? " +
            "and jdp.JobDefinition = jd.UniqueId " +
            "and jd.MasterJobDefinition = jd.UniqueId " +
            "and jdp.DefaultExpression like ? " +
            "and jdp.Name like ? ";

      if(app != null){
       jobDefinitions = jcsSession.executeObjectQuery(sql1, new Object[]{app.getName(),p_ParamValue,p_JobParameter});
                    }else{
       jobDefinitions = jcsSession.executeObjectQuery(sql, new Object[]{p_ParamValue,p_JobParameter});
      }

      if (!jobDefinitions.hasNext())
      {
        return;
      }

      while (jobDefinitions.hasNext())
      {
jcsOut.println("control 1" );
        JobDefinition jd = (JobDefinition) jobDefinitions.next();
jcsOut.println("control 2" );

Why the jobdefinition cannot be seperated from the iterator?

Thanks and best regards

Dana

Accepted Solutions (1)

Accepted Solutions (1)

nanda_kumar21
Active Contributor
0 Kudos

hi Dana,

You are doing a select on JobDefinitionParameter and casting it to JobDefinition object, which is causing the error.

Modify your query to

"select jd.*...."

thanks

Nanda

Former Member
0 Kudos

Many, many thanks.

Such a small letter with such a big impact.

Best regards Dana

Answers (0)