i am having a problem executing a java object from a coldfusion page. i
have a java program which on the server when run from command line is
as follows:
java ShortestPath 0 3232

and this outputs the shortest route between 0 and 3232

i am trying to send those values from coldfusion page but the result im
getting is undefined.

attached is the program, and below if the coldfusion page and the java
class im trying to call:

i want to call it from a coldfusion page as below:

<cfobject
action="create"
type = "java"
class = "ShortestPath"
name = "shortPath">

<cfscript>
<cfset cfarg = JavaCast("String", "")>
myString1 = JavaCast("String", #pcsid.node_id#);
myString2 = JavaCast("String", #pceid.node_id#);
result = "Empty result";
result = shortPath.showPath(cfarg, myString1, myString2);
</cfscript>

result is undefined in cfm page,
the program works when i giv it input from cmd, why not here?

class is:
ShortestPath.java

method is like:
public String showPath(String start, String end) { .......}

i have had a look at the live docs and even changed the way the object
is called as below, but still doesnt work:

<cfset result ="Empty result">
<!--- create an object based on the ShortestPath class --->
<cfset myObject = createObject( "java", "ShortestPath" ) >
<cfset cfarg = JavaCast("String", "")>
<cfset myString1 = JavaCast("String", #pcsid.node_id#)>
<cfset myString2 = JavaCast("String", #pceid.node_id#)>

<!--- call the method and store the result in a variable. --->
<cfset result = myObject.showPath(cfarg,myString1, myString2) >

<!--- Print the value of the variable. --->
<cfoutput>The result is: #result#</cfoutput>

here is the java class itself:
import java.sql.ResultSet;

/*************************************************************************
 *  Compilation:  javac ShortestPath.java
 *  Execution:    java ShortestPath
 *  Dependencies: EuclideanGraph.java Dijkstra.java In.java StdIn.java
Turtle.java
 *
 *  Reads in a map from a file, and two integers s and d from standard
input,
 *  and plots the shortest path from s to d in autodesk mapguide
through javascript
 *  on coldfusion page.
 *
 *  % java ShortestPath 0 5000
 *

****************************************************************************/

public class ShortestPath {

    public static void main(String[] args) {

         ShortestPath sp=new ShortestPath();
         String arg="";
         if (args.length>0) arg=args[0];
         System.out.println("args len = "+arg.length());
         String first = args[0];
   String second = args[1];
         System.out.println(sp.showPath(arg,first,second));
    }
   // public String cfinput(String arg1,String arg2)
    //     {
              //return arg1;
              //return arg2;

         ///}
    /**
     * Returns path in String
     * @param Start startPoint from #cfinput#
     * @param end endPoint from #cfinput# hopefully!
     * @return String with path
     */
    public String showPath(String arg, String start, String end) {

        // read in the graph from a database
        EuclideanGraph G=null;
       if (arg.length()<2)
       {
             //System.out.println("args len = "+arg.length());
             int V=0;
             int E=0;
             MSSQLAccess da= new MSSQLAccess();
               da.openCon(da.url, da.user, da.password); // it's in
class variables now
               try {
                    ResultSet rs;

                    rs = da.stmt.executeQuery("select count(*) from
bradNodesXY");
                    if (rs.next()) V=rs.getInt(1);
                    rs.close();

                    rs = da.stmt.executeQuery("select count(*) from
bradEdges where status=0");
                    if (rs.next()) E=rs.getInt(1);
                    rs.close();

            // read in and insert vertices
            Point []points = new Point[V];
               rs = da.stmt.executeQuery("select id,x,y from
bradNodesXY");
            for (int i = 0; i < V&&rs.next(); i++)
            {
                int v = rs.getInt(1);
                int x = rs.getInt(2);
                int y = rs.getInt(3);
                if (v < 0 || v >= V) throw new
RuntimeException("Illegal vertex number");
                points[v] = new Point(x, y);
            }
            rs.close();

            // read in and insert edges
            EuclideanGraph.Node[] adj = new EuclideanGraph.Node[E];
               rs = da.stmt.executeQuery("select start_node, end_node
from bradEdges where status=0");
            for (int i = 0; i < E&&rs.next(); i++) {
                int v = rs.getInt(1);
                int w = rs.getInt(2);

                if (v < 0 || v >= V) throw new
RuntimeException("Illegal vertex number");
                if (w < 0 || w >= V) throw new
RuntimeException("Illegal vertex number");
                adj[v] = new EuclideanGraph.Node(w, adj[v]);
                adj[w] = new EuclideanGraph.Node(v, adj[w]);
            }

            int nodes = V;//StdIn.readInt();
             int edges = E;

            G=new EuclideanGraph(V,E,points,adj);

               } catch (Exception e){
                    return e.getMessage();
               }
        }
        if (arg.length()>2){
          In graphin = new In(arg);
        G = new EuclideanGraph(graphin);

        }

        //System.err.println("Done reading the graph " + arg[0]);

        Dijkstra dijkstra = new Dijkstra(G);

        int s = Integer.parseInt(start);//StdIn.readInt();
        int d = Integer.parseInt(end);//StdIn.readInt();

        String result="";
        result=dijkstra.showPath(s, d);
        return result;

    }

}

here is the stack trace from my coldfusion page:
at cfpath2ecfm488286674.runPage(C:\Documents and
Settings\Administrator\My Documents\aaRouteFinder\Web\path.cfm:169)


coldfusion.runtime.UndefinedVariableException: Variable RESULT is
undefined.
at coldfusion.runtime.CfJspPage._get(CfJspPage.java:216)
at coldfusion.runtime.CfJspPage._autoscalarize(CfJspPage.java:916)
at cfpath2ecfm488286674.runPage(C:\Documents and
Settings\Administrator\My Documents\aaRouteFinder\Web\path.cfm:169)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
at
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:24)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
at
coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
at
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.CfmServlet.service(CfmServlet.java:105)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:192)
at
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
at
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)



somebody please help with this error, do you think i cant execute it
successfully from cfm page because i have to get database values from
another class in java program???
if so, what are the possible solutions??


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---

Reply via email to