Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Unable to Find Methods of Java classes

Guest
Jun 26, 2006 Jun 26, 2006
I am using my own Java objects in ColdFusion. Whenever, I try to make an instance of my class, it gives me an error:
"Unable to find a constructor for class dssLogin that accepts parameters of type ( java.lang.String, java.lang.String ) ". Similar for any methods of this class.

I am compiling it using version 1.4 which is compatible to ColdFusion. I am using the following code in my class:
import java.sql.*;

class dssLogin
{
String username;
String password;
boolean status;
int site;
int patientCount;
String [] patientList;
String query;
int currentPatient;

dssLogin(String uname, String pword)
{
username = uname;
password = pword;
status = false;
site = -1;
patientCount = 0;
currentPatient = 0;
query = "select * from admin where username = '" + username + "' and password = '" + password + "'";
}

void verify()
{

}
}

I am using the following code in coldfusion
<cfset dssLog = createObject( "java", "dssLogin" ) >
<cfset user = #Form.username# >
<cfset pword = #Form.password# >
<cfset obj1 = dssLog.init(user, pword)>
<cfset obj2 = dssLog.verify()>
TOPICS
Getting started
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2006 Jun 27, 2006
Coldfusion should not do that. I've just compiled your Java code and instantiated dssLogin("un","pw") outside Coldfusion. No problems. It's one for the Coldfusion team to have a look at.



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2006 Jun 27, 2006
Do you need to use JavaCast on those string args prior to passing them to
the java method?

"Farrukh Mohisn" <webforumsuser@macromedia.com> wrote in message
news:e7pmq7$i35$1@forums.macromedia.com...
>I am using my own Java objects in ColdFusion. Whenever, I try to make an
> instance of my class, it gives me an error:
> "Unable to find a constructor for class dssLogin that accepts parameters
> of
> type ( java.lang.String, java.lang.String ) ". Similar for any methods of
> this
> class.
>
> I am compiling it using version 1.4 which is compatible to ColdFusion. I
> am
> using the following code in my class:
> import java.sql.*;
>
> class dssLogin
> {
> String username;
> String password;
> boolean status;
> int site;
> int patientCount;
> String [] patientList;
> String query;
> int currentPatient;
>
> dssLogin(String uname, String pword)
> {
> username = uname;
> password = pword;
> status = false;
> site = -1;
> patientCount = 0;
> currentPatient = 0;
> query = "select * from admin where username = '" + username + "' and
> password = '" + password + "'";
> }
>
> void verify()
> {
>
> }
> }
>
> I am using the following code in coldfusion
> <cfset dssLog = createObject( "java", "dssLogin" ) >
> <cfset user = #Form.username# >
> <cfset pword = #Form.password# >
> <cfset obj1 = dssLog.init(user, pword)>
> <cfset obj2 = dssLog.verify()>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 27, 2006 Jun 27, 2006
I have resolved the issue. Thanks to Jemski for giving me the hint.
However, this problem should not occur as I don't have any overloaded functions / Constructor. So, I modified the code in my Cold Fusion file as follow.

<cfset dssLog = createObject( "java", "dssLogin" ) >
<cfset user = #Form.username# >
<cfset pword = #Form.password# >
<cfset myuser = JavaCast("String", user)>
<cfset mypword = JavaCast("String", pword)>
<cfset obj2 = dssLog.verify(myuser, mypword)>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2006 Jun 27, 2006
>>Thanks to Jemski for giving me the hint.

no probs - I have seen this issue before.


"Farrukh Mohisn" <webforumsuser@macromedia.com> wrote in message
news:e7r51s$c7m$1@forums.macromedia.com...
>I have resolved the issue. Thanks to Jemski for giving me the hint.
> However, this problem should not occur as I don't have any overloaded
> functions / Constructor. So, I modified the code in my Cold Fusion file as
> follow.
>
> <cfset dssLog = createObject( "java", "dssLogin" ) >
> <cfset user = #Form.username# >
> <cfset pword = #Form.password# >
> <cfset myuser = JavaCast("String", user)>
> <cfset mypword = JavaCast("String", pword)>
> <cfset obj2 = dssLog.verify(myuser, mypword)>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2006 Jun 27, 2006
Erratum: <cfset obj2 = dssLog.verify(myuser, mypword)>
You, of course, mean <cfset obj2 = dssLog.init(myuser, mypword)>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2006 Jun 27, 2006
Javacast notwithstanding, it still looks fishy to me. I believe the Coldfusion team has to do something about it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 27, 2006 Jun 27, 2006
LATEST
I am still having problem with my class methods. For the same class, sometimes after compiling the code it executes fine, but on other times after little or no modification, the same function doesn't work. Even some functions work fine, but other do not for the same compilation. The error is as follow:

"The selected method "methodname" Not Found". Either there are no methods with the specified method name and argument types, or the method getStatus is overloaded with arguments types that ColdFusion can't decipher reliably. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity.

I don't have any overloaded functions.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources