I'm having some problems trying to execute java loaded in the database from PL/SQL. The java code written in Eclipse (which needs a single jar file) works fine. I can load this into the database with the jar and everything seems to resolve and the class status of all code is VALID. However when I write the PL/SQL wrapper function I get ORA-29532 java.lang.NoClassDefFoundError. When I remove the method private static BraintreeGateway gateway = new BraintreeGateway from the code an reupload the call works suggesting that it cannot find The gateway class (although it is uploaded and the code must see it as it compiles OK
The java was uploaded with the command below with no errors and all classes loaded and checked to be valid.
loadjava -user nrdw/xxxxx@nressby -grant nrdw -resolve -R '((* NRDW) (* PUBLIC))' -oci8 ./src/hello.java ./lib/braintree-java-2.46.0.jar
Just to check I can call the class I created the below
create or replace FUNCTION gettest RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'hello.gettest() return java.lang.String';
select gettest from dual returns SQL Error: ORA-29532: Java call terminated by uncaught Java exception: java.lang.NoClassDefFoundError
As I said if I remove the Braintree references and reupload the I get "asdasd" from the call as expected.
I'm not sure why the Braintree classes are clearly there and compiled but then I get this error on execution. Any help please!
import com.braintreegateway.BraintreeGateway;
import com.braintreegateway.Environment;
public class hello {
private static BraintreeGateway gateway = new BraintreeGateway(
Environment.SANDBOX,
"7vb755cbfcvs828h",
"4x57rybz5t4wy944",
"09e10eb38dfac8c7237f47ebbb97bfd8");
public static void main(String[] args) {
System.out.println( gettoken( ));
}
public static String gettoken( ) { String b_token = gateway.clientToken( )
.generate( );
return b_token;
}
public static String gettest( ) { String b_test = "asdasd";
return b_test;
}
}