aspose file tools*
The moose likes Other Open Source Projects and the fly likes Cewolf and database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Cewolf and database?" Watch "Cewolf and database?" New topic
Author

Cewolf and database?

michael stoker
Ranch Hand

Joined: Jul 15, 2010
Posts: 39
Hi everyone,

I am using Cewolf for my charts which is working like a charm but now I am facing a problem in drawing an example of a chart with data from a database (which is a Sybase system) and i can't really see why my code is not working. Any help would be very appreciated.
There is my code java:




There is my web.xml:



And there is my jsp:


I am getting this error when i run this example:

java.lang.NoClassDefDoundError raised:
org/jfree/data/DefaultPieDataset


Anyone has an idea please as i don't have a clue why it's not working?

Regards.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54

Does this code actually compile? If so, something is seriously screwed up, because none of these classes is in the org.jfree.data package. Where did you get the idea that they are? I suppose there could be really old JFree versions where the package structure was different, but those would have to be ancient versions indeed; certainly not the ones shipped with cewolf for the last 4 years or so.


Ping & DNS - my free Android networking tools app
michael stoker
Ranch Hand

Joined: Jul 15, 2010
Posts: 39
Hi Ulf anf thank you for your remark.

Yes it does compile without any errors. I am using Jfreechart-1.0.13 so i am not sure if it's actually an old version. But i have been using it before starting with cewolf and it worked fine for me. Do you think that's the reason why i am getting this error? Which version of Jfreechart do you advice me to use please?
Also, i have tried to change the web.xml to add the parameters of the driver for the Sybase database but i am getting an error saying now :

The value for the useBean class attribute de.laures.cewolf.example.PageViewCountData is invalid.


Yet i haven't even changed it so i am very confused concerning the case of a database.

Do you know any good example of a chart with data taken from a database that i can use as example please since the ones i have found on the net give me the same error?

Regards.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
JFreeChart 10.13 is indeed current, yet I doubt that that's what you're using - it does not have those classes in the org.jfree.data package: http://www.jfree.org/jfreechart/api/javadoc/index.html. It seems that you are not compiling and running against the same set of libraries.

I recommend to use the versions that come as part of the cewolfexample web app. Those are the ones I test cewolf against, and what's more, the newer JFreeChart/JCommon versions are known to have at least one bug that impacts cewolf.

I'm not sure what you're saying (or doing) with the whole DB access issue. Where does "de.laures.cewolf.example.PageViewCountData" come from - where and how are you using that? And what do you mean by "change the web.xml to add the parameters of the driver" - which piece of code is supposed to pick those up from web.xml, and how?
michael stoker
Ranch Hand

Joined: Jul 15, 2010
Posts: 39
I will check again about this Jfreechart thing but i can tell you this is the only one i have on my computer and the only one i have added as a jar on my project and it has always worked that way so i don't really know.

About the database point, it's confused i know and i am sorry as i am also very confused in how to fix the different parameters to connect to the database. I tried to follow your tutorial here: http://cewolf.sourceforge.net/new/tutorial/step3.html
It says about the web.xml that we need to add the ressource-reference for the connection instances, which i have done like this :



Then i haven't changed anything else and it gave me the above error and i don't know where "de.laures.cewolf.example.PageViewCountData" comes from as i haven't even used that.
Is it then an error on my web.xml?

Regards.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
You must have used "de.laures.cewolf.example.PageViewCountData" in the JSP page (that wouldn't be a surprise if you followed the tutorial because the tutorial uses that class), and apparently the class not present in the classpath (which is the WEB-INF/classes directory); that's not surprising either, because in the code you posted above the class was named "examples.BarChart".

The resource-ref in the tutorial looks very different from the one in your web.xml; that's not how it works. Start by going through the Tomcat documentation on data sources: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC_Data_Sources, and then modify your <Context> (probably in server.xml) accordingly.

Tackle these problems one at a time, you're only confusing yourself by solving both simultaneously.
michael stoker
Ranch Hand

Joined: Jul 15, 2010
Posts: 39
Thank you very much for your response. My jsp file is the one above and i checked again, i haven't used that class, only at first to try the normal graph on your tutorial to see how cewolf works which worked perfectly but then i replaced it with the new code above.
Ok about the ressource-reference, i just thought that because i am using a Sybase Database (not mysql), i had to specify the port as this is what i normally use to get connected to the database.
I am going to try those changes.

Regards and thank you again.
michael stoker
Ranch Hand

Joined: Jul 15, 2010
Posts: 39
I have made the changes following the links you gave me like this:

web.xml




My jsp file:




And my java code:



And now i get this error:

The value for the useBean class attribute examples.EmployeesByDeptAndYear is invalid.


Why is it invalid please?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54

The Context element does not go into the web.xml file; see the Tomcat documentation: http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

The value for the useBean class attribute examples.EmployeesByDeptAndYear is invalid.

Why is it invalid please?

The class you posted is named "EmployeesByDeptAndQtr", not "EmployeesByDeptAndYear".
michael stoker
Ranch Hand

Joined: Jul 15, 2010
Posts: 39
Aahhhhh Ulf THANK YOU so so so so much, i didn't see that i kept the old class too and forgot to change it, silly me. Thank you very very much, its working perfectly fine!! I didn't even have to change the web.xml.
You have made my day, i am so released now.
I will come to post a final screenshot of my charts and tables with all my codes for other people to use it too.

Thank you again Ulf, you are a GENIUS

Very best regards from France.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cewolf and database?