Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Stack Trace generating Word Counts

  • Paul Jungwirth
    Paul Jungwirth


    I was running the step for Word Counts (./runjava perseus.document.WordCountLoader). It ran for a about two hours (on a fast machine), then ended with this stack trace:

    Exception in thread "main" java.lang.NoClassDefFoundError: language (wrong name: perseus/util/Language)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:164)
            at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
            at org.hibernate.impl.SessionFactoryImpl.getImportedClassName(SessionFactoryImpl.java:731)
            at org.hibernate.hql.QuerySplitter.getImportedClass(QuerySplitter.java:132)
            at org.hibernate.hql.QuerySplitter.concreteQueries(QuerySplitter.java:98)
            at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:68)
            at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
            at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
            at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
            at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
            at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
            at perseus.document.HibernateWordCountDAO.aggregateCorpus(HibernateWordCountDAO.java:132)
            at perseus.document.WordCountLoader.aggregateCounts(WordCountLoader.java:131)
            at perseus.document.WordCountLoader.processCorpus(WordCountLoader.java:40)
            at perseus.document.WordCountLoader.main(WordCountLoader.java:78)

    I'm not sure if that means the step failed or not.

    I'm not sure if it matters, but on my system I only loaded the Greek & Latin texts. I did edit the hopper.properties file as described in the instructions.


    • Rashmi S
      Rashmi S

      I've never gotten this error when loading the Word Counts, so I think it failed.  Nothing is jumping out as the cause for this problem.  Check your database using the query: select * from hib_word_counts where document_id like "Perseus:collection%";  You should have a bunch of results where document_id=Perseus:collection:Greco-Roman.  If not, then this will cause problems in the following jsp files: reading/jsp/collection.jsp, text.jsp, and reading/jsp/index/collections.jsp.  The code for the Word Count boxes may cause errors if there is nothing in the database.

      • Paul Jungwirth
        Paul Jungwirth

        Sure enough, there are no rows in hib_word_counts.

        After a bit of Googling, I came across this post, which seems to display an analagous problem:


        I think this may be a Hibernate bug. From the stack trace, it looks like Hibernate is trying to treat the "language" from the query as a classname, without translating it into "perseus.util.Language" first. After reading that whole linked conversation, I tried renaming WordCount.get/setLanguage() to WordCount.get/setLang(). I also changed the private "language" member to "lang," though that was probably not necessary. Then I changed the Hibernate cfg file and the queries in perseus.document.HibernateWordCountDAO to use "lang" instead of "language." I also had to change jsp/collection.jsp. Once all that was done, I was able to say "ant clean dist jsp," and then the word-count step ran without errors. My hib_word_counts table has rows in it now.

        I'm a little nervous changing your code, especially since it makes upgrading hard, but this seems to get around the problem. It really looks like a Hibernate bug to me, as if Hibernate thinks "language" is an existing class because it's comparing it against the unqualified class name of perseus.util.Language.

        I'm running Mac OS 10.4.11. Here is my Java:

        $ java -version
        java version "1.5.0_07"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
        Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)


    • Paul Jungwirth
      Paul Jungwirth

      Sourceforge is garbling that URL because it contains an "at" symbol. Here it is with "==AT==" instead of the actual symbol. Obviously you'll have to paste this into your browser and correct the URL:


    • Rashmi S
      Rashmi S

      Looking into this bug more, it appears not to be a problem with Hibernate.  Instead, it appears to be an issue with Mac OS X being case-insensitive, unlike Unix/Linux.  Running the WordCountLoader on Unix does not throw that error, while the same code on a Mac does.  Therefore, the code will be modified, similar to the way you did it, and will be updated in the next release.