Java.lang.LinkageError: loader constraint violation?

Hi all. I’m currently receiving the following error message whenever I submit some values on a JSP page I’m using to test a web service:

exception: java.lang.reflect.InvocationTargetException

So far, this issue has been very difficult to track down, so I decided to use a catch block with a Throwable object (i.e. - attempting to output everything that’s causing problems). This is what I saw in the console:

java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/catalina/loader/WebappClassLoader) previously initiated loading for a different type with name “oracle/jdbc/OracleConnection”
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at com.testsystems.soap.user.UserCheck_2.Authenticate.checkPidm(Authenticate.java:63)
at com.testsystems.soap.user.UserCheck_2.Authenticate.authenticate(Authenticate.java:138)
at com.testsystems.soap.user.UserCheck_2.UserCheckPortBindingImpl.checkUser(UserCheckPortBindingImpl.java:44)
at com.testsystems.soap.user.UserCheck_2.UserCheckPortBindingSkeleton.checkUser(UserCheckPortBindingSkeleton.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)

The big thing that seems to pop out in my mind is how this stack output seems to be implying problems with my Oracle connectivity. This is making me believe that I’ve called (or created) an OracleConnection instance incorrectly.

The code responsible for connecting to the database is as follows:

Main Database Connection Class

package mypackage.common;

import java.sql.DriverManager;
import java.sql.SQLException;
import oracle.jdbc.OracleConnection;

public class DBConnect{
	
	private String url;
	private String user;
	private String pass;
	
	public DBConnect(String url, String user, String pass){
		this.url	= url;
		this.user 	= user;
		this.pass 	= pass;
	}
	
	public OracleConnection connect() throws ClassNotFoundException, SQLException{
		Class.forName("oracle.jdbc.OracleDriver");//Loads Oracle driver...
		OracleConnection ora_conn = (OracleConnection) DriverManager.getConnection(url, user, pass);
		return ora_conn;
	}
}

The calling class I’m using to create the connection object is as follows:

Main Calling Class

package my.other.package.UserCheck_2;

import oracle.jdbc.OracleConnection;
import java.sql.SQLException;
import mypackage.common.*;

public class UserCheckPortBindingImpl implements com.testsystems.soap.user.UserCheck_2.UserCheck_PortType{
	
	String url = "jdbc:oracle:thin:@blah.whatever.com:9999:test";
	String user = "username";
	String pass = "password";
	
	public com.testsystems.soap.user.UserCheck_2.CheckUserResponse checkUser(com.testsystems.soap.user.UserCheck_2.CheckUserRequest parameters) throws java.rmi.RemoteException {
		
		DBConnect dbConn 						= new mypackage.common.DBConnect(url, user, pass);
		CheckUserResponse outputObj				= new CheckUserResponse();
		UserStatus stu_userStatus 				= null;
		OracleConnection ora_conn				= null;
		
    	try{		
    		
    		ora_conn							= dbConn.connect();//Assign Oracle connection to ora_conn...
    		Authenticate customer 				= new Authenticate(parameters.getUserId(),parameters.getUserMatch());
    		String st_userStatusMessage			= null;
    		String st_returnedPId				= null;
    		
    		try{
    			
    			st_returnedPId 					= customer.authenticate(ora_conn);
        		Holder record 					= new Holder(st_returnedPId);
        		
        		if(record.HasHolder(ora_conn)){
        			stu_userStatus 				= new UserStatus(UserStatus._HMSG);
        			st_userStatusMessage 		= UserStatus._HMSG;
        		}else{
        			stu_userStatus 				= new UserStatus(UserStatus._VERIFIED);
        			st_userStatusMessage 		= UserStatus._VERIFIED;
        		}
        		
    		}catch(NoMatchException NoMatch){
    			stu_userStatus 					= new UserStatus(UserStatus._NOFIND);
    			st_userStatusMessage 			= UserStatus._NOFIND;
    		}
    		
    		outputObj.setUserId(st_returnedPId);
    		outputObj.setUserStatus(stu_userStatus);
    		outputObj.setUserStatusMessage(st_userStatusMessage);

    	}catch(SQLException e){
			e.printStackTrace();
			throw new java.rmi.RemoteException(e.toString());
		}catch (ClassNotFoundException e){
			e.printStackTrace();
			throw new java.rmi.RemoteException(e.toString());
		}catch (Throwable e){
		    e.printStackTrace();
		}finally{
			if(ora_conn != null){
				try{
					ora_conn.close();
				}catch(Exception e){
					e.printStackTrace();
				}
			}
		}
	    return outputObj;
	}
}

Finally, I’m using another class to perform some business logic and I believe (as per the stack trace) that this is where the problem really is (all System.out.println statements stop their output after the “prep_sql_statement” variable assignment below–does this not insinuate that something is wrong with a library or way I’m using the database?):

Business Logic Class

package my.other.package.UserCheck_2;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import oracle.jdbc.OracleConnection;

public class Authenticate {
		
	String st_pid; 
	UserMatch stu_userData;

	//2 Constructors...
	public Authenticate(UserMatch stu_userData){
		setUserMatch(stu_userData);
	}
	
	public Authenticate(String st_pid, UserMatch stu_userData){
		setPId(st_pid);
		setUserMatch(stu_userData);
	}
	
	public String getPId(){
		return this.st_pid = st_pid;
	}
	
	public UserMatch getUserMatch(){
		return this.stu_userData = stu_userData;
	}
	
	public void setPId(String st_pid){
		this.st_pid = st_pid;
	}
	
	public void setUserMatch(UserMatch stu_userData){
		this.stu_userData = stu_userData;
	}
	
	
	//
	//Returns the true false or error of pid check (pid is passed in).
	//
	public boolean checkPId(OracleConnection ora_conn, String arg_pid) throws SQLException{
		
		PreparedStatement prep_sql_statement 	= null;
		String query 							= null;
		ResultSet returnedQuery 				= null;
		boolean result							= false;
		
		query = "SELECT pid FROM table WHERE pid = ? AND something IS NULL";
		
		try{
			System.out.println("Running 'ora_conn.prepareStatement(query)' in Authenticate within checkPId...");
			prep_sql_statement = ora_conn.prepareStatement(query);//Can't seem to get past this!!!
			System.out.println(prep_sql_statement.toString());
			prep_sql_statement.setString(1, st_pid);
			returnedQuery = prep_sql_statement.executeQuery();
			
			if(returnedQuery.next()){
				result = true;
			}else{
				result = false;
			}
		}finally{
			if(returnedQuery != null)
		    	returnedQuery.close();
		    if(prep_sql_statement != null)
		    	prep_sql_statement.close();
		}
		return result;
	}	
	
	//
	// Primary authentication process...
	//
	public String authenticate(OracleConnection ora_conn) throws NoMatchException{
		PreparedStatement prep_sql_statement = null;
		boolean noMatch 			= false;
		ResultSet returnedQuery 	= null;
		String st_returnPId 		= null;
		
		try{
			if(st_pid != null){		
				if(checkPId(ora_conn, st_pid)){
					st_returnPId = st_pid;
				}else{
					throw new NoMatchException("PId identifier is invalid.");
				}
				//More to come in this section...
				throw new NoMatchException("PId is null.");
			}
		}catch(SQLException e){
			throw new NoMatchException("Hardware error / connection error?");
		}

		return st_returnPId;
	}	
}

All of this goes without saying that my knowledge of Java is still pretty new.

So if anyone can help me understand why I keep getting that obnoxious “exception: java.lang.reflect.InvocationTargetException” error, or better yet, help me fix this damn thing, I would be forever in your debt.

Please let me know if you need further information, too. I’ve masked a lot of the internals due to security of course, but I can help with whatever ambiguity I may have caused in doing so. Just ask. :slight_smile: