JDBC connection issue

Solapas principales


I am using the below code in my REST service and it throws the error "java.lang.NoClassDefFoundError: com/intersys/jdbc/CacheDataSource] with root cause
java.lang.ClassNotFoundException: com.intersys.jdbc.CacheDataSource

Surprisingly when i am using the same code in a static main method its running perfectly. 

package webapps.services.datamgmt.webapps;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.intersys.jdbc.CacheDataSource;

import webapps.services.datamgmt.CacheQueryUtilities;
import webapps.services.datamgmt.dto.UiTestCaseContainer;
import webapps.services.datamgmt.dto.WebAppContainer;

public class CosController {
    public WebAppContainer getIt() {
        WebAppContainer jsonContainer = new WebAppContainer();
        jsonContainer.setErrorText("No Error");
        return jsonContainer;

    public WebAppContainer saveCase(UiTestCaseContainer uiTestCaseContainer) {
        try {
//            CacheQueryUtilities cacheQueryUtility = new CacheQueryUtilities();
//            cacheQueryUtility.InsertUpdateUiTestCase(uiTestCaseContainer);
            CacheDataSource cacheDataSource = new CacheDataSource();
            Connection dbconnection = cacheDataSource.getConnection();
            Statement st = dbconnection.createStatement(); 
            ResultSet rs = st.executeQuery("SELECT * FROM Table1");
            while (rs.next()) {
        } catch (Exception e) {
        WebAppContainer jsonContainer = new WebAppContainer();
        jsonContainer.setErrorText("No Error");
        return jsonContainer;


How are you running both scenarios? The error you're getting is mostly a symtom of the Cache JDBC jar not being present in the classpath. When you run locally it may be present in your IDE but it's not being included in your build thus the REST code is failing.

Thank you , i added the jars in tomcat lib directory and its fixed my issue.