Runtime exception java.lang.ClassNotFoundException on executing Stored Proc
I am getting the below error when I try to execute a stored proc in Pointbase from weblogic.
java.sql.SQLException: The external "DbLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: DbLog"
So I setted the classpath in commEnv.cmd as follows,
set POINTBASE_HOME=%WL_HOME%\common\eval\pointbase
set POINTBASE_CLIENT_CLASSPATH=%POINTBASE_HOME%\lib\pb client57.jar
set POINTBASE_CLASSPATH=%POINTBASE_HOME%\lib\pbembedde d57.jar;%POINTBASE_CLIENT_CLASSPATH%;C:\bea\user_p rojects\workspaces\work1\utility\build\classes
set POINTBASE_TOOLS=%POINTBASE_HOME%\lib\pbtools57.jar
My DbLog class is in the path, C:\bea\user_projects\workspaces\Work1\util\build\c lasses\net\local\util\common FYI, net\local\util\common is the package structure.
But when I try to execute the page which calls RequestFilter.java, I am getting the following error,
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
...
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
...
And when I refresh the page,
java.lang.NoClassDefFoundError: Could not initialize class net.verizon.whatsnext.util.common.DbLog
So before setting classpath, atleast it was going inside DbLog. Now its not at all instantiating DbLog class.
--RequestFilter.java
Code:
import net.local.util.common.DbLog;
public final class RequestFilter {
public void log() {
DbLog dblog = new DbLog();
dblog.logPreAuth();
}
}
--DbLog.java
Code:
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) {
}
}
}
Please help !
Re: Runtime exception java.lang.ClassNotFoundException on executing Stored Proc
Since you have got quite a lot of help over at OTN do you not think it might be an idea to provide a link to the thread there?
Re: Runtime exception java.lang.ClassNotFoundException on executing Stored Proc
Please find the entire code at https://forums.oracle.com/forums/thr...55663&tstart=0
Please suggest. Thanks
Re: Runtime exception java.lang.ClassNotFoundException on executing Stored Proc
I read the pointbase documentation at, http://docs.oracle.com/cd/E19518-01/...4/817-7464.pdf
And it says,
In order for the database to access this external Java method, the class SampleExternalMethods
must be included in the database CLASSPATH. For PointBase Embedded - Server Option, it
must be in the Server CLASSPATH, but not in the Client CLASSPATH.
The java method can be static or non-static. If it is non-static, connection object will be
established during function invocation, so a non-static member variable of java.sql.connection
and a constructor having parameter java.sql.connection needs to be implemented. If it is static,
the method is called directly and no connection object will be established during function
invocation.
I setted the POINTBASE_CLASSPATH as mentioned in my previous posts but of no use. Did i miss anything?
Should I create a constructor with a connection parameter? But it says, if java method is static, then no connection object will be established during function invocation. Does this mean, no constructor with connection parameter is needed for static java method too?