Skip to main content
April 8, 2014
Question

Error while assigning resultset value to Querytable variable in Coldfusion 10

  • April 8, 2014
  • 1 reply
  • 938 views

We are upgrading from coldfusion 8 to 10. Internally we were using java function to to get the data.

In java function we have a resultset object, if we assign this resultset value to Querytable variable, we are getting below error. This code was working fine in coldfusion 8.

 

Detail    This exception is usually caused by service startup failure. Check your server configuration.

Message    The Runtime service is not available.

StackTrace    coldfusion.server.ServiceFactory$ServiceNotAvailableException: The Runtime service is not available. at coldfusion.server.ServiceFactory.getRuntimeService(ServiceFactory.java:117) at coldfusion.runtime.RequestMonitor.<clinit>(RequestMonitor.java:14) at coldfusion.sql.QueryTable.populate(QueryTable.java:358) at coldfusion.sql.QueryTable.populate(QueryTable.java:283) at coldfusion.sql.QueryTable.<init>(QueryTable.java:96) at com.myCompany.myClass.myFunct(myClass.java:627) at

 

Here is the function which is causing error.

static private QueryTable myFunct(String userId, SessionFactory sf) {

        PreparedStatement pStmt = null;

        ResultSet rs = null;

        QueryTable ret = null;

         try{

            Query q = sf.getCurrentSession().getNamedQuery("ListUsers");

            pStmt = sf.getCurrentSession().connection().prepareStatement(q.getQueryString());

            rs = pStmt.executeQuery();// works fine till here

            ret = new QueryTable(rs);  // error line         

            rs.close();

        }catch(Exception e){

            e.printStackTrace();

            throw new RuntimeException(e.getLocalizedMessage());

        }

        return ret;

    }

Can you provide some help on this. Please let me know if you need any other details.

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
April 8, 2014

This code seems to mix the Java and ColdFusion idioms. To make it work, you have to familiarize Java with ColdFusion's QueryTable object. The usual way to do this is to initially include cfusion.jar in the classpath and then introduce the line import coldfusion.sql.QueryTable; in the code that defines the class in question.

April 8, 2014

Thanks BKBK.  We have already done that.

Included cfusion.jar in the classpath and introduced the line import coldfusion.sql.QueryTable

BKBK
Community Expert
Community Expert
April 8, 2014

OK. What about installing the latest Java Development Kit (JDK), linking it with ColdFusion and testing?