Flex - 'Cannot create class of type' error RemoteObject

635 Views Asked by At

I have the following Java class RemoteDBAccess inside validator package as follows. Basically, the function inside the class takes a string as an input and returns a string valid or invalid as output:

    public class RemoteDBAccess {

    public String Validator(String input)
    {
        String Output = "";
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try
        {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        String connectionUrl = "jdbc:mysql://ctovm1873.dev.spotlight.com:3306/ttds";
        String connectionUser = "root";
        String connectionPassword = "root";
        conn = DriverManager.getConnection(connectionUrl, connectionUser, connectionPassword);
        stmt = conn.createStatement();
        int rowcount = 0;

            if(input.startsWith("CHG"))
            {
                rs = stmt.executeQuery("Select * from rm_projectrepository_gen where snow_change_id like '" + input + "'");
                while (rs.next() != false) {
                     ++rowcount;
                    }
            }
            else
            {
                rs = stmt.executeQuery("Select * from rm_projectrepository_gen where idRM_ProjectRepository_Gen like '" + input + "'");
                while (rs.next() != false) {
                     ++rowcount;
                    }
            }
            if(rowcount == 0)
            {
            Output = "invalid";
            }
            else{
                Output = "valid";
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        return Output;
    }

}

In the remoting-config.xml file, I have added the destination for my RemoteObject as follows:`

<destination id="RemoteDBAccess">
<properties>
<source>validator.RemoteDBAccess</source>
</properties>
<adapter ref="java-object"/>
</destination>

Inside my flex code, I have created the RemoteObject as follows:<mx:RemoteObject id="BeforeWithAfterValidator" destination="RemoteDBAccess" source="validator.RemoteDBAccess" result="Alert.show(event.result.toString());" fault="Alert.show(event.fault.faultString);"/>

Now, when I use the following piece of code to call the remote method:

    var Data:String = "1239";
Alert.show(BeforeWithAfterValidator.Validator(Data));

The alert box displays: Cannot create class of type 'validator.RemoteDBAccess'.

Please help me with the issue.

1

There are 1 best solutions below

0
Ruchir Sharma On

I went inside the WEB-INF/classes folder of my Tomcat installation and created a folder named validator, inside which I put my RemoteDBAccess.class file(that justified the source for my RemoteObject(validator.RemoteDBAccess). Afterwards, restarted the Tomcat server, re-built my flex code and it worked.