java - ORA-29532 : Java call terminated by uncaught Java exception: java. lang.NoClassDefFoundError

标签 java oracle plsql oracle-sqldeveloper noclassdeffounderror

在 sql Developer 中运行以下代码时出现以下错误:

创建java源代码-

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED demoskr1 AS
package ScreenShot;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.*;

class demoskr1
{
public static void main(String args[]) throws Exception
{
  try{      
                            Thread.sleep(5000);
                            Robot awt_robot = new Robot();
                            String path = "C:\\Users\\pbafna\\workspace\\shot.jpg"; 
                            BufferedImage Entire_Screen = awt_robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
                            ImageIO.write(Entire_Screen, "jpg", new File(path));
                            System.out.println("Screenshot saved");
 }
  catch (Exception e) {
              System.out.println("Something went wrong.");
                  }   
  }
  };

创建过程-

create or replace procedure proc_capture 
as 
 language Java 
 name 'demoskr1.main(java.lang.String[])';

运行程序-

 begin
  proc_capture();
  end;

运行后我收到以下错误:

ORA-29532: Java call terminated by uncaught Java exception: java.lang.NoClassDefFoundError
ORA-06512: at "XXOSC.PROC_CAPTURE", line 1
ORA-06512: at line 2
29532. 00000 -  "Java call terminated by uncaught Java exception: %s"
*Cause:    A Java exception or error was signaled and could not be
           resolved by the Java code.
*Action:   Modify Java code, if this behavior is not intended.

最佳答案

您正在使用java.awt.Robot它需要图形、非 headless 环境才能正常工作,而数据库服务器不提供它。根据User Interfaces on the Server Oracle 文档:

Oracle Database furnishes all core Java class libraries on the server, including those associated with presentation of the user interfaces. However, it is inappropriate for code running on the server to attempt to materialize or display a user interface on the server. Users running applications in Oracle JVM environment should not be expected nor allowed to interact with or depend on the display and input hardware of the server where Oracle Database is running.

关于java - ORA-29532 : Java call terminated by uncaught Java exception: java. lang.NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54925564/

相关文章:

sql - PLSQL 脚本不改变表?

java - 从Java中的方法返回int值

java - JPA @OneToOne关系删除

mysql - MySQL/MariaDB 中 PERCENTILE_CONT 的替代方案

java - Oracle SQL 在由逗号分隔的许多值组成的一列中选择特定值

sql - SQL 中的无序结果

oracle - DBMS_UTILITY.COMPILE_SCHEMA(schema => '<SCHEMA_NAME>' ,compile_all => FALSE) 不编译无效的包体

java - System.out 到 Windows 上的 Unix 行结尾

java - 将 JSONArray 发布到 REST 服务

PLSQL:VARBIABLE:= SEQUENCE.NEXTVAL或SELECT SEQUENCE.NEXTVAL从对偶转换为VARIABLE?