DERBY-5585: Improve error message when user function can't find class.

This patch was contributed by Danoja Dias (danojadias at gmail dot com)

Additional text is added to the 42x50 and 42x51 error messages suggesting
an additional possible cause of the error might be derby.database.classpath.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1754348 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/java/engine/org/apache/derby/loc/messages.xml b/java/engine/org/apache/derby/loc/messages.xml
index 5f12ec8..b041e84 100644
--- a/java/engine/org/apache/derby/loc/messages.xml
+++ b/java/engine/org/apache/derby/loc/messages.xml
@@ -1897,7 +1897,7 @@
 
             <msg>
                 <name>42X50</name>
-                <text>No method was found that matched the method call {0}.{1}({2}), tried all combinations of object and primitive types and any possible type conversion for any  parameters the method call may have. The method might exist but it is not public and/or static, or the parameter types are not method invocation convertible.</text>
+                <text>No method was found that matched the method call {0}.{1}({2}), tried all combinations of object and primitive types and any possible type conversion for any  parameters the method call may have. The method might exist but it is not public and/or static, or the parameter types are not method invocation convertible or the derby.database.classpath property is missing or incorrectly defined.</text>
                 <arg>className</arg>
                 <arg>methodName</arg>
                 <arg>parameterTypes</arg>
@@ -1905,7 +1905,7 @@
 
             <msg>
                 <name>42X51</name>
-                <text>The class '{0}' does not exist or is inaccessible. This can happen if the class is not public.</text>
+                <text>The class '{0}' does not exist or is inaccessible. This can happen if the class is not public or the derby.database.classpath property is missing or incorrectly defined.</text>
                 <arg>className</arg>
             </msg>
 
diff --git a/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java b/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
index 29cdef5..193b0c7 100644
--- a/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
+++ b/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
@@ -1014,6 +1014,8 @@
         bulkInsert();
         
         miscBugs();
+
+	classpathError();
     }
     
     /**
@@ -1144,6 +1146,46 @@
              "    from TABLE( invert( 1 ) ) s\n"
              );
     }
+
+	/**
+     * test for DERBY-5585
+     */
+    private void classpathError()
+        throws Exception
+    {
+        goodStatement
+            (
+             "create function foo( a int )\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "no sql\n" +
+             "external name 'Bop.doowop'\n"
+              );
+
+        
+        expectError
+            (
+             "42X51",
+             "values ( foo( 1 ) )"
+             );
+
+	goodStatement
+            (
+             "create function bar( a int )\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "no sql\n" +
+             "external name 'java.lang.Integer.doowop'\n"
+             );
+
+        expectError
+            (
+             "42X50",
+             "values ( bar( 1 ) )"
+             );
+     }
     
     /**
      * Verify that a simple VTI returns the correct results.