当我尝试从weblogic执行Pointbase中的存储过程时,我收到以下错误。
java.sql.SQLException: The external "DbLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: DbLog"
所以我在commEnv.cmd中设置了类路径,如下所示,
set POINTBASE_HOME=%WL_HOME%\common\eval\pointbase
set POINTBASE_CLIENT_CLASSPATH=%POINTBASE_HOME%\lib\pbclient57.jar
set POINTBASE_CLASSPATH=%POINTBASE_HOME%\lib\pbembedded57.jar;%POINTBASE_CLIENT_CLASSPATH%;C:\bea\user_projects\workspaces\work1\utility\build\classes
set POINTBASE_TOOLS=%POINTBASE_HOME%\lib\pbtools57.jar
我的DbLog类位于路径中,C:\ bea \ user_projects \ workspaces \ Work1 \ util \ build \ classes \ net \ local \ util \ common FYI,net \ local \ util \ common是包结构。< / p>
但是当我尝试执行调用RequestFilter.java的页面时,我收到以下错误,
Error 500--Internal Server Error
java.lang.NoClassDefFoundError: Could not initialize class net.local.util.common.DbLog
- RequestFilter.java
import net.local.util.common.DbLog;
public final class RequestFilter {
public void log() {
DbLog dblog = new DbLog();
dblog.logPreAuth();
}
}
- DbLog.java
package net.local.util.common;
import java.sql.*;
import org.apache.log4j.Logger;
import com.pointbase.jdbc.*;
public class DbLog {
private static final Logger logger = Logger.getLogger(DbLog.class);
private static boolean DEBUGGING = logger.isDebugEnabled();
private Connection conn = null;
private Statement m_stmt;
private Statement l_stmt;
private CallableStatement m_callStmt = null;
//static ResultSet l_rs = null;
public DbLog() {
logger.info("DbLog constructor called");
init();
}
public void init() {
logger.info("DbLog init called");
}
public void logPreAuth() {
try {
logger.info("Inside logPreAuth method");
String I_URL = "jdbc:pointbase:server://localhost:9093/weblogic_eval";
Class.forName("com.pointbase.jdbc.jdbcUniversalDriver").newInstance();
//Class.forName("com.pointbase.jdbc.jdbcDataSource");
conn = DriverManager.getConnection(I_URL, "PBPUBLIC", "PBPUBLIC");
String SQL_CREATE_PROC = "CREATE PROCEDURE insLog(IN P1 VARCHAR(30))"
+ " LANGUAGE JAVA"
+ " SPECIFIC insLog"
+ " DETERMINISTIC"
+ " NO SQL"
+ " EXTERNAL NAME \"DbLog::insLog\""
+ " PARAMETER STYLE SQL";
m_stmt = conn.createStatement();
m_stmt.executeUpdate(SQL_CREATE_PROC);
m_stmt.close();
m_callStmt = conn.prepareCall("{ call PBPUBLIC.insLog(?) }");
m_callStmt.setString(1, "Success!!");
m_callStmt.execute();
}
catch (Exception e) {
logger.error("Error in logPreAuth method" + e);
}
}
public void insLog(String test)
{
try {
l_stmt = conn.createStatement();
l_stmt.execute("Insert into logs values('" + test + "')");
l_stmt.close();
conn.close();
}
catch (Exception e) {
}
}
}
答案 0 :(得分:0)
java.lang.NoClassDefFoundError:无法初始化类net.local.util.common.DbLog
这基本上意味着Class.forName("net.local.util.common.DbLog")
因异常而失败。这可能反过来意味着所讨论的类的任何static
变量或初始化程序块都抛出了未处理的异常。它们即在类加载期间执行。
你在班上有两个人:
private static final Logger logger = Logger.getLogger(DbLog.class);
private static boolean DEBUGGING = logger.isDebugEnabled();
他们中的任何一个都因此抛出异常。它的堆栈跟踪在日志中可以进一步显示。返回读取日志并检查堆栈跟踪的最底层异常。这是第一个根本原因。应该足够自我解释。也许运行时类路径中缺少Log4j。