[Biojava-l] exception with no stacktrace

Cox, Greg gcox@netgenics.com
Fri, 1 Mar 2002 10:07:24 -0500


Sorry, I can't replicate your error.  When I run your code, a class cast
exception is generated where SymbolList list is assigned, but no null
pointer exception.  Anyone else want to take a swing?

Greg

> -----Original Message-----
> From: Guoneng Zhong [mailto:Guoneng.Zhong@med.nyu.edu]
> Sent: Friday, March 01, 2002 9:05 AM
> To: Cox, Greg
> Cc: biojava-l@biojava.org
> Subject: Re: [Biojava-l] exception with no stacktrace
> 
> 
> This is the function that has the code I included:
> 
>      private static void readFile() throws Exception{
>          String file = "[some path]";
>          AlignmentFormat format = new MSFAlignmentFormat();
>          BufferedReader reader = new BufferedReader(new 
> FileReader(file));
>          if(false){
>              String line = null;
>              while((line=reader.readLine()) != null){
>                  System.out.println(line);
>              }
> 	return;
>          }
>          Alignment alignment = format.read(reader);
>          List labels = alignment.getLabels();
>          System.out.println("Retrieved "+labels.size()+" labels");
>          for(int i=0;i<labels.size();i++){
>              SymbolList list = (SymbolList)labels.get(i);
>              System.out.println(list.seqString());
>          }
>          reader.close();
>      }
> 
> The if statement on false is my way of testing and to show 
> you that when 
> I switch it to true, the buffered reader works.  So there's nothing 
> wrong with the reader.  But when I switch that block to 
> false, and let 
> the alignment parser use the reader, I get this null pointer 
> exception 
> that is not at all informative of where the problem is.  It could be 
> that the output I have has a missing part, but the exception does not 
> tell me anything.
> 
> Is there any other way I can debug this without downloading 
> the source 
> code and incorporate it into my IDE and step through with my debugger?
> 
> Thanks,
> Guoneng
> 
> On Thursday, February 28, 2002, at 04:54 PM, Cox, Greg wrote:
> 
> > I'd need to see all your code to be sure, but it looks like 
> your file 
> > isn't
> > initialized, and that's what's causing the null pointer exception.  
> > Whenere
> > is 'file' coming from in creating the bufferedReader?  If 
> you're sure 
> > it's
> > valid, I'd recommed breaking that line up into sub lines to 
> track down 
> > which
> > statement is causing problems.
> >
> > Greg
> >
> >> -----Original Message-----
> >> From: Guoneng Zhong [mailto:Guoneng.Zhong@med.nyu.edu]
> >> Sent: Thursday, February 28, 2002 4:31 PM
> >> To: biojava-l@biojava.org
> >> Subject: [Biojava-l] exception with no stacktrace
> >>
> >>
> >> Hi,
> >> I tried the following lines and got the following exception.
> >> Problem is
> >> that I don't know what the problem is.  What line and what the
> >> underlying cause.  There is no stacktrace beyond my own...
> >>
> >> Thanks ahead for all the help!
> >>
> >> G
> >>
> >>          AlignmentFormat format = new MSFAlignmentFormat();
> >>          Alignment alignment = format.read(new BufferedReader(new
> >> FileReader(file)));
> >>          List labels = alignment.getLabels();
> >>          System.out.println("Retrieved "+labels.size()+" labels");
> >>          for(int i=0;i<labels.size();i++){
> >>              SymbolList list = (SymbolList)labels.get(i);
> >>              System.out.println(list.seqString());
> >>          }
> >>
> >> MSFFormatReader null
> >> Exception in thread "main" java.lang.NullPointerException
> >> 	at test.TestClustalW.readFile(TestClustalW.java:27)
> >> 	at test.TestClustalW.main(TestClustalW.java:20)
> >>
> >> _______________________________________________
> >> Biojava-l mailing list  -  Biojava-l@biojava.org
> >> http://biojava.org/mailman/listinfo/biojava-l
> >>
>