« Back to CVP - All Versions

RE: Run Time error:- java.lang.ClassCastException: ModularDBbackup. Need he

Combination View Flat View Tree View
Threads [ Previous | Next ]
I have a number of configuration databases installed (MS SQL Server 2008), which have the same tables and values and have replication enabled among them. I read values from these tables and in my CVP Studio application "Master.app" and perform actions.
Currently, for DB connection in Studio app "Master.app", I statically mention the JNDI name for connection to DB. So, I do not have a redundancy in place for the database connection from my app.
To resolve this, I have created an Action Class to read JNDI names entered in an XML file, perform a connection test, and return the JNDI name as a session variable to the "Master.app" studio application. This action class is called right after the "CVP Subdialog Start" element in the Master application.
But, when I ran my code, I get the run tim error -  java.lang.ClassCastException: ModularDBbackup
I then tried to run the application using "StartCallInterface" and method "OnStartCall"; and calling the ModularDBbackup at the start of the Master application, but face the same error - classcastexception.
Does anyone have any idea why is this happening?
 
The error is given below ----
 
10.204.3.134.1307453348333.0.MS2,06/07/2011 13:29:08.395,There was a problem instantiating the dynamic configuration class ModularDBbackup. The error was: java.lang.ClassCastException: ModularDBbackup
java.lang.ClassCastException: ModularDBbackup
at com.audium.server.voiceElement.ActionElementBase.determineConfig(ActionElementBase.java:486)
at com.audium.server.voiceElement.ActionElementBase.service(ActionElementBase.java:358)
at com.audium.server.controller.Controller.goToAction(Controller.java:2751)
at com.audium.server.controller.Controller.goToElement(Controller.java:2493)
at com.audium.server.controller.Controller.continueCall(Controller.java:2317)
at com.audium.server.controller.Controller.doPost(Controller.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:834)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
at java.lang.Thread.run(Thread.java:595)
 
 
 
My actual source code is given below -------------------------------------
 

/*  ********************************************/
/* @author AmlanDas
/*  ********************************************/
 
 
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
 
import org.igfay.jfig.JFig;
import org.igfay.jfig.JFigConstants;
import org.igfay.jfig.JFigException;
import org.igfay.jfig.JFigIF;
import org.igfay.jfig.JFigLocator;
 
import com.audium.server.AudiumException;
import com.audium.server.session.ActionElementData;
import com.audium.server.voiceElement.ActionElementBase;
//import com.audium.server.voiceElement.ElementInterface;
import org.apache.log4j.*;
 
 
public class ModularDBbackup extends ActionElementBase
{
String logFilename = "/Cisco/CVP/VXMLServer/logs/ModularDBbackup.log";
String maxFileSize = "20MB";
int maxNumFiles = 20;
String logLevel = "TRACE";
public static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(ModularDBbackup.class);

JFigLocator configLocator;
static String configFileName = "DBconfig.xml";
String configPath;
JFigIF config;
public void doAction(String name, ActionElementData actionData) throws AudiumException
    {
actionData.addToLog("Entered the ", "ModularDBbackup class");
try
{
// Initialize the log4j Loggers
 
PatternLayout logFileLayout = new PatternLayout("%d{dd-MMM-yyyy HH:mm:ss,SSS} [%t] %-5p %c{1}.%m%n");
RollingFileAppender appender = new RollingFileAppender(logFileLayout, logFilename);
 
//appender.setFile(Filename.generateTimestampFilename(logFolderPath, strLogFileName, ".log"));
appender.setMaxFileSize(maxFileSize);
appender.setMaxBackupIndex(maxNumFiles);
appender.activateOptions();
logger.addAppender(appender);
logger.setLevel(org.apache.log4j.Level.toLevel(logLevel));

// Load JNDI name search configuration
// This is used to load the JNDI name configuration stored in
// the DBconfig.xml file.
BasicConfigurator.configure();
try 
{
logger.debug("Entered the config loader space");
// Configure the LF5Appender using the DefaultLF5Configurator.  
configLocator = new JFigLocator(configFileName);
   Map<String, String> env = System.getenv();
   configPath = env.get("JNDI_Search_Path");
 
   if (configPath != null)
   {
    if (!configPath.endsWith("\\"))
    {
    configPath = configPath.concat("\\");
    }
    configLocator.setConfigDirectory(configPath);
configLocator.setConfigLocation(JFigConstants.FILE);
logger.debug("Read the config from system variables");
   }
   else
   {
    // Write Error message and continue. 
    logger.error("Environment Variable JNDI_Search_Path not set. Can't get applicaiton configuration");
   }

JFig.initialize(configLocator);
config = JFig.getInstance();
 

catch (JFigException jfEx) {
logger.error(jfEx.getMessage());
}


}
catch (Exception Ex)
{
logger.error(Ex.getMessage());
}
 
String method = "getJNDIname";
boolean rowFound = false;
String value = null;
String key = "JNDI_";
String JNDIValue = "ModularA";
List JNDI_list = JFig.getInstance().getValuesStartingWith("Modular_DB_JNDI_names", key);
ListIterator JNDI_listIterator = JNDI_list.listIterator();
logger.debug("Populated list with DB information values");
// Make sure we have at least one entry in the iterator
if (JNDI_listIterator.hasNext())
{
while(JNDI_listIterator.hasNext()&& !rowFound)
{
value = (String)JNDI_listIterator.next();
if ((value != null) && (value.compareTo("") != 0))
{
try
{
Context initialContext = new InitialContext();
if(initialContext == null )
{
logger.error(method  + "Error - No DB Naming Context created, cannot continue insert.");
}
else
{
for(int i=0; i<10; i++)
{
Context envContext  = (Context)initialContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup(value);
if (ds != null) 
{
try
{
Connection tempcon = ds.getConnection();
Statement stmt = tempcon.createStatement();
String sqlstmt = "Select * from Modular.dbo.Customers";
ResultSet rs = null;
rs=stmt.executeQuery(sqlstmt);
if(rs.next())
{
JNDIValue = value;
i = 10;
}
else
{
if (JNDI_listIterator.hasNext())
{
value = (String)JNDI_listIterator.next();
}
else{
logger.debug("There are no active DB connections. Please check the DB status");
}
}
}
catch (SQLException ex)
{
logger.debug("Caught SQL exception " + ex );
}
}
}
}
}
catch (Exception x)
{
logger.debug("Caught SQL exception " + x );
}
}
else
{
logger.debug("The value returned for JNDI name lookup is NULL");
}
}
}
//JNDIValue = this.getJNDIName();
actionData.setSessionData("JNDI_name", JNDIValue);
actionData.addToLog("ModularDBbackup", "getJNDIName: JNDI name returned is" + JNDIValue);
}
}

I have found the solution to this. I would rather say I was acting stupid. For the benefit of all those whose viewed this post -
I was calling the Action class as a Dynamic configuration class from the Cisco ready-made Database element.
Using a separate Action class above the Database element has resolved the issue.