You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gora.apache.org by Lewis John Mcgibbney <le...@gmail.com> on 2011/11/23 16:32:57 UTC

Problems with Gora Tutorial???

Hi Guys,

Was going through the main tutorial with a student today and ran into a
ClassCastException, which I have appended to this thread. This is
encountered in most recent trunk when attempting to run a parse with the
logmanager, having already compiled the Avro schema and defined the mapping.

Please correct me if I'm not seeing this clearly, but does the parse method
not try to read the String line, which is specified in both
gora-hbase-mapping and gora-sql-mapping.xml as keyClass="java.lang.Long".
Is it here, or somewhere else that there is a mismatch in data types?

Thanks

  /**
   * Parses a log file and store the contents at the data store.
   * @param input the input file location
   */
  private void parse(String input) throws IOException, ParseException {
    log.info("Parsing file:" + input);
    BufferedReader reader = new BufferedReader(new FileReader(input));
    long lineCount = 0;
    try {
      String line = reader.readLine();
      do {
        Pageview pageview = parseLine(line);

        if(pageview != null) {
          //store the pageview
          storePageview(lineCount++, pageview);
        }

        line = reader.readLine();
      } while(line != null);

    } finally {
      reader.close();
    }
    log.info("finished parsing file. Total number of log lines:" +
lineCount);
  }



lewis@lewis-desktop:~/ASF/gora_trunk$ bin/gora logmanager -parse
gora-tutorial/src/main/resources/access.log
Exception in thread "main" java.lang.ClassCastException: java.lang.Long
cannot be cast to java.lang.String
    at org.apache.gora.mock.store.MockDataStore.put(MockDataStore.java:36)
    at
org.apache.gora.tutorial.log.LogManager.storePageview(LogManager.java:140)
    at org.apache.gora.tutorial.log.LogManager.parse(LogManager.java:91)
    at org.apache.gora.tutorial.log.LogManager.main(LogManager.java:240)


-- 
*Lewis*

Re: Problems with Gora Tutorial???

Posted by Lewis John Mcgibbney <le...@gmail.com>.
Hi Enis,

Thanks for this, this was a stupid mistake on my part, we got it fixed
thanks to your suggestions.

I'm trying to work more more with the HBase (which I am not wholly
confident with) module just now so hopefully I'll be learning a decent bit
over the forthcoming while.

Thanks again

Lewis

On Wed, Nov 23, 2011 at 11:12 PM, Enis Söztutar <en...@gmail.com> wrote:

> Hi Lewis,
>
> In the exception log, I see MockDataStore, rather than HBaseStore, and this
> might indicate that the configuration cannot be found, or is not showing
> the correct data store. Could you please check whether gora.properties is
> setup to show the actual HBaseStore, and this is included in the classpath.
> Did you check out the source code from scratch?
>
> Thanks,
> Enis
>
> On Wed, Nov 23, 2011 at 7:32 AM, Lewis John Mcgibbney <
> lewis.mcgibbney@gmail.com> wrote:
>
> > Hi Guys,
> >
> > Was going through the main tutorial with a student today and ran into a
> > ClassCastException, which I have appended to this thread. This is
> > encountered in most recent trunk when attempting to run a parse with the
> > logmanager, having already compiled the Avro schema and defined the
> > mapping.
> >
> > Please correct me if I'm not seeing this clearly, but does the parse
> method
> > not try to read the String line, which is specified in both
> > gora-hbase-mapping and gora-sql-mapping.xml as keyClass="java.lang.Long".
> > Is it here, or somewhere else that there is a mismatch in data types?
> >
> > Thanks
> >
> >  /**
> >   * Parses a log file and store the contents at the data store.
> >   * @param input the input file location
> >   */
> >  private void parse(String input) throws IOException, ParseException {
> >    log.info("Parsing file:" + input);
> >    BufferedReader reader = new BufferedReader(new FileReader(input));
> >    long lineCount = 0;
> >    try {
> >      String line = reader.readLine();
> >      do {
> >        Pageview pageview = parseLine(line);
> >
> >        if(pageview != null) {
> >          //store the pageview
> >          storePageview(lineCount++, pageview);
> >        }
> >
> >        line = reader.readLine();
> >      } while(line != null);
> >
> >    } finally {
> >      reader.close();
> >    }
> >    log.info("finished parsing file. Total number of log lines:" +
> > lineCount);
> >  }
> >
> >
> >
> > lewis@lewis-desktop:~/ASF/gora_trunk$ bin/gora logmanager -parse
> > gora-tutorial/src/main/resources/access.log
> > Exception in thread "main" java.lang.ClassCastException: java.lang.Long
> > cannot be cast to java.lang.String
> >    at org.apache.gora.mock.store.MockDataStore.put(MockDataStore.java:36)
> >    at
> >
> org.apache.gora.tutorial.log.LogManager.storePageview(LogManager.java:140)
> >    at org.apache.gora.tutorial.log.LogManager.parse(LogManager.java:91)
> >    at org.apache.gora.tutorial.log.LogManager.main(LogManager.java:240)
> >
> >
> > --
> > *Lewis*
> >
>



-- 
*Lewis*

Re: Problems with Gora Tutorial???

Posted by Enis Söztutar <en...@gmail.com>.
Hi Lewis,

In the exception log, I see MockDataStore, rather than HBaseStore, and this
might indicate that the configuration cannot be found, or is not showing
the correct data store. Could you please check whether gora.properties is
setup to show the actual HBaseStore, and this is included in the classpath.
Did you check out the source code from scratch?

Thanks,
Enis

On Wed, Nov 23, 2011 at 7:32 AM, Lewis John Mcgibbney <
lewis.mcgibbney@gmail.com> wrote:

> Hi Guys,
>
> Was going through the main tutorial with a student today and ran into a
> ClassCastException, which I have appended to this thread. This is
> encountered in most recent trunk when attempting to run a parse with the
> logmanager, having already compiled the Avro schema and defined the
> mapping.
>
> Please correct me if I'm not seeing this clearly, but does the parse method
> not try to read the String line, which is specified in both
> gora-hbase-mapping and gora-sql-mapping.xml as keyClass="java.lang.Long".
> Is it here, or somewhere else that there is a mismatch in data types?
>
> Thanks
>
>  /**
>   * Parses a log file and store the contents at the data store.
>   * @param input the input file location
>   */
>  private void parse(String input) throws IOException, ParseException {
>    log.info("Parsing file:" + input);
>    BufferedReader reader = new BufferedReader(new FileReader(input));
>    long lineCount = 0;
>    try {
>      String line = reader.readLine();
>      do {
>        Pageview pageview = parseLine(line);
>
>        if(pageview != null) {
>          //store the pageview
>          storePageview(lineCount++, pageview);
>        }
>
>        line = reader.readLine();
>      } while(line != null);
>
>    } finally {
>      reader.close();
>    }
>    log.info("finished parsing file. Total number of log lines:" +
> lineCount);
>  }
>
>
>
> lewis@lewis-desktop:~/ASF/gora_trunk$ bin/gora logmanager -parse
> gora-tutorial/src/main/resources/access.log
> Exception in thread "main" java.lang.ClassCastException: java.lang.Long
> cannot be cast to java.lang.String
>    at org.apache.gora.mock.store.MockDataStore.put(MockDataStore.java:36)
>    at
> org.apache.gora.tutorial.log.LogManager.storePageview(LogManager.java:140)
>    at org.apache.gora.tutorial.log.LogManager.parse(LogManager.java:91)
>    at org.apache.gora.tutorial.log.LogManager.main(LogManager.java:240)
>
>
> --
> *Lewis*
>