weblogicme
asked on
Getting ClassNotFoundException for external java method stored procedure in weblogic
Please I need help in this desperately. Struggling with this NoClassDefFoundError :(
Created a portal web project (sampleWeb) with the following -
And created a test.jsp with the following contents -
Then added pbembedded57.jar into web projects "Add external Jar's Library" and built the project.
When I hit the page, http://localhost:7001/sampleWeb/faces/test.jsp
INFO: Initializing Mojarra (1.2_09-20081212-SNAPSHOT) for context '/sampleWeb'
DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundEx ception: DBLog"
at com.pointbase.net.netJDBCP rimitives. handleResp onse(Unkno wn Source)
at com.pointbase.net.netJDBCP rimitives. handlePrim itiveRespo nse(Unknow n Source)
at com.pointbase.net.netJDBCP reparedSta tement.exe cute(Unkno wn Source)
at net.local.util.common.DBLo g.logPreAu th(DBLog.j ava:65)
......
Also FYI, there were following 2 build warnings,
Classpath entry E:/Oracle/Middleware/wlser ver_10.3/c ommon/eval /pointbase /lib/pbemb edded57.ja r will not be exported or published. Runtime ClassNotFoundExceptions may result.
The import com.pointbase.jdbc is never used
Then tried adding "net.local.util.common.DBL og" to EXTERNAL NAME as follows,
EXTERNAL NAME \"net.local.util.common.DB Log::insLo g\" but now I got the error,
DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "net.local.util.common.DBL og::insLog " routine had the following runtime exception "java.lang.ClassNotFoundEx ception: net.local.util.common.DBLo g"
at com.pointbase.net.netJDBCP rimitives. handleResp onse(Unkno wn Source)
......
Then I tried adding the following classpath entry to startPointbase.cmd,
@REM Add PointBase classes to the classpath
SET CLASSPATH=E:\Oracle\Middle ware\user_ projects\W orkspaces\ DBLog\samp leWeb\src\ net\local\ util\commo n;%POINTBA SE_CLASSPA TH%;%WEBLO GIC_CLASSP ATH%
Now I got the error,
DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "net.local.util.common.DBL og::insLog " routine had the following runtime exception "java.lang.ClassNotFoundEx ception: net.local.util.common.DBLo g"
at com.pointbase.net.netJDBCP rimitives. handleResp onse(Unkno wn Source)
......
I also tried classpath "E:\Oracle\Middleware\user _projects\ Workspaces \DBLog\sam pleWeb\src " and again same above error.
Also tried adding external class folder in Libraries tab of Java build path. Still same above error.
I will be extremely thankful for any help.
Created a portal web project (sampleWeb) with the following -
package net.local.util.common;
import java.sql.*;
import com.bea.netuix.transformer.openfoundation.util.XPSystem.Out;
import com.pointbase.jdbc.*;
public class DBLog {
private Connection conn = null;
private Statement m_stmt;
private Statement l_stmt;
private CallableStatement m_callStmt = null;
public DBLog() {
Out.Write("DBLog constructor called");
}
public void logPreAuth() {
try {
Out.Write("Inside logPreAuth");
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();
Out.Write("SP created");
m_callStmt = conn.prepareCall("{ call PBPUBLIC.insLog(?) }");
m_callStmt.setString(1, "Success!!");
m_callStmt.execute();
Out.Write("SP executed");
}
catch (Exception e) {
e.printStackTrace();
}
}
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) {
e.printStackTrace();
}
}
}
And created a test.jsp with the following contents -
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
import="net.local.util.common.DBLog"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test</title>
</head>
<body>
<%
DBLog dblog = new DBLog();
dblog.logPreAuth();
%>
</body>
</html>
Then added pbembedded57.jar into web projects "Add external Jar's Library" and built the project.
When I hit the page, http://localhost:7001/sampleWeb/faces/test.jsp
INFO: Initializing Mojarra (1.2_09-20081212-SNAPSHOT)
DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundEx
at com.pointbase.net.netJDBCP
at com.pointbase.net.netJDBCP
at com.pointbase.net.netJDBCP
at net.local.util.common.DBLo
......
Also FYI, there were following 2 build warnings,
Classpath entry E:/Oracle/Middleware/wlser
The import com.pointbase.jdbc is never used
Then tried adding "net.local.util.common.DBL
EXTERNAL NAME \"net.local.util.common.DB
DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "net.local.util.common.DBL
at com.pointbase.net.netJDBCP
......
Then I tried adding the following classpath entry to startPointbase.cmd,
@REM Add PointBase classes to the classpath
SET CLASSPATH=E:\Oracle\Middle
Now I got the error,
DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "net.local.util.common.DBL
at com.pointbase.net.netJDBCP
......
I also tried classpath "E:\Oracle\Middleware\user
Also tried adding external class folder in Libraries tab of Java build path. Still same above error.
I will be extremely thankful for any help.
ASKER
Tried like this,
EXTERNAL NAME \"net.local.util.common.DB Log.insLog \"
And got,
java.sql.SQLException: The routine name "null" does not contain a "::" to delimit the method name.
Tried like this,
EXTERNAL NAME \"net.local.util.common.DB Log.insLog ::insLog\"
And got,
java.sql.SQLException: The external "net.local.util.common.DBL og.insLog: :insLog" routine had the following runtime exception "java.lang.ClassNotFoundEx ception: net.local.util.common.DBLo g.insLog"
Tried like this,
EXTERNAL NAME \"net.local.util.common.DB Log::insLo g\"
And got,
java.sql.SQLException: The external "net.local.util.common.DBL og::insLog " routine had the following runtime exception "java.lang.ClassNotFoundEx ception: net.local.util.common.DBLo g"
As you said, I changed my code and splitted it as follows,
Still I got the error as,
java.sql.SQLException: The external "DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundEx ception: DBLog"
And I can see from logs, till "SP Created" its going fine, and then after that its throwing error. Also checked in pointbase DB and found insLog routine is listed.
EXTERNAL NAME \"net.local.util.common.DB
And got,
java.sql.SQLException: The routine name "null" does not contain a "::" to delimit the method name.
Tried like this,
EXTERNAL NAME \"net.local.util.common.DB
And got,
java.sql.SQLException: The external "net.local.util.common.DBL
Tried like this,
EXTERNAL NAME \"net.local.util.common.DB
And got,
java.sql.SQLException: The external "net.local.util.common.DBL
As you said, I changed my code and splitted it as follows,
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 static Connection conn = null;
private static Statement m_stmt;
private static Statement l_stmt;
private static CallableStatement m_callStmt = 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.jdbcUniversalDriver");
conn = DriverManager.getConnection(I_URL, "PBPUBLIC", "PBPUBLIC");
doCreateProc();
doInvokeProc();
}
catch (Exception e) {
logger.error("Error in logforSSP method" + e);
}
finally {
if (m_stmt != null) {
try {
m_stmt.close();
}
catch (Exception e) {
logger.info("Exception" + e);
}
}
if (m_callStmt != null) {
try {
m_callStmt.close();
}
catch(Exception e) {
logger.info("Exception: " + e);
}
}
if (conn != null) {
try {
conn.close();
}
catch(Exception e) {
logger.info("Exception :" + e);
}
}
}
}
public static void doCreateProc() throws SQLException {
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();
logger.info("SP Created");
}
public static void doInvokeProc() throws SQLException
{
m_callStmt = conn.prepareCall("{ call PBPUBLIC.insLog(?) }");
m_callStmt.setString(1, "Success!!");
m_callStmt.executeUpdate();
logger.info("SP executed");
//l_rs = l_stmt.executeQuery("Insert into logs values('" + test + "')");
//l_stmt.executeUpdate("Insert into logs values('" + test + "')");
}
public static void insLog(String test) {
try {
l_stmt = conn.createStatement();
l_stmt.execute("Insert into logs values('" + test + "')");
//l_rs.close();
l_stmt.close();
}
catch(SQLException e){
logger.info("SQL Exception: " + e);
}
finally {
if (l_stmt != null) {
try{
l_stmt.close();
}
catch(Exception e) {
logger.info("Exception: " + e);
}
}
}
}
}
Still I got the error as,
java.sql.SQLException: The external "DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundEx
And I can see from logs, till "SP Created" its going fine, and then after that its throwing error. Also checked in pointbase DB and found insLog routine is listed.
ASKER
Its really strange. I followed the steps given in the below documentation on setting the classpath and still same error!
http://docs.oracle.com/cd/E19253-01/817-7465/817-7465.pdf
As they mentioned in that doc. under the section "Using JAR and ZIP files" in page 10, I updated pbembedded75.jar with DBLog.class package as follows,
jar -uf pbembedded57.jar net
In the above command, "net" is the folder package structure having DBLog.class inside it.
Verified whether commEnv.cmd is having right classpath and found the below,
set POINTBASE_CLASSPATH=C:\bea \user_proj ects\works paces\What sNext\What sNextUtili ty\build\c lasses;%PO INTBASE_HO ME%\lib\pb embedded57 .jar;%POIN TBASE_CLIE NT_CLASSPA TH%
To make sure, I checked the console window while admin server is running, and it outputted the following,
echo CLASSPATH=;C:\bea\patch_wl w1030\prof iles\defau lt\sys_man ifest_clas spath\webl ogic_patch .jar;C:\be a\patch_wl s1030\prof iles\defau lt\sys_man ifest_clas spath\webl ogic_patch .jar;C:\be a\patch_wl p1030\prof iles\defau lt\sys_man ifest_clas spath\webl ogic_patch .jar;C:\be a\patch_ci e670\profi les\defaul t\sys_mani fest_class path\weblo gic_patch. jar;C:\bea \JDK160~1\ lib\tools. jar;C:\bea \WLSERV~1. 3\server\l ib\weblogi c_sp.jar;C :\bea\WLSE RV~1.3\ser ver\lib\we blogic.jar ;C:\bea\mo dules\feat ures\weblo gic.server .modules_1 0.3.0.0.ja r;C:\bea\W LSERV~1.3\ server\lib \webservic es.jar;C:\ bea\module s\ORGAPA~1 .5/lib/ant -all.jar;C :\bea\modu les\NETSFA ~1.0_1/lib /ant-contr ib.jar;;C: \bea\user_ projects\w orkspaces\ WhatsNext\ WhatsNextU tility\bui ld\classes ;C:\bea\WL SERV~1.3\c ommon\eval \pointbase \lib\pbemb edded57.ja r;C:\bea\W LSERV~1.3\ common\eva l\pointbas e\lib\pbcl ient57.jar ;C:\bea\WL SERV~1.3\s erver\lib\ xqrl.jar;C :\bea\WLSE RV~1.3\ser ver\lib\xq uery.jar;C :\bea\WLSE RV~1.3\ser ver\lib\bi nxml.jar;;
So pbembedded57.jar file is having DBLog.class and also my classpath is pointing to it.
Now I tried both the ways of calling EXTERNAL NAME \"DBLog::insLog\" as well as EXTERNAL NAME \"net.verizon.whatsnext.ut il.common. DBLog::ins Log\" , and the result was the same error.
http://docs.oracle.com/cd/E19253-01/817-7465/817-7465.pdf
As they mentioned in that doc. under the section "Using JAR and ZIP files" in page 10, I updated pbembedded75.jar with DBLog.class package as follows,
jar -uf pbembedded57.jar net
In the above command, "net" is the folder package structure having DBLog.class inside it.
Verified whether commEnv.cmd is having right classpath and found the below,
set POINTBASE_CLASSPATH=C:\bea
To make sure, I checked the console window while admin server is running, and it outputted the following,
echo CLASSPATH=;C:\bea\patch_wl
So pbembedded57.jar file is having DBLog.class and also my classpath is pointing to it.
Now I tried both the ways of calling EXTERNAL NAME \"DBLog::insLog\" as well as EXTERNAL NAME \"net.verizon.whatsnext.ut
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I see. So does Oracle Express has a database in which I can create Stored procedures and call from java? The point is I need to test my local java code setup and see if I am able to make jdbc call to Oracle SP.
So if Oracle Express has a database feature I can connect to, then I can very well try it.
Please suggest. Thanks
So if Oracle Express has a database feature I can connect to, then I can very well try it.
Please suggest. Thanks
As far as I know any Oracle supports Java stored procedure
And the way I tried was that I used lodjava command
In general I think you need to have a good reason to use Java Stored Procedure, don't see wvery manty cases where you would not be able to use JDBC + PL/SQL procedures instaed
And the way I tried was that I used lodjava command
In general I think you need to have a good reason to use Java Stored Procedure, don't see wvery manty cases where you would not be able to use JDBC + PL/SQL procedures instaed
ASKER
Using oracle database client, is it possible to create a local test database, so that I can create stored procedures in it?
Yes, with Oracle Express you can create the oracke database right on your local machine and then you should be able to create your schem and load java stored proceduure in that schema.
ASKER
No, I mean do I need to install database or client is sufficient? But I dont think I can create a database im my local system using client, right?
No, you need to download and instal Oracle Express database - this is of course not a client but quite separate product - it is the database which is limited in size and connections but otherwise it has Oracle database functionality and it is free.
And it makes much more sense than pointbase as everything you would develop with it is transferable to any oracle database.
And it makes much more sense than pointbase as everything you would develop with it is transferable to any oracle database.
EXTERNAL NAME 'net.local.util.common.DBL
I was also thinking that you need to have a static method to be able
to stotr in Java Stored Procedure
Another thing, I'd suggest to split these two tasks - make one piece of code which
would create java stored procedure - then you can check at the sql prompt if such
stored procedure was created and exists.
Then run a separate code which will have tested its operation