[英]How to correctly develop, upload java library with dependencies to Oracle DB and call my Java function from PL\SQL?
I have:我有:
What i did:我做了什么:
I write simple class with one method in Java 8.我用 Java 8 中的一种方法编写了简单的 class。
package <mypackage>;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import com.networknt.schema.ValidationMessage;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.Set;
import java.util.stream.Collectors;
public class <classname> {
<some simple validation function>
}
I compile my project with maven and maven-assembly-plugin
to build .jar
file with dependencies.我使用 maven 和maven-assembly-plugin
编译我的项目以构建具有依赖项的.jar
文件。
I upload it with loadtool
: loadjava -f -r -v -synonym -oracleresolver -resolve -grant <user> -thin -user <credentials> <filename>.jar
我用loadtool
上传它: loadjava -f -r -v -synonym -oracleresolver -resolve -grant <user> -thin -user <credentials> <filename>.jar
There were 0 errors during upload.上传过程中出现 0 个错误。 All uploaded classes (including dependencies) have 'VALID' status in dba_objects
table.所有上传的类(包括依赖项)在dba_objects
表中都具有“有效”状态。
I write PL/SQL wrapper over my Java function.我在我的 Java function 上编写 PL/SQL 包装器。
create FUNCTION <funcname>(P_IN_BODY_TEXT CLOB, P_IN_BODY_SCHEMA_TEXT CLOB)
RETURN VARCHAR2
AS LANGUAGE JAVA NAME '<packagename>.<classname>.<funcname>(java.sql.Clob, java.sql.Clob) return java.lang.String';
/
I use this function in my ORDS REST Service.我在我的 ORDS REST 服务中使用这个 function。
When doing request to ORDS i am getting this exception:在向 ORDS 提出请求时,我收到了这个异常:
The request could not be processed because an error occurred whilst attempting to evaluate
the SQL statement associated with this resource.
Please check the SQL statement is correctly formed and executes without error. SQL Error Code: 29532,
Error Message: ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NoClassDefFoundError ORA-06512: at <rest stacktrace that gives me nothing>
Quiestion is:问题是:
What is root of this problem?这个问题的根源是什么? By -synonym
flag tool creates synonyms for me, all classes is valid.通过-synonym
标志工具为我创建同义词,所有类都是有效的。 Do i need some permisions to use java packages liike java.sql
that in my class imports?我是否需要一些权限才能使用java.sql
中的 java 包? I upload some others open sources java libraries into my Oracle, but they doesn't hava dependencies - is that the problem?我将其他一些开源 java 库上传到我的 Oracle 中,但它们没有依赖关系 - 这是问题吗?
Problem was in slf4j
library that throws this exception.问题出在引发此异常的slf4j
库中。 slf4j
was dependency of library that i used. slf4j
是我使用的库的依赖项。 Didn't dig the problem, I just pick another labrary with less dependencies and its works.没有挖掘问题,我只是选择了另一个依赖较少的实验室及其工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.