8 Replies Latest reply on Apr 27, 2004 8:54 PM by brian1

    Cannot Use JFreeGraph / JCommon Package in JBoss?

    brian1

      I have been trying for several days to add graphing to my app with the JFreeChart package. I continually get noclassdeffound exceptions on a particular package, thought I CAN SEE IT IN THE WAR FILE. everything is spelled right, I have had another experienced J2EE developer re inspect everything (because I thoguth I was going crazy)... and still nothing. I have rebuilt the library, and its dependancy to no avail.
      I once ran into an issue where tomcat would get mad if the same class was on the classpath 2 times, (though i must admit to being confused as to why), and I read a forum that spoke of JBoss using the JCommon/JFreeGraph libs in one of the bundled management apps.... though I cannot find that either, having greped every way I can think of, and actually manually looking inside most of the jar/sar/wars that are in the default deployment directory.
      I have RTFM, and yes, the jars are in the right place in the web app.
      I would greatly appreciate any help/suggestions with this. as you can imagine, I am going nuts, having now spent 10 hours + trying to solve this issue...
      Thanks in advance for any help.

        • 1. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
          dannyyates

          Ah, "it doesn't work". Sadly I was mugged on the way to work this morning and my crystal ball was stolen. Sorry.

          • 2. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
            brian1

            ? What exactly does that mean?
            What info do you want? I could post the big pretty stack trace, but the top frames are clear:

            NoClassDefFoundException org.jfree.ui.Drawable not found.

            though it clearly exists in the jcommon-0.9.3.jar file that is in WEB-INF/lib

            Crystal ball? I am looking for someone that can give me a clue, not a snide comment. I apologize if I sound rude, but I am beyond joking with the time I have spent working on this.

            • 3. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
              triathlon98

              You are not giving any information which allows anybody to help you. Starting with the stupid things, like was structure, web.xml (cfr configuration settings), exact names of the libraries etc.

              Joachim

              • 4. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
                dannyyates

                Would you take your car to the mechanic and say "it doesn't work"? Give people something to go on. Stack traces, deployment descriptors, version numbers, etc. Very rarely to people meet with "snide" comments for giving up too much information.

                • 5. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
                  brian1

                  I have to first apolgize for my calling the remark "snide" it still might have been, but i suppose i had it coming, and have said things more rude when posters are as vague as I was. Seriously, I apologize for the vague and the frustration.

                  Now I will post some relevant detail, and I promise, I'll do this first next time
                  First, the versions etc:
                  WinXP - a recent build
                  jdk1.4.2
                  jboss-3.2.2
                  deploying to the default server deployment directory, no special configuration changes to the container.

                  I am trying to use org.jfree.chart.JFreeChart (in JFreeChart-0.9.18.jar file) in a struts action. JFreeChart implements org.jfree.ui.Drawable (In the JCommon-0.9.3 jar file)
                  Here are the relevant sections of the jar/wars:

                  jar -tf dump from JFreeChart-0.9.18.jar:

                  .
                  .
                  .
                  org/jfree/chart/axis/ValueAxis.class
                  org/jfree/chart/axis/ValueTick.class
                  org/jfree/chart/ChartColor.class
                  org/jfree/chart/ChartFactory.class
                  org/jfree/chart/ChartFrame.class
                  org/jfree/chart/ChartMouseEvent.class
                  .
                  .
                  .
                  org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.class
                  org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.class
                  org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.class
                  org/jfree/chart/imagemap/URLTagFragmentGenerator.class
                  org/jfree/chart/JFreeChart.class
                  org/jfree/chart/JFreeChartConstants.class

                  This shows the ChartFactory and JFreeChart are in the JFreeChart jar file.


                  relevant dump from JCommon-0.9.3:
                  org/jfree/ui/about/AboutPanel.class
                  org/jfree/ui/about/LibraryTableModel.class
                  org/jfree/ui/Drawable.class
                  org/jfree/ui/L1R3ButtonPanel.class
                  org/jfree/ui/ArrowPanel.class

                  Now the dump showing that both of these jar files are in my war where they should be:
                  WEB-INF/lib/commons-resources.jar
                  WEB-INF/lib/commons-validator.jar
                  WEB-INF/lib/JAMon.jar
                  WEB-INF/lib/jcommon-0.9.3.jar
                  WEB-INF/lib/jdbc2_0-stdext.jar
                  WEB-INF/lib/jdom.jar
                  WEB-INF/lib/jfreechart-0.9.18.jarWEB-INF/lib/mail.jar




                  The stack trace to the browser from the action:
                  java.lang.NoClassDefFoundError: org/jfree/ui/Drawable
                  at java.lang.ClassLoader.defineClass0(Native Method)
                  at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
                  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
                  at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
                  at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
                  at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
                  at org.jfree.chart.ChartFactory.createVerticalBarChart(Unknown Source)
                  at com.kendig.webclient.action.ChartTestAction.execute(Unknown Source)
                  at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
                  at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)

                  The Code throwing this exception:


                  package com.kendig.webclient.action;
                  
                  import javax.servlet.http.HttpServletRequest;
                  import javax.servlet.http.HttpServletResponse;
                  
                  import org.apache.struts.action.Action;
                  import org.apache.struts.action.ActionForm;
                  import org.apache.struts.action.ActionForward;
                  import org.apache.struts.action.ActionMapping;
                  import org.jfree.chart.ChartFactory;
                  import org.jfree.chart.JFreeChart;
                  
                  /**
                   *This action updates the assignment types for a teacher.
                   *@struts.action
                   * path="/chart"
                   */
                  public class ChartTestAction extends Action
                  {
                   public ActionForward execute(ActionMapping mapping, ActionForm arg1,
                   HttpServletRequest req, HttpServletResponse res) throws Exception
                   {
                   JFreeChart chart = ChartFactory.createVerticalBarChart("","","", null, false, false, false);
                   return null;
                   }
                  }



                  The system I am trying to add this code to is reasonably well developed, and I haven't had any other issues, which is why I was/am so vexed by this one...
                  I really am assuming it is a Dumb*** error on my part, and that I've just been staring at it for too long... i appreciate your time, not only in reading this info, but in tolerating my impatience. (and spelling).



                  • 6. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
                    jonlee

                    Maybe something screwy is going on with the classloading. Have you tried as a sanity check, dumping the two jars in the JBOSS_HOME/server/default/lib instead of putting them in the WEB-INF/lib? It may or may not work, but takes the dynamic classloading out of the equation, I guess.

                    • 7. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
                      brian1

                      Just tried it. The amazing yet frustrating thing... it did not work. The jars are not in the war file, and are in the default server's lib directory, yet the class is not found. To be user they are the right jars, a jar -tf on the JCommon library reveals that org.jfree.ui.Drawable is most certainly in the jar file.
                      I grow more confused by this by the day. Any other suggestions, even really far out ones - please.
                      I will continue to try everything I can think of.

                      • 8. Re: Cannot Use JFreeGraph / JCommon Package in JBoss?
                        brian1

                        rarely have i felt so sheepish.
                        Probably I should re read and memorize the docs on classloading.
                        From the beginning:
                        there is a cool jsp tag library that wraps around the graph generating code, but it only works with an older version of the charting lib. It is not stated that it only works with an older version, so I dl'ed the most current. as i tried to get it working, i did the great no-no - I put a copy of the charting lib in the extension directory, then forgot. :( there's the rub. I failed to put the common lib in the extensions directory, so when I caught the dependency, I dropped both jars into WEB-INF/lib. evidently the jvm was loading the charting code from the extension dir, and when it couldn't load the drawable interface with the same loader, it pukied. All this time... your efforts, my frustration... I have learned a lesson, and will NEVER put anything into the extensions directory again.

                        I always thought the container would load from web-inf/lib first, rather than going to the jvm's loader first... i was sadly wrong, and will be substantially more careful next time.