3 Replies Latest reply on Apr 24, 2009 1:39 PM by peterj

    NoSuchMethodError when accessing library class.

    leomrlima

      My JBoss Version is 4.2.3, and I'm using Sun's JDK 1.6.0_11 in a RHEL 2.6.9-55.ELsmp. I'm also using current Apache POI 3.5-beta5 (poi-3.5-beta5.jar).

      When my application tries to access a method (that compiles OK in Eclipse using the same .jar file), it throws a:

      java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFCell.setCellValue(Lorg/apache/poi/hssf/usermodel/HSSFRichTextString;)V

      Which I find strange, as the only library containing POI files is the correct one. I tried to validate the .jar file used accessing "name=Default,service=LoaderRepository" from the JMX Console. The method displayClassInfo() gets me the same UnifiedClassLoader3 object hash and the correct code source (++++CodeSource: (file:/data/jboss/server/default/lib/poi-3.5-beta5.jar )).

      I tried to 'google' around but I found only references about multiple .jar files, which I don't know is the problem here, because I get the correct .jar when I display the class info.

      What can I do to resolve this? Is there a way to invoce "displayClassInfo()" from inside the App context?

      Thanks!
      Leonardo.

        • 1. Re: NoSuchMethodError when accessing library class.
          peterj

          Perhaps at runtime you are picking up a stray version of the POI JAR file. Try this: add the "-verbose:class" JVM option to JAVA_OPTS in run.bat (Windows) or run.conf (Linux). Redirect stdout and stderr to a file (you will get a lot of output). When you runn, each time a class is loaded the JVM will tell you which JAR file contains the class. This should help you locate the offending JAR file.

          • 2. Re: NoSuchMethodError when accessing library class.
            leomrlima

            PeterJ, thanks for your reply.

            I enabled the option. The output confirmed that the correct .jar is being used:

            [Loaded org.apache.poi.hssf.usermodel.HSSFCell from file:/data/jboss/server/default/lib/poi-3.5-beta5.jar]
            ...
            java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFCell.setCellValue(Lorg/apache/poi/hssf/usermodel/HSSFRichTextString;)V

            So, any more ideas, please?

            Thanks in advance,
            Leonardo.

            • 3. Re: NoSuchMethodError when accessing library class.
              peterj

              Which class is making this call (if you would have posted the full exception stack trace I would know this...)? Where did it get loaded from?

              Both the callee class, and the HSSFCell class, at compile time, agreed on the signature of the setCellValue() method or else the compiler would have complained. Thus one of those classes is now incorrect.

              Another possibility is that the JAR file is corrupted. Try using javap or a decompiler to view the signature for the setCellValue method.