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 -

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();
		
	}
	
}
	

} 

Open in new window


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>

Open in new window


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.ClassNotFoundException: DBLog"
      at com.pointbase.net.netJDBCPrimitives.handleResponse(Unknown Source)
      at com.pointbase.net.netJDBCPrimitives.handlePrimitiveResponse(Unknown Source)
      at com.pointbase.net.netJDBCPreparedStatement.execute(Unknown Source)
      at net.local.util.common.DBLog.logPreAuth(DBLog.java:65)
                   ......

Also FYI, there were following 2 build warnings,
Classpath entry E:/Oracle/Middleware/wlserver_10.3/common/eval/pointbase/lib/pbembedded57.jar 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.DBLog" to EXTERNAL NAME as follows,

 EXTERNAL NAME \"net.local.util.common.DBLog::insLog\"  but now I got the error,

DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "net.local.util.common.DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: net.local.util.common.DBLog"
      at com.pointbase.net.netJDBCPrimitives.handleResponse(Unknown Source)
                   ......

Then I tried adding the following classpath entry to startPointbase.cmd,
@REM Add PointBase classes to the classpath
SET CLASSPATH=E:\Oracle\Middleware\user_projects\Workspaces\DBLog\sampleWeb\src\net\local\util\common;%POINTBASE_CLASSPATH%;%WEBLOGIC_CLASSPATH%

Now I got the error,

DBLog constructor called
Inside logPreAuth
SP created
java.sql.SQLException: The external "net.local.util.common.DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: net.local.util.common.DBLog"
      at com.pointbase.net.netJDBCPrimitives.handleResponse(Unknown Source)
                   ......

I also tried classpath "E:\Oracle\Middleware\user_projects\Workspaces\DBLog\sampleWeb\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.
weblogicmeAsked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
I was thinking that Pointbase is a demonstration database which comes with Weblogic for some testing and demonstration purposes. Is there any point of using such specific features as java stored procedures with this kind of database?
Doesn't it make more sense to install at least Oracle Express which is free and do any debugging with Oracle which has much better organized support for java stored procedures, and ability to load java stored procedure say using loadjava command.
In general, even with Oracle I'd think that application of java stored procedures is rather limited - in many cases it  makes more sense to use JDBC in conjunction with PL/SQL procedures, rather than java stored procedures even in Oracle. I would rather go away from Pointbase, and espcially of such features as java stored procedures in this kind of database.
0
 
for_yanCommented:
Have you tried like that:

 EXTERNAL NAME 'net.local.util.common.DBLog.insLog'

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
0
 
weblogicmeAuthor Commented:
Tried like this,
EXTERNAL NAME \"net.local.util.common.DBLog.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.DBLog.insLog::insLog\"

And got,
java.sql.SQLException: The external "net.local.util.common.DBLog.insLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: net.local.util.common.DBLog.insLog"

Tried like this,
EXTERNAL NAME \"net.local.util.common.DBLog::insLog\"

And got,
java.sql.SQLException: The external "net.local.util.common.DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: net.local.util.common.DBLog"

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);
			}
		}
	}
}

}

Open in new window


Still I got the error as,

java.sql.SQLException: The external "DBLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: 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.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
weblogicmeAuthor Commented:
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_projects\workspaces\WhatsNext\WhatsNextUtility\build\classes;%POINTBASE_HOME%\lib\pbembedded57.jar;%POINTBASE_CLIENT_CLASSPATH%

To make sure, I checked the console window while admin server is running, and it outputted the following,

echo CLASSPATH=;C:\bea\patch_wlw1030\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\bea\patch_wls1030\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\bea\patch_wlp1030\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\bea\patch_cie670\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\bea\JDK160~1\lib\tools.jar;C:\bea\WLSERV~1.3\server\lib\weblogic_sp.jar;C:\bea\WLSERV~1.3\server\lib\weblogic.jar;C:\bea\modules\features\weblogic.server.modules_10.3.0.0.jar;C:\bea\WLSERV~1.3\server\lib\webservices.jar;C:\bea\modules\ORGAPA~1.5/lib/ant-all.jar;C:\bea\modules\NETSFA~1.0_1/lib/ant-contrib.jar;;C:\bea\user_projects\workspaces\WhatsNext\WhatsNextUtility\build\classes;C:\bea\WLSERV~1.3\common\eval\pointbase\lib\pbembedded57.jar;C:\bea\WLSERV~1.3\common\eval\pointbase\lib\pbclient57.jar;C:\bea\WLSERV~1.3\server\lib\xqrl.jar;C:\bea\WLSERV~1.3\server\lib\xquery.jar;C:\bea\WLSERV~1.3\server\lib\binxml.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.util.common.DBLog::insLog\" , and the result was the same error.
0
 
weblogicmeAuthor Commented:
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
0
 
for_yanCommented:
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
0
 
weblogicmeAuthor Commented:
Using oracle database client, is it possible to create a local test database, so that I can create stored procedures in it?
0
 
for_yanCommented:
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.
0
 
weblogicmeAuthor Commented:
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?
0
 
for_yanCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.