Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Tomcat crashing

807603Nov 16 2007 — edited Nov 16 2007
All,
tomcat is crashing and I dont know why.
It happens when I run this class:
package ClientDataProc;

import org.apache.regexp.*;

import java.util.*;
import ClientDataProc.Logging;
import ClientDataProc.BalancesDataClass;
import ClientDataProc.ControlsAccess;
import au.com.bytecode.opencsv.CSVReader;

import java.io.*;


public class CSVBalanceParse {

String find="";
//lets get headers from config file.

String finalDate ="";
String date ="";

private Logging log = new Logging();

public CSVBalanceParse(Logging l){
	log = l;
}

public Logging getLog(){
	return log;
	
}




	public LinkedList<BalancesDataClass> readData(BufferedReader filename, InputStream config, String bo)throws IOException {
		
		
		
		
		//read our properties file
		System.out.println("Getting props");
		Properties props = new Properties();
		//FileInputStream in = new FileInputStream("my.properties");
		try{
			props.load(config);
		}catch(IOException ioe){
		ioe.printStackTrace();
		}
		
		//get our headers.
		System.out.println("Getting headers");
		String headers = props.getProperty("balanceHeaders");
		String[] headerResults = headers.split(",");
		
		//System.out.println(headers);
		//get our row offset. This tells app which line to start processing from.
		String offset = props.getProperty("balanceOffset");
		int startLine = Integer.parseInt(offset);
		//System.out.println(startLine);
		String fundco="";
		
		ControlsAccess controls = new ControlsAccess(log);
		
		
		
		LinkedList<BalancesDataClass> list = new LinkedList<BalancesDataClass>();
		/*System.out.println("Getting date");
		String date = findDate(filename);*/
		
		
			
			//now we read the data file.
			CSVReader reader = new CSVReader(filename,',','\"',startLine);
			String[] data;
			while((data = reader.readNext()) != null){
				BalancesDataClass balances = new BalancesDataClass(controls,bo,-1,log);		
				for(int i =0;i<headerResults.length;i++){
					
					
				
					System.out.println(headerResults[i] + data[i] + date);	
					balances.saveData(headerResults, data[i]);

balances.setDate("20071116");

}
list.add(balances);
}


//System.out.println(list.size());
return list;











}

public String findDate(BufferedReader buf){
//establish csv reader
CSVReader reader = new CSVReader(buf);
String line="";

String finalDate="";
String pattern = "[0-9][0-9]" + "/" + "[0-9][0-9]" + "/" + "[0-9][0-9][0-9][0-9]";
RE r = new RE(pattern);
try{
while((line = buf.readLine()) != null){
//System.out.println(line);
if(r.match("Line" + line)){
finalDate = r.getParen(0);
break;
}
}
}catch(IOException io){
io.printStackTrace();
}

return finalDate;
}


}



When I run a class, that is very similar, I get no problems:
Code of successful class:
package ClientDataProc;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import org.apache.regexp.*;

import java.util.*;
import ClientDataProc.Logging;
import ClientDataProc.ClientDataClass;
import ClientDataProc.ControlsAccess;
import au.com.bytecode.opencsv.CSVReader;
import java.io.*;


public class CSVClientParse {


String find="";

String finalDate ="";
String date ="";
StringBuffer buf = new StringBuffer();
private Logging log = new Logging();


public CSVClientParse(Logging l){
	log = l;
}

public Logging getLog(){
	return log;
	
}



	public LinkedList<ClientDataClass> readData(BufferedReader filename, InputStream config, String backoffice)throws IOException {
		//read our properties file
		Properties props = new Properties();
		
		
		

		
		try{
			props.load(config);
		}catch(IOException ioe){
		ioe.printStackTrace();
		}
		
		//get our headers.
		String headers = props.getProperty("clientHeaders");
		String[] headerResults = headers.split(",");
		

		//getting from params

		String fundco = "";
		//System.out.println(headers);
		
		//get our row offset. This tells app which line to start processing from.
		String offset = props.getProperty("clientOffset");
		int startLine = Integer.parseInt(offset);
		//System.out.println("StartLine"+startLine);
		
		
		ControlsAccess controls = new ControlsAccess(log);
		
		
		
		LinkedList<ClientDataClass> list = new LinkedList<ClientDataClass>();
		
		
		
		
		String fileDate = findDate(filename);
		Date d = null;
		try{
		d = new SimpleDateFormat("MM/dd/yyyy").parse(fileDate);
		SimpleDateFormat newFormat = new SimpleDateFormat("yyyyMMdd");
		
		}catch(ParseException pe){
			pe.printStackTrace();
		}
		String date = String.valueOf(d);

					
		//now we read the data file.
		//problem
	CSVReader reader = new CSVReader(filename,',','\"',startLine);
	//System.out.println("Here");
	String[] data;
		
	while((data = reader.readNext()) != null){
		ClientDataClass client = new ClientDataClass(fundco, backoffice, log);
			//System.out.println(data[0] + data[1]);
		for(int i = 0;i<headerResults.length;i++){
			
			
			System.out.println(headerResults[i] + data[i] + date);
			client.saveData(headerResults, data[i]);
client.setDate("20071116");
}
list.add(client);

}



return list;


}

public String findDate(BufferedReader buf){
//establish csv reader
CSVReader reader = new CSVReader(buf);
String line="";

String finalDate="";
String pattern = "[0-9][0-9]" + "/" + "[0-9][0-9]" + "/" + "[0-9][0-9][0-9][0-9]";
RE r = new RE(pattern);
try{
while((line = buf.readLine()) != null){
//System.out.println(line);
if(r.match("Line" + line)){
finalDate = r.getParen(0);
break;
}
}
}catch(IOException io){
io.printStackTrace();
}

return finalDate;
}


}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 14 2007
Added on Nov 16 2007
3 comments
111 views